Skip to content

Commit 93805e5

Browse files
committed
feat: separate package configuration in pyproject.toml from the package’s development configuration and dependencies
1 parent acc0409 commit 93805e5

5 files changed

Lines changed: 222 additions & 219 deletions

File tree

.pre-commit-config.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ repos:
2727
hooks:
2828
- id: isort
2929
name: Sort import statements
30-
args: [--settings-path, pyproject.toml]
30+
args: [--settings-path, develop.toml]
3131
stages: [pre-commit]
3232

3333
# Add Black code formatters.
@@ -36,7 +36,7 @@ repos:
3636
hooks:
3737
- id: black
3838
name: Format code
39-
args: [--config, pyproject.toml]
39+
args: [--config, develop.toml]
4040
- repo: https://github.com/asottile/blacken-docs
4141
rev: 1.19.1
4242
hooks:
@@ -67,7 +67,7 @@ repos:
6767
args: [--config, .flake8]
6868

6969
# Run Pylint from the local repo to make sure venv packages
70-
# specified in pyproject.toml are available.
70+
# specified in develop.toml are available.
7171
- repo: local
7272
hooks:
7373
- id: pylint
@@ -76,7 +76,7 @@ repos:
7676
language: python
7777
files: ^src/package/|^tests/
7878
types: [text, python]
79-
args: [--rcfile, pyproject.toml]
79+
args: [--rcfile, develop.toml]
8080

8181
# Type-check all Python code.
8282
- repo: local
@@ -87,15 +87,15 @@ repos:
8787
language: python
8888
files: ^src/package/|^tests/
8989
types: [text, python]
90-
args: [--config-file, pyproject.toml]
90+
args: [--config-file, develop.toml]
9191

9292
# Check for potential security issues.
9393
- repo: https://github.com/PyCQA/bandit
9494
rev: 1.7.10
9595
hooks:
9696
- id: bandit
9797
name: Check for security issues
98-
args: [--configfile, pyproject.toml]
98+
args: [--configfile, develop.toml]
9999
files: ^src/package/|^tests/
100100
types: [text, python]
101101
additional_dependencies: ['bandit[toml]']
@@ -165,7 +165,7 @@ repos:
165165
hooks:
166166
- id: pytest
167167
name: Run unit tests
168-
entry: pytest -c pyproject.toml --cov-config pyproject.toml src/package/ tests/ docs/
168+
entry: pytest -c develop.toml --cov-config develop.toml src/package/ tests/ docs/
169169
language: python
170170
verbose: true
171171
always_run: true

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ upgrade: .venv/upgraded-on
9696
.venv/upgraded-on: pyproject.toml
9797
python -m pip install --upgrade pip setuptools
9898
python -m pip install --upgrade wheel
99-
python -m pip install --upgrade --upgrade-strategy eager --editable .[actions,dev,docs,hooks,test]
99+
python -m pip install --upgrade --upgrade-strategy eager --editable . --requirement develop-requirements.txt
100100
$(MAKE) upgrade-quiet
101101
force-upgrade:
102102
rm -f .venv/upgraded-on

develop-requirements.txt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
# Manage git hooks.
3+
pre-commit >=4.0.0,<4.3.0
4+
5+
# Manage conventional commits.
6+
commitizen ==4.5.0
7+
8+
# Packaging and distribution.
9+
flit >=3.2.0,<4.0.0
10+
twine >=6.0.0,<6.1.0
11+
12+
# Tools for development and to check Python code.
13+
mypy >=1.0.0,<1.15
14+
pylint >=3.0.0,<3.4.0
15+
perflint >=0.8.0,<1.0.0
16+
17+
# Support for CI and package integrity.
18+
cyclonedx-bom >=4.0.0,<5.0.0
19+
pip-audit >=2.4.4,<3.0.0
20+
21+
# Documentation.
22+
sphinx >=5.1.1,<9.0.0
23+
sphinx-markdown-builder >=0.6.4,<1.0.0
24+
25+
# All things testing.
26+
# Note that the `custom_exit_code` and `env` plugins may currently be unmaintained.
27+
faker ==37.1.0
28+
hypothesis >=6.21.0,<6.130.9
29+
pytest >=7.2.0,<9.0.0
30+
pytest-cases ==3.8.6
31+
pytest-cov ==6.1.0
32+
pytest-custom_exit_code ==0.3.0
33+
pytest-doctestplus ==1.3.0
34+
pytest-env ==1.1.5

develop.toml

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
2+
# https://bandit.readthedocs.io/en/latest/config.html
3+
# Skip test B101 because of issue https://github.com/PyCQA/bandit/issues/457
4+
[tool.bandit]
5+
tests = []
6+
skips = ["B101"]
7+
8+
9+
# https://github.com/psf/black#configuration
10+
[tool.black]
11+
line-length = 120
12+
13+
14+
# https://github.com/commitizen-tools/commitizen
15+
# https://commitizen-tools.github.io/commitizen/bump/
16+
[tool.commitizen]
17+
bump_message = """bump: release $current_version → $new_version
18+
19+
Automatically generated by Commitizen.
20+
"""
21+
tag_format = "v$major.$minor.$patch$prerelease"
22+
update_changelog_on_bump = true
23+
version_files = [
24+
"src/package/__init__.py:__version__",
25+
]
26+
major_version_zero = false
27+
version = "2.16.0"
28+
29+
30+
# https://github.com/pytest-dev/pytest-cov
31+
# https://github.com/nedbat/coveragepy
32+
[tool.coverage.report]
33+
fail_under = 100
34+
show_missing = true
35+
36+
[tool.coverage.run]
37+
branch = true
38+
omit = [
39+
"src/package/__main__.py",
40+
]
41+
42+
43+
# https://pycqa.github.io/isort/
44+
[tool.isort]
45+
profile = "black"
46+
multi_line_output = 3
47+
line_length = 120
48+
skip_gitignore = true
49+
50+
51+
# https://mypy.readthedocs.io/en/stable/config_file.html#using-a-pyproject-toml
52+
[tool.mypy]
53+
# mypy_path =
54+
# exclude =
55+
show_error_codes = true
56+
show_column_numbers = true
57+
pretty = true
58+
show_traceback = true
59+
check_untyped_defs = true
60+
incremental = false
61+
strict = true
62+
warn_return_any = true
63+
warn_redundant_casts = true
64+
warn_unreachable = true
65+
warn_unused_configs = true
66+
warn_unused_ignores = true
67+
disallow_any_explicit = true
68+
disallow_untyped_calls = true
69+
disallow_untyped_defs = true
70+
disallow_incomplete_defs = true
71+
disallow_untyped_decorators = true
72+
# disable_error_code =
73+
# allow_redefinition =
74+
75+
[[tool.mypy.overrides]]
76+
module = [
77+
"pytest.*",
78+
]
79+
ignore_missing_imports = true
80+
81+
82+
# https://pylint.pycqa.org/en/latest/user_guide/configuration/index.html
83+
[tool.pylint.main]
84+
fail-under = 10.0
85+
suggestion-mode = true
86+
load-plugins = [
87+
"perflint", # A Linter for performance anti-patterns.
88+
"pylint.extensions.bad_builtin",
89+
"pylint.extensions.broad_try_clause",
90+
"pylint.extensions.check_elif",
91+
"pylint.extensions.code_style",
92+
"pylint.extensions.comparison_placement",
93+
"pylint.extensions.confusing_elif",
94+
"pylint.extensions.consider_refactoring_into_while_condition",
95+
"pylint.extensions.consider_ternary_expression",
96+
"pylint.extensions.dict_init_mutate",
97+
# "pylint.extensions.docparams",
98+
# "pylint.extensions.docstyle",
99+
"pylint.extensions.dunder",
100+
"pylint.extensions.empty_comment",
101+
"pylint.extensions.for_any_all",
102+
"pylint.extensions.magic_value",
103+
# "pylint.extensions.mccabe",
104+
"pylint.extensions.no_self_use",
105+
"pylint.extensions.overlapping_exceptions",
106+
"pylint.extensions.private_import",
107+
"pylint.extensions.redefined_loop_name",
108+
"pylint.extensions.redefined_variable_type",
109+
"pylint.extensions.set_membership",
110+
"pylint.extensions.typing",
111+
"pylint.extensions.while_used",
112+
]
113+
disable = [
114+
"fixme",
115+
"line-too-long", # Replaced by Flake8 Bugbear B950 check.
116+
"too-few-public-methods",
117+
"too-many-ancestors",
118+
"too-many-arguments",
119+
"too-many-boolean-expressions",
120+
"too-many-branches",
121+
"too-many-instance-attributes",
122+
"too-many-lines",
123+
"too-many-locals",
124+
"too-many-nested-blocks",
125+
"too-many-positional-arguments",
126+
"too-many-public-methods",
127+
"too-many-return-statements",
128+
"too-many-statements",
129+
"too-many-try-statements",
130+
]
131+
132+
[tool.pylint.MISCELLANEOUS]
133+
notes = [
134+
"FIXME",
135+
"TODO",
136+
"BUGBUG",
137+
]
138+
139+
[tool.pylint.FORMAT]
140+
max-line-length = 120
141+
142+
143+
# https://docs.pytest.org/en/latest/reference/customize.html#configuration-file-formats
144+
# https://docs.pytest.org/en/latest/reference/reference.html#configuration-options
145+
# https://docs.pytest.org/en/latest/reference/reference.html#command-line-flags
146+
#
147+
# To integrate Hypothesis into pytest and coverage, we use its native plugin:
148+
# https://hypothesis.readthedocs.io/en/latest/details.html#the-hypothesis-pytest-plugin
149+
#
150+
# To discover tests in documentation, we use doctest and the doctest-plus plugin which
151+
# adds multiple useful options to control tests in documentation. More details at:
152+
# https://docs.python.org/3/library/doctest.html
153+
# https://github.com/scientific-python/pytest-doctestplus
154+
#
155+
# To avoid failing pytest when no tests were dicovered, we need an extra plugin:
156+
# https://docs.pytest.org/en/latest/reference/exit-codes.html
157+
# https://github.com/yashtodi94/pytest-custom_exit_code
158+
[tool.pytest.ini_options]
159+
minversion = "7.0"
160+
addopts = """-vv -ra --tb native --durations 0 \
161+
--hypothesis-show-statistics --hypothesis-explain --hypothesis-verbosity verbose \
162+
--doctest-modules --doctest-continue-on-failure --doctest-glob '*.rst' --doctest-plus \
163+
--suppress-no-test-exit-code \
164+
--cov package \
165+
""" # Consider adding --pdb
166+
# https://docs.python.org/3/library/doctest.html#option-flags
167+
doctest_optionflags = "IGNORE_EXCEPTION_DETAIL"
168+
env = [
169+
"PYTHONDEVMODE=1", # https://docs.python.org/3/library/devmode.html
170+
]
171+
filterwarnings = [
172+
"error",
173+
"always::DeprecationWarning",
174+
# https://docs.pytest.org/en/latest/how-to/failures.html#warning-about-unraisable-exceptions-and-unhandled-thread-exceptions
175+
"error::pytest.PytestUnraisableExceptionWarning",
176+
"error::pytest.PytestUnhandledThreadExceptionWarning",
177+
]

0 commit comments

Comments
 (0)