Skip to content

Commit

Permalink
Update linters (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea authored Jan 31, 2025
1 parent f7b4956 commit d12ae43
Show file tree
Hide file tree
Showing 12 changed files with 295 additions and 162 deletions.
13 changes: 13 additions & 0 deletions .config/constraints.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# This file was autogenerated by uv via the following command:
# tox run -e deps
coverage==7.6.10 # via pytest-plus (pyproject.toml)
exceptiongroup==1.2.2 # via pytest
iniconfig==2.0.0 # via pytest
jinja2==3.1.5 # via pytest-html
markupsafe==3.0.2 # via jinja2
packaging==24.2 # via pytest
pluggy==1.5.0 # via pytest
pytest==8.3.4 # via pytest-html, pytest-metadata, pytest-plus (pyproject.toml)
pytest-html==4.1.1 # via pytest-plus (pyproject.toml)
pytest-metadata==3.1.1 # via pytest-html
tomli==2.2.1 # via pytest
2 changes: 2 additions & 0 deletions .config/requirements-test.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
coverage>=7.0.0
pytest-html
1 change: 1 addition & 0 deletions .config/requirements.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pytest>=7.4.2
91 changes: 49 additions & 42 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,84 +6,91 @@ repos:
- repo: meta
hooks:
- id: check-useless-excludes
- repo: https://github.com/pre-commit/mirrors-prettier
- repo: https://github.com/rbubley/mirrors-prettier
# keep it before yamllint
rev: v3.0.3
rev: v3.4.2
hooks:
- id: prettier
always_run: true
additional_dependencies:
- prettier
- prettier-plugin-toml
- prettier-plugin-sort-json
- repo: https://github.com/PyCQA/doc8.git
rev: v1.1.1
hooks:
- id: doc8
- repo: https://github.com/python/black
rev: 23.9.1
hooks:
- id: black
language_version: python3
- repo: https://github.com/pre-commit/pre-commit-hooks.git
rev: v4.5.0
rev: v5.0.0
hooks:
- id: check-added-large-files
- id: check-merge-conflict
- id: check-symlinks
- id: debug-statements
- id: detect-private-key
- id: end-of-file-fixer
- id: trailing-whitespace
- id: mixed-line-ending
- id: check-byte-order-marker
- id: fix-byte-order-marker
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: debug-statements
- repo: https://github.com/codespell-project/codespell
rev: v2.4.1
hooks:
- id: codespell
- repo: https://github.com/pappasam/toml-sort
rev: v0.24.2
hooks:
- id: toml-sort-fix
alias: toml

- repo: https://github.com/tox-dev/tox-ini-fmt
rev: 1.5.0
hooks:
- id: tox-ini-fmt
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.1.0"
rev: v0.9.4
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
args:
- --fix
- --exit-non-zero-on-fix
types_or: [python, pyi]
- id: ruff-format # must be after ruff
types_or: [python, pyi]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.6.0
rev: v1.14.1
hooks:
- id: mypy
# empty args needed in order to match mypy cli behavior
args: [--strict]
additional_dependencies:
- pytest
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.32.0
rev: v1.35.1
hooks:
- id: yamllint
files: \.(yaml|yml)$
types: [file, yaml]
entry: yamllint --strict
- repo: https://github.com/codespell-project/codespell.git
rev: v2.2.6
hooks:
- id: codespell
name: codespell
description: Checks for common misspellings in text files.
entry: codespell
language: python
types: [text]
args: []
require_serial: false
additional_dependencies: []
- repo: https://github.com/jazzband/pip-tools
rev: 7.3.0

- # keep at bottom as these are slower
repo: local
hooks:
- id: pip-compile
entry: pip-compile -q --no-annotate --output-file=requirements.txt pyproject.toml --extra test --strip-extras
- id: deps
name: Upgrade constraints files and requirements
files: ^(pyproject\.toml|.config/.*)$
always_run: true
language: python
files: ^(requirements\.txt|pyproject\.toml)$
alias: deps
language_version: "3.10" # minimal we support officially
entry: python3 -m uv pip compile -q --all-extras --output-file=.config/constraints.txt pyproject.toml --upgrade
pass_filenames: false
stages:
- manual
additional_dependencies:
- pip>=22.3.1
- uv>=0.5.21
- id: pip-compile
entry: pip-compile -q --no-annotate --output-file=requirements.txt pyproject.toml --extra test --strip-extras --upgrade
name: Check constraints files and requirements
files: ^(pyproject\.toml|\.config/.*)$
language: python
files: ^(requirements\.txt|pyproject\.toml)$
alias: up
stages: [manual]
language_version: "3.10" # minimal we support officially
entry: python3 -m uv pip compile -q --all-extras --output-file=.config/constraints.txt pyproject.toml
pass_filenames: false
additional_dependencies:
- pip>=22.3.1
- uv>=0.5.21
10 changes: 10 additions & 0 deletions .taplo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[formatting]
# cspell: disable-next-line
# compatibility between toml-sort-fix pre-commit hook and panekj.even-betterer-toml extension
align_comments = false
array_trailing_comma = false
compact_arrays = true
compact_entries = false
compact_inline_tables = true
inline_table_expand = false
reorder_keys = true
18 changes: 18 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"recommendations": [
"Tyriar.sort-lines",
"charliermarsh.ruff",
"esbenp.prettier-vscode",
"hbenl.vscode-test-explorer",
"ms-python.isort",
"ms-python.mypy-type-checker",
"ms-python.pylint",
"ms-python.python",
"ms-python.vscode-pylance",
"ryanluker.vscode-coverage-gutters",
"shardulm94.trailing-spaces",
"tamasfe.even-better-toml",
"timonwong.shellcheck",
"znck.grammarly"
]
}
45 changes: 45 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"[markdown]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[python]": {
"editor.codeActionsOnSave": {
"source.fixAll": "explicit",
"source.organizeImports": "explicit"
},
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.formatOnSave": true
},
"[toml]": {
"editor.defaultFormatter": "panekj.even-betterer-toml"
},
"editor.formatOnSave": true,
"evenBetterToml.formatter.alignComments": false,
"evenBetterToml.formatter.arrayTrailingComma": true,
"files.exclude": {
"*.egg-info": true,
".pytest_cache": true,
".tox": true,
"__pycache__": true,
"build": true
},
"git.ignoreLimitWarning": true,
"grammarly.config.documentDomain": "academic",
"grammarly.files.include": ["**/*.txt", "**/*.md"],
"mypy-type-checker.severity": {
"error": "Warning"
},
"python.experiments.optInto": ["pythonTestAdapter"],
"python.terminal.activateEnvironment": true,
"python.testing.pytestEnabled": true,
"python.testing.unittestEnabled": false,
"sonarlint.connectedMode.project": {
"connectionId": "ansible",
"projectKey": "ansible_ansible-lint"
},
"sortLines.filterBlankLines": true,
"yaml.completion": true,
"yaml.customTags": ["!encrypted/pkcs1-oaep scalar", "!vault scalar"],
"yaml.format.enable": false,
"yaml.validate": true
}
122 changes: 91 additions & 31 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
[build-system]
build-backend = "setuptools.build_meta"
requires = [
"setuptools >= 63.0.0", # required by pyproject+setuptools_scm integration
"setuptools_scm[toml] >= 7.0.5", # required for "no-local-version" scheme

"setuptools_scm[toml] >= 7.0.5" # required for "no-local-version" scheme
]
build-backend = "setuptools.build_meta"

[project]
# https://peps.python.org/pep-0621/#readme
requires-python = ">=3.10"
dynamic = ["version"]
name = "pytest-plus"
description = "PyTest Plus Plugin :: extends pytest functionality"
readme = "README.md"
authors = [{ "name" = "Sorin Sbarnea", "email" = "[email protected]" }]
maintainers = [
{ "name" = "Sorin Sbarnea", "email" = "[email protected]" }
]
license = { text = "MIT" }
authors = [{"email" = "[email protected]", "name" = "Sorin Sbarnea"}]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
Expand All @@ -38,52 +27,123 @@ classifiers = [
"Topic :: Software Development :: Quality Assurance",
"Topic :: Software Development :: Testing",
"Topic :: System :: Systems Administration",
"Topic :: Utilities",
"Topic :: Utilities"
]
description = "PyTest Plus Plugin :: extends pytest functionality"
dynamic = ["version", "dependencies", "optional-dependencies"]
keywords = ["testing", "pytest", "plugin"]
dependencies = ["pytest>=7.4.2"]

[project.urls]
homepage = "https://github.com/pytest-dev/pytest-plus"
repository = "https://github.com/pytest-dev/pytest-plus"
changelog = "https://github.com/pytest-dev/pytest-plus/releases"

[project.optional-dependencies]
test = ["coverage>=7.0.0", "pytest-html"]
license = {text = "MIT"}
maintainers = [
{"email" = "[email protected]", "name" = "Sorin Sbarnea"}
]
name = "pytest-plus"
readme = "README.md"
# https://peps.python.org/pep-0621/#readme
requires-python = ">=3.10"

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

[tool.coverage.run]
omit = ["test/*", "/private/var/folders/*", "/tmp/*"]
[project.urls]
changelog = "https://github.com/pytest-dev/pytest-plus/releases"
homepage = "https://github.com/pytest-dev/pytest-plus"
repository = "https://github.com/pytest-dev/pytest-plus"

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

[tool.coverage.run]
omit = ["test/*", "/private/var/folders/*", "/tmp/*"]

[tool.pytest.ini_options]
addopts = "-p no:flaky"

filterwarnings = [
"error",
"ignore:ast.(Str|Num|NameConstant) is deprecated and will be removed in Python 3.14:DeprecationWarning:_pytest.assertion.rewrite",
"ignore:Attribute s is deprecated and will be removed in Python 3.14:DeprecationWarning:_pytest.assertion.rewrite",
"ignore:Attribute s is deprecated and will be removed in Python 3.14:DeprecationWarning:_pytest.assertion.rewrite"
]

[tool.ruff]
cache-dir = "./.cache/.ruff"
fix = true
# Same as Black.
line-length = 88
preview = true
target-version = "py310"

[tool.ruff.lint]
ignore = [
"COM812", # conflicts with ISC001 on format
"CPY001", # missing-copyright-notice
"D203", # incompatible with D211
"D213", # incompatible with D212
"E501", # we use black
"ERA001", # auto-removal of commented out code affects development and vscode integration
"INP001", # "is part of an implicit namespace package", all false positives
"ISC001", # conflicts with COM812 on format
"PLW2901", # PLW2901: Redefined loop variable
"RET504", # Unnecessary variable assignment before `return` statement
# temporary disabled until we fix them:
"ANN",
"ARG002", # Unused method argument (currently in too many places)
"D102", # Missing docstring in public method (currently in too many places)
"FBT001",
"FBT003",
"PLR",
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
"PERF203",
"PD011", # We are not using pandas, any .values attributes are unrelated
"PLW0603", # global lock file in cache dir
# part of preview rules:
"B909", # raise-missing-from
"DOC201", # docstring-missing-returns
"DOC402", # docstring-missing-summary
"DOC501", # docstring-missing-exception
"FURB101",
"FURB103",
"FURB110",
"FURB113",
"FURB118",
"PLC0415",
"PLC2701",
"PLW1641",
"S404"
]
select = ["ALL"]
target-version = "py39"
# Same as Black.
line-length = 88

[tool.ruff.lint.pydocstyle]
convention = "google"

[tool.ruff.per-file-ignores]
"test/**/*.py" = ["S"]

[tool.setuptools.dynamic]
dependencies = {file = [".config/requirements.in"]}
optional-dependencies.test = {file = [".config/requirements-test.in"]}

[tool.setuptools_scm]
# To prevent accidental pick of mobile version tags such 'v6'
git_describe_command = [
"git",
"describe",
"--dirty",
"--long",
"--tags",
"--match",
"v*.*"
]
local_scheme = "no-local-version"
tag_regex = "^(?P<prefix>v)?(?P<version>\\d+[^\\+]*)(?P<suffix>.*)?$"
write_to = "src/pytest_plus/_version.py"

[tool.tomlsort]
in_place = true
sort_inline_tables = true
sort_table_keys = true

[tool.uv.pip]
annotation-style = "line"
custom-compile-command = "tox run -e deps"
no-emit-package = ["pip", "resolvelib", "ruamel-yaml-clib", "uv"]
Loading

0 comments on commit d12ae43

Please sign in to comment.