Skip to content

Commit d12ae43

Browse files
authored
Update linters (#40)
1 parent f7b4956 commit d12ae43

12 files changed

+295
-162
lines changed

.config/constraints.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# This file was autogenerated by uv via the following command:
2+
# tox run -e deps
3+
coverage==7.6.10 # via pytest-plus (pyproject.toml)
4+
exceptiongroup==1.2.2 # via pytest
5+
iniconfig==2.0.0 # via pytest
6+
jinja2==3.1.5 # via pytest-html
7+
markupsafe==3.0.2 # via jinja2
8+
packaging==24.2 # via pytest
9+
pluggy==1.5.0 # via pytest
10+
pytest==8.3.4 # via pytest-html, pytest-metadata, pytest-plus (pyproject.toml)
11+
pytest-html==4.1.1 # via pytest-plus (pyproject.toml)
12+
pytest-metadata==3.1.1 # via pytest-html
13+
tomli==2.2.1 # via pytest

.config/requirements-test.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
coverage>=7.0.0
2+
pytest-html

.config/requirements.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pytest>=7.4.2

.pre-commit-config.yaml

Lines changed: 49 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,84 +6,91 @@ repos:
66
- repo: meta
77
hooks:
88
- id: check-useless-excludes
9-
- repo: https://github.com/pre-commit/mirrors-prettier
9+
- repo: https://github.com/rbubley/mirrors-prettier
1010
# keep it before yamllint
11-
rev: v3.0.3
11+
rev: v3.4.2
1212
hooks:
1313
- id: prettier
1414
always_run: true
1515
additional_dependencies:
1616
- prettier
17-
- prettier-plugin-toml
1817
- prettier-plugin-sort-json
19-
- repo: https://github.com/PyCQA/doc8.git
20-
rev: v1.1.1
21-
hooks:
22-
- id: doc8
23-
- repo: https://github.com/python/black
24-
rev: 23.9.1
25-
hooks:
26-
- id: black
27-
language_version: python3
2818
- repo: https://github.com/pre-commit/pre-commit-hooks.git
29-
rev: v4.5.0
19+
rev: v5.0.0
3020
hooks:
21+
- id: check-added-large-files
22+
- id: check-merge-conflict
23+
- id: check-symlinks
24+
- id: debug-statements
25+
- id: detect-private-key
3126
- id: end-of-file-fixer
3227
- id: trailing-whitespace
3328
- id: mixed-line-ending
34-
- id: check-byte-order-marker
29+
- id: fix-byte-order-marker
3530
- id: check-executables-have-shebangs
3631
- id: check-merge-conflict
3732
- id: debug-statements
33+
- repo: https://github.com/codespell-project/codespell
34+
rev: v2.4.1
35+
hooks:
36+
- id: codespell
37+
- repo: https://github.com/pappasam/toml-sort
38+
rev: v0.24.2
39+
hooks:
40+
- id: toml-sort-fix
41+
alias: toml
42+
43+
- repo: https://github.com/tox-dev/tox-ini-fmt
44+
rev: 1.5.0
45+
hooks:
46+
- id: tox-ini-fmt
3847
- repo: https://github.com/astral-sh/ruff-pre-commit
39-
rev: "v0.1.0"
48+
rev: v0.9.4
4049
hooks:
4150
- id: ruff
42-
args: [--fix, --exit-non-zero-on-fix]
51+
args:
52+
- --fix
53+
- --exit-non-zero-on-fix
54+
types_or: [python, pyi]
55+
- id: ruff-format # must be after ruff
56+
types_or: [python, pyi]
4357
- repo: https://github.com/pre-commit/mirrors-mypy
44-
rev: v1.6.0
58+
rev: v1.14.1
4559
hooks:
4660
- id: mypy
4761
# empty args needed in order to match mypy cli behavior
4862
args: [--strict]
4963
additional_dependencies:
5064
- pytest
5165
- repo: https://github.com/adrienverge/yamllint.git
52-
rev: v1.32.0
66+
rev: v1.35.1
5367
hooks:
5468
- id: yamllint
5569
files: \.(yaml|yml)$
5670
types: [file, yaml]
5771
entry: yamllint --strict
58-
- repo: https://github.com/codespell-project/codespell.git
59-
rev: v2.2.6
60-
hooks:
61-
- id: codespell
62-
name: codespell
63-
description: Checks for common misspellings in text files.
64-
entry: codespell
65-
language: python
66-
types: [text]
67-
args: []
68-
require_serial: false
69-
additional_dependencies: []
70-
- repo: https://github.com/jazzband/pip-tools
71-
rev: 7.3.0
72+
73+
- # keep at bottom as these are slower
74+
repo: local
7275
hooks:
73-
- id: pip-compile
74-
entry: pip-compile -q --no-annotate --output-file=requirements.txt pyproject.toml --extra test --strip-extras
76+
- id: deps
77+
name: Upgrade constraints files and requirements
78+
files: ^(pyproject\.toml|.config/.*)$
79+
always_run: true
7580
language: python
76-
files: ^(requirements\.txt|pyproject\.toml)$
77-
alias: deps
7881
language_version: "3.10" # minimal we support officially
82+
entry: python3 -m uv pip compile -q --all-extras --output-file=.config/constraints.txt pyproject.toml --upgrade
83+
pass_filenames: false
84+
stages:
85+
- manual
7986
additional_dependencies:
80-
- pip>=22.3.1
87+
- uv>=0.5.21
8188
- id: pip-compile
82-
entry: pip-compile -q --no-annotate --output-file=requirements.txt pyproject.toml --extra test --strip-extras --upgrade
89+
name: Check constraints files and requirements
90+
files: ^(pyproject\.toml|\.config/.*)$
8391
language: python
84-
files: ^(requirements\.txt|pyproject\.toml)$
85-
alias: up
86-
stages: [manual]
8792
language_version: "3.10" # minimal we support officially
93+
entry: python3 -m uv pip compile -q --all-extras --output-file=.config/constraints.txt pyproject.toml
94+
pass_filenames: false
8895
additional_dependencies:
89-
- pip>=22.3.1
96+
- uv>=0.5.21

.taplo.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[formatting]
2+
# cspell: disable-next-line
3+
# compatibility between toml-sort-fix pre-commit hook and panekj.even-betterer-toml extension
4+
align_comments = false
5+
array_trailing_comma = false
6+
compact_arrays = true
7+
compact_entries = false
8+
compact_inline_tables = true
9+
inline_table_expand = false
10+
reorder_keys = true

.vscode/extensions.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"recommendations": [
3+
"Tyriar.sort-lines",
4+
"charliermarsh.ruff",
5+
"esbenp.prettier-vscode",
6+
"hbenl.vscode-test-explorer",
7+
"ms-python.isort",
8+
"ms-python.mypy-type-checker",
9+
"ms-python.pylint",
10+
"ms-python.python",
11+
"ms-python.vscode-pylance",
12+
"ryanluker.vscode-coverage-gutters",
13+
"shardulm94.trailing-spaces",
14+
"tamasfe.even-better-toml",
15+
"timonwong.shellcheck",
16+
"znck.grammarly"
17+
]
18+
}

.vscode/settings.json

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"[markdown]": {
3+
"editor.defaultFormatter": "esbenp.prettier-vscode"
4+
},
5+
"[python]": {
6+
"editor.codeActionsOnSave": {
7+
"source.fixAll": "explicit",
8+
"source.organizeImports": "explicit"
9+
},
10+
"editor.defaultFormatter": "charliermarsh.ruff",
11+
"editor.formatOnSave": true
12+
},
13+
"[toml]": {
14+
"editor.defaultFormatter": "panekj.even-betterer-toml"
15+
},
16+
"editor.formatOnSave": true,
17+
"evenBetterToml.formatter.alignComments": false,
18+
"evenBetterToml.formatter.arrayTrailingComma": true,
19+
"files.exclude": {
20+
"*.egg-info": true,
21+
".pytest_cache": true,
22+
".tox": true,
23+
"__pycache__": true,
24+
"build": true
25+
},
26+
"git.ignoreLimitWarning": true,
27+
"grammarly.config.documentDomain": "academic",
28+
"grammarly.files.include": ["**/*.txt", "**/*.md"],
29+
"mypy-type-checker.severity": {
30+
"error": "Warning"
31+
},
32+
"python.experiments.optInto": ["pythonTestAdapter"],
33+
"python.terminal.activateEnvironment": true,
34+
"python.testing.pytestEnabled": true,
35+
"python.testing.unittestEnabled": false,
36+
"sonarlint.connectedMode.project": {
37+
"connectionId": "ansible",
38+
"projectKey": "ansible_ansible-lint"
39+
},
40+
"sortLines.filterBlankLines": true,
41+
"yaml.completion": true,
42+
"yaml.customTags": ["!encrypted/pkcs1-oaep scalar", "!vault scalar"],
43+
"yaml.format.enable": false,
44+
"yaml.validate": true
45+
}

pyproject.toml

Lines changed: 91 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,12 @@
11
[build-system]
2+
build-backend = "setuptools.build_meta"
23
requires = [
34
"setuptools >= 63.0.0", # required by pyproject+setuptools_scm integration
4-
"setuptools_scm[toml] >= 7.0.5", # required for "no-local-version" scheme
5-
5+
"setuptools_scm[toml] >= 7.0.5" # required for "no-local-version" scheme
66
]
7-
build-backend = "setuptools.build_meta"
87

98
[project]
10-
# https://peps.python.org/pep-0621/#readme
11-
requires-python = ">=3.10"
12-
dynamic = ["version"]
13-
name = "pytest-plus"
14-
description = "PyTest Plus Plugin :: extends pytest functionality"
15-
readme = "README.md"
16-
authors = [{ "name" = "Sorin Sbarnea", "email" = "[email protected]" }]
17-
maintainers = [
18-
{ "name" = "Sorin Sbarnea", "email" = "[email protected]" }
19-
]
20-
license = { text = "MIT" }
9+
authors = [{"email" = "[email protected]", "name" = "Sorin Sbarnea"}]
2110
classifiers = [
2211
"Development Status :: 5 - Production/Stable",
2312
"Environment :: Console",
@@ -38,52 +27,123 @@ classifiers = [
3827
"Topic :: Software Development :: Quality Assurance",
3928
"Topic :: Software Development :: Testing",
4029
"Topic :: System :: Systems Administration",
41-
"Topic :: Utilities",
30+
"Topic :: Utilities"
4231
]
32+
description = "PyTest Plus Plugin :: extends pytest functionality"
33+
dynamic = ["version", "dependencies", "optional-dependencies"]
4334
keywords = ["testing", "pytest", "plugin"]
44-
dependencies = ["pytest>=7.4.2"]
45-
46-
[project.urls]
47-
homepage = "https://github.com/pytest-dev/pytest-plus"
48-
repository = "https://github.com/pytest-dev/pytest-plus"
49-
changelog = "https://github.com/pytest-dev/pytest-plus/releases"
50-
51-
[project.optional-dependencies]
52-
test = ["coverage>=7.0.0", "pytest-html"]
35+
license = {text = "MIT"}
36+
maintainers = [
37+
{"email" = "[email protected]", "name" = "Sorin Sbarnea"}
38+
]
39+
name = "pytest-plus"
40+
readme = "README.md"
41+
# https://peps.python.org/pep-0621/#readme
42+
requires-python = ">=3.10"
5343

5444
[project.entry-points.pytest11]
5545
plus = "pytest_plus"
5646

57-
[tool.coverage.run]
58-
omit = ["test/*", "/private/var/folders/*", "/tmp/*"]
47+
[project.urls]
48+
changelog = "https://github.com/pytest-dev/pytest-plus/releases"
49+
homepage = "https://github.com/pytest-dev/pytest-plus"
50+
repository = "https://github.com/pytest-dev/pytest-plus"
5951

6052
[tool.coverage.report]
6153
fail_under = 100
6254
omit = ["test/*", "/private/var/folders/*", "/tmp/*"]
6355
show_missing = true
6456

57+
[tool.coverage.run]
58+
omit = ["test/*", "/private/var/folders/*", "/tmp/*"]
59+
6560
[tool.pytest.ini_options]
6661
addopts = "-p no:flaky"
67-
6862
filterwarnings = [
6963
"error",
7064
"ignore:ast.(Str|Num|NameConstant) is deprecated and will be removed in Python 3.14:DeprecationWarning:_pytest.assertion.rewrite",
71-
"ignore:Attribute s is deprecated and will be removed in Python 3.14:DeprecationWarning:_pytest.assertion.rewrite",
65+
"ignore:Attribute s is deprecated and will be removed in Python 3.14:DeprecationWarning:_pytest.assertion.rewrite"
7266
]
7367

7468
[tool.ruff]
69+
cache-dir = "./.cache/.ruff"
70+
fix = true
71+
# Same as Black.
72+
line-length = 88
73+
preview = true
74+
target-version = "py310"
75+
76+
[tool.ruff.lint]
7577
ignore = [
78+
"COM812", # conflicts with ISC001 on format
79+
"CPY001", # missing-copyright-notice
7680
"D203", # incompatible with D211
7781
"D213", # incompatible with D212
7882
"E501", # we use black
83+
"ERA001", # auto-removal of commented out code affects development and vscode integration
84+
"INP001", # "is part of an implicit namespace package", all false positives
85+
"ISC001", # conflicts with COM812 on format
86+
"PLW2901", # PLW2901: Redefined loop variable
87+
"RET504", # Unnecessary variable assignment before `return` statement
88+
# temporary disabled until we fix them:
89+
"ANN",
90+
"ARG002", # Unused method argument (currently in too many places)
91+
"D102", # Missing docstring in public method (currently in too many places)
92+
"FBT001",
93+
"FBT003",
94+
"PLR",
95+
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
96+
"PERF203",
97+
"PD011", # We are not using pandas, any .values attributes are unrelated
98+
"PLW0603", # global lock file in cache dir
99+
# part of preview rules:
100+
"B909", # raise-missing-from
101+
"DOC201", # docstring-missing-returns
102+
"DOC402", # docstring-missing-summary
103+
"DOC501", # docstring-missing-exception
104+
"FURB101",
105+
"FURB103",
106+
"FURB110",
107+
"FURB113",
108+
"FURB118",
109+
"PLC0415",
110+
"PLC2701",
111+
"PLW1641",
112+
"S404"
79113
]
80114
select = ["ALL"]
81-
target-version = "py39"
82-
# Same as Black.
83-
line-length = 88
115+
116+
[tool.ruff.lint.pydocstyle]
117+
convention = "google"
84118

85119
[tool.ruff.per-file-ignores]
86120
"test/**/*.py" = ["S"]
121+
122+
[tool.setuptools.dynamic]
123+
dependencies = {file = [".config/requirements.in"]}
124+
optional-dependencies.test = {file = [".config/requirements-test.in"]}
125+
87126
[tool.setuptools_scm]
127+
# To prevent accidental pick of mobile version tags such 'v6'
128+
git_describe_command = [
129+
"git",
130+
"describe",
131+
"--dirty",
132+
"--long",
133+
"--tags",
134+
"--match",
135+
"v*.*"
136+
]
88137
local_scheme = "no-local-version"
138+
tag_regex = "^(?P<prefix>v)?(?P<version>\\d+[^\\+]*)(?P<suffix>.*)?$"
89139
write_to = "src/pytest_plus/_version.py"
140+
141+
[tool.tomlsort]
142+
in_place = true
143+
sort_inline_tables = true
144+
sort_table_keys = true
145+
146+
[tool.uv.pip]
147+
annotation-style = "line"
148+
custom-compile-command = "tox run -e deps"
149+
no-emit-package = ["pip", "resolvelib", "ruamel-yaml-clib", "uv"]

0 commit comments

Comments
 (0)