Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Pre-commit hooks for Pyomo
# See https://pre-commit.com for more information
#
# Setup (one-time):
# pip install pre-commit
# pre-commit install
#
# After setup, hooks run automatically on 'git commit'
# To run manually on all files: pre-commit run --all-files

repos:
- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: black
# Exclusions match pyproject.toml [tool.black] extend-exclude
exclude: |
(?x)^(
examples/pyomobook/python-ch/BadIndent\.py|
pyomo/tpl/.*|
pyomo/dataportal/_parse_table_datacmds\.py
)$

- repo: https://github.com/crate-ci/typos
rev: v1.27.0
hooks:
- id: typos
args: ["--config", ".github/workflows/typos.toml"]
22 changes: 22 additions & 0 deletions doc/OnlineDocs/contribution_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,28 @@ determine correct configuration, so if you are running ``black``
indirectly (for example, using an IDE integration), please ensure you
are not overriding the project-level configuration set in that file.

Pre-commit Hooks (Optional)
^^^^^^^^^^^^^^^^^^^^^^^^^^^

To avoid formatting failures in CI, you can set up
`pre-commit <https://pre-commit.com/>`_ hooks that automatically run
``black`` and the spell-checker on staged files before each commit:

::

pip install pre-commit
pre-commit install

After installation, hooks run automatically when you run ``git commit``.
To manually run hooks on all files:

::

pre-commit run --all-files

This is optional but recommended, as it catches formatting and spelling
issues locally before they reach CI.

Online Pyomo documentation is generated using `Sphinx <https://www.sphinx-doc.org/en/master/>`_
with the ``napoleon`` extension enabled. For API documentation we use of one of these
`supported styles for docstrings <https://www.sphinx-doc.org/en/master/usage/extensions/napoleon.html>`_,
Expand Down
Loading