Skip to content

Commit b14bae7

Browse files
committed
Update developer configuration
1 parent bf1744c commit b14bae7

File tree

7 files changed

+61
-33
lines changed

7 files changed

+61
-33
lines changed

.config/requirements-dev.in

Lines changed: 0 additions & 8 deletions
This file was deleted.

.config/requirements-test.in

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
pytest
22
coverage[toml]
3+
coverage-enable-subprocess
4+
mypy
5+
pip-tools
6+
pre-commit
7+
pydoclint
8+
pytest
39
pytest-xdist
10+
ruff
11+
toml-sort
412
tox
13+
types-PyYAML

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,4 +168,7 @@ cython_debug/
168168
# Version created and populated by setuptools_scm
169169
/src/*/_version.py
170170

171+
# Coverage files
172+
*.lcov
173+
171174
.DS_Store

.vscode/extensions.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
{
22
"recommendations": [
3+
"charliermarsh.ruff",
4+
"esbenp.prettier-vscode",
5+
"markis.code-coverage",
36
"ms-python.black-formatter",
7+
"ms-python.debugpy",
8+
"ms-python.mypy-type-checker",
49
"ms-python.pylint",
5-
"charliermarsh.ruff",
6-
"matangover.mypy",
7-
"esbenp.prettier-vscode"
10+
"ms-python.python",
11+
"streetsidesoftware.code-spell-checker"
812
]
913
}

.vscode/settings.json

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
{
22
"python.testing.unittestEnabled": false,
3-
"python.testing.pytestEnabled": true,
43
// Override the pyproject.toml and disable xdist to enable test debugging
5-
"python.testing.pytestArgs": ["-n0", "--dist", "no"],
4+
"python.testing.pytestArgs": ["tests"],
65
"[python]": {
7-
"editor.formatOnSave": true,
86
"editor.codeActionsOnSave": {
9-
"source.fixAll": "explicit"
7+
"source.fixAll": "explicit",
8+
"source.organizeImports": "explicit"
109
},
11-
"editor.defaultFormatter": "charliermarsh.ruff"
10+
"editor.defaultFormatter": "ms-python.black-formatter",
11+
"editor.formatOnSave": true
1212
},
13-
"mypy.runUsingActiveInterpreter": true,
14-
"mypy.targets": ["src", "tests"],
1513
"[jsonc]": {
1614
"editor.defaultFormatter": "esbenp.prettier-vscode"
17-
}
15+
},
16+
"mypy-type-checker.importStrategy": "fromEnvironment",
17+
"mypy-type-checker.preferDaemon": true,
18+
"mypy-type-checker.reportingScope": "workspace",
19+
"python.testing.pytestEnabled": true,
20+
"markiscodecoverage.searchCriteria": "coverage.lcov"
1821
}

pyproject.toml

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ documentation = "https://ansible.readthedocs.io/projects/dev-environment/"
4040
homepage = "https://github.com/ansible/ansible-dev-environment"
4141
repository = "https://github.com/ansible/ansible-dev-environment"
4242

43+
[tool.coverage.paths]
44+
source = ["src"]
45+
4346
[tool.coverage.report]
4447
exclude_lines = ["if TYPE_CHECKING:", "pragma: no cover"]
4548
# Increase it just so it would pass on any single-python run
@@ -52,12 +55,12 @@ skip_covered = true
5255
skip_empty = true
5356

5457
[tool.coverage.run]
55-
concurrency = ["multiprocessing", "thread"]
58+
source = ["src"]
5659
# Do not use branch until bug is fixes:
5760
# https://github.com/nedbat/coveragepy/issues/605
5861
# branch = true
5962
parallel = true
60-
source = ["src"]
63+
concurrency = ["multiprocessing", "thread"]
6164

6265
[tool.mypy]
6366
files = ["src", "tests"]
@@ -308,33 +311,41 @@ disable = [
308311
"unsubscriptable-object"
309312
]
310313

314+
[tool.pytest.ini_options]
315+
addopts = "-ra --showlocals --durations=10"
316+
tmp_path_retention_policy = "failed"
317+
verbosity_assertions = 2
318+
311319
[tool.ruff]
312320
builtins = ["__"]
313321
fix = true
314322
line-length = 100
315-
select = ["ALL"]
316323
target-version = "py310"
317324

318-
[tool.ruff.flake8-pytest-style]
325+
[tool.ruff.lint]
326+
select = ["ALL"]
327+
328+
[tool.ruff.lint.flake8-pytest-style]
319329
parametrize-values-type = "tuple"
320330

321-
[tool.ruff.isort]
331+
[tool.ruff.lint.isort]
322332
lines-after-imports = 2 # Ensures consistency for cases when there's variable vs function/class definitions after imports
323333
lines-between-types = 1 # Separate import/from with 1 line
324334

325-
[tool.ruff.per-file-ignores]
335+
[tool.ruff.lint.per-file-ignores]
326336
# SLF001: Allow private member access in tests
327337
# S101 Allow assert in tests
328338
# S602 Allow shell in test
329339
# T201 Allow print in tests
330340
"tests/**" = ["SLF001", "S101", "S602", "T201"]
341+
# SIM108, file is generated
342+
"_version.py" = ["SIM108"]
331343

332-
[tool.ruff.pydocstyle]
344+
[tool.ruff.lint.pydocstyle]
333345
convention = "pep257"
334346

335347
[tool.setuptools.dynamic]
336348
dependencies = {file = [".config/requirements.in"]}
337-
optional-dependencies.dev = {file = [".config/requirements-dev.in"]}
338349
optional-dependencies.docs = {file = [".config/requirements-docs.in"]}
339350
optional-dependencies.test = {file = [".config/requirements-test.in"]}
340351

tox.ini

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,25 @@ pass_env =
2525
TERM
2626
USER
2727
set_env =
28+
COVERAGE_FILE = {env:COVERAGE_FILE:{envdir}/.coverage.{envname}}
2829
COVERAGE_PROCESS_START = {toxinidir}/pyproject.toml
2930
FORCE_COLOR = 1
3031
PIP_CONSTRAINT = {toxinidir}/.config/constraints.txt
3132
PRE_COMMIT_COLOR = always
3233
TERM = xterm-256color
3334
commands_pre =
34-
sh -c "rm -f .coverage* coverage.xml 2>/dev/null || true"
35-
commands =
36-
coverage run -m pytest {posargs}
35+
# safety measure to assure we do not accidentally run tests with broken dependencies
36+
{envpython} -m pip check
37+
# cleaning needed to prevent errors between runs
38+
sh -c "rm -f {envdir}/.coverage.* 2>/dev/null || true"commands =
3739
commands_post =
38-
py,py{39,310,311,312}: sh -c "coverage combine .coverage.*"
39-
py,py{39,310,311,312}: coverage xml
40-
py,py{39,310,311,312}: coverage report
40+
# We add coverage options but not making them mandatory as we do not want to force
41+
# pytest users to run coverage when they just want to run a single test with `pytest -k test`
42+
coverage run -m pytest {posargs:-n auto}
43+
# needed for upload to codecov.io
44+
{py,py310,py311,py312,py313}: sh -c "coverage combine -a -q --data-file={envdir}/.coverage {envdir}/.coverage.* && coverage xml --data-file={envdir}/.coverage -o {envdir}/coverage.xml --ignore-errors --fail-under=0 && COVERAGE_FILE={envdir}/.coverage coverage lcov --fail-under=0 --ignore-errors -q && COVERAGE_FILE={envdir}/.coverage coverage report --fail-under=0 --ignore-errors"
45+
# lcov needed for vscode integration due to https://github.com/ryanluker/vscode-coverage-gutters/issues/403
46+
# We fail if files are modified at the end
4147
git diff --exit-code
4248
allowlist_externals =
4349
git

0 commit comments

Comments
 (0)