Skip to content

Commit 039023d

Browse files
authored
Merge pull request #3660 from sadavis1/pyproject-toml-black
Add project-level default configuration for black to pyproject.toml
2 parents 10d6acc + 8f06322 commit 039023d

4 files changed

Lines changed: 19 additions & 7 deletions

File tree

.github/workflows/test_branches.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@ jobs:
4444
python-version: '3.10'
4545
- name: Black Formatting Check
4646
run: |
47-
# Note v24.4.1 fails due to a bug in the parser
47+
# Note v24.4.1 fails due to a bug in the parser. Project-level
48+
# configuration is inherited from pyproject.toml.
4849
pip install 'black!=24.4.1'
49-
black . -S -C --check --diff --exclude examples/pyomobook/python-ch/BadIndent.py
50+
black . --check --diff
5051
- name: Spell Check
5152
uses: crate-ci/typos@master
5253
with:

.github/workflows/test_pr_and_main.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,10 @@ jobs:
5555
python-version: '3.10'
5656
- name: Black Formatting Check
5757
run: |
58-
# Note v24.4.1 fails due to a bug in the parser
58+
# Note v24.4.1 fails due to a bug in the parser. Project-level
59+
# configuration is inherited from pyproject.toml.
5960
pip install 'black!=24.4.1'
60-
black . -S -C --check --diff --exclude examples/pyomobook/python-ch/BadIndent.py
61+
black . --check --diff
6162
- name: Spell Check
6263
uses: crate-ci/typos@master
6364
with:

doc/OnlineDocs/contribution_guide.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,17 @@ run:
3737

3838
# Auto-apply correct formatting
3939
pip install black
40-
black -S -C <path> --exclude examples/pyomobook/python-ch/BadIndent.py
40+
black <path>
4141
# Find typos in files
4242
conda install typos
4343
typos --config .github/workflows/typos.toml <path>
4444
45-
If the spell-checker returns a failure for a word that is spelled correctly,
46-
please add the word to the ``.github/workflows/typos.toml`` file.
45+
If the spell-checker returns a failure for a word that is spelled
46+
correctly, please add the word to the ``.github/workflows/typos.toml``
47+
file. Note also that ``black`` reads from ``pyproject.toml`` to
48+
determine correct configuration, so if you are running ``black``
49+
indirectly (for example, using an IDE integration), please ensure you
50+
are not overriding the project-level configuration set in that file.
4751

4852
Online Pyomo documentation is generated using `Sphinx <https://www.sphinx-doc.org/en/master/>`_
4953
with the ``napoleon`` extension enabled. For API documentation we use of one of these

pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,9 @@ markers = [
8686
"bar: marks bar tests",
8787
"builders: tests that should be run when testing custom (extension) builders",
8888
]
89+
90+
[tool.black]
91+
line-length = 88
92+
skip-string-normalization = true
93+
skip-magic-trailing-comma = true
94+
extend-exclude = 'examples/pyomobook/python-ch/BadIndent.py'

0 commit comments

Comments
 (0)