Skip to content

Commit

Permalink
Linters updates (#417)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea authored Feb 1, 2025
1 parent 25143c7 commit 6b51c44
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 80 deletions.
19 changes: 9 additions & 10 deletions .config/constraints.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# This file was autogenerated by uv via the following command:
# tox run deps
# tox run -e deps
ansible-compat==25.1.1 # via pytest-ansible
astroid==3.3.8 # via pylint
attrs==25.1.0 # via jsonschema, referencing
babel==2.16.0 # via mkdocs-material
beautifulsoup4==4.12.3 # via linkchecker, mkdocs-htmlproofer-plugin
black==25.1.0 # via tox-ansible (pyproject.toml)
cachetools==5.5.1 # via tox
cairocffi==1.7.1 # via cairosvg
cairosvg==2.7.1 # via mkdocs-ansible
Expand All @@ -14,8 +13,8 @@ cffi==1.17.1 # via cairocffi, cryptography
cfgv==3.4.0 # via pre-commit
chardet==5.2.0 # via tox
charset-normalizer==3.4.1 # via requests
click==8.1.8 # via black, mkdocs, mkdocstrings, pydoclint
colorama==0.4.6 # via griffe, mkdocs-material, tox
click==8.1.8 # via mkdocs, mkdocstrings, pydoclint
colorama==0.4.6 # via click, griffe, mkdocs, mkdocs-material, pylint, pytest, tox
coverage==7.6.10 # via tox-ansible (pyproject.toml)
cryptography==44.0.0 # via ansible-core
csscompressor==0.9.5 # via mkdocs-minify-plugin
Expand All @@ -25,7 +24,6 @@ dill==0.3.9 # via pylint
distlib==0.3.9 # via virtualenv
dnspython==2.7.0 # via linkchecker
docstring-parser-fork==0.0.12 # via pydoclint
exceptiongroup==1.2.2 # via pytest
execnet==2.1.1 # via pytest-xdist
filelock==3.17.0 # via tox, virtualenv
ghp-import==2.1.0 # via mkdocs
Expand Down Expand Up @@ -61,13 +59,13 @@ mkdocs-monorepo-plugin==1.1.0 # via mkdocs-ansible
mkdocstrings==0.27.0 # via mkdocs-ansible, mkdocstrings-python
mkdocstrings-python==1.13.0 # via mkdocs-ansible
mypy==1.14.1 # via tox-ansible (pyproject.toml)
mypy-extensions==1.0.0 # via black, mypy
mypy-extensions==1.0.0 # via mypy
nodeenv==1.9.1 # via pre-commit
packaging==24.2 # via ansible-compat, ansible-core, black, mkdocs, mkdocs-macros-plugin, pyproject-api, pytest, pytest-ansible, tox
packaging==24.2 # via ansible-compat, ansible-core, mkdocs, mkdocs-macros-plugin, pyproject-api, pytest, pytest-ansible, tox
paginate==0.5.7 # via mkdocs-material
pathspec==0.12.1 # via black, mkdocs, mkdocs-macros-plugin
pathspec==0.12.1 # via mkdocs, mkdocs-macros-plugin
pillow==11.1.0 # via cairosvg, mkdocs-ansible
platformdirs==4.3.6 # via black, mkdocs-get-deps, mkdocstrings, pylint, tox, virtualenv
platformdirs==4.3.6 # via mkdocs-get-deps, mkdocstrings, pylint, tox, virtualenv
pluggy==1.5.0 # via pytest, tox
pre-commit==4.1.0 # via tox-ansible (pyproject.toml)
pycparser==2.22 # via cffi
Expand Down Expand Up @@ -96,7 +94,6 @@ termcolor==2.5.0 # via mkdocs-macros-plugin
text-unidecode==1.3 # via python-slugify
tinycss2==1.4.0 # via cairosvg, cssselect2
toml-sort==0.24.2 # via tox-ansible (pyproject.toml)
tomli==2.2.1 # via black, coverage, mypy, pydoclint, pylint, pyproject-api, pytest, tox
tomlkit==0.13.2 # via pylint, toml-sort
tox==4.24.1 # via tox-ansible (pyproject.toml)
types-pyyaml==6.0.12.20241230 # via tox-ansible (pyproject.toml)
Expand All @@ -107,5 +104,7 @@ webencodings==0.5.1 # via cssselect2, tinycss2

# The following packages were excluded from the output:
# ansible-core
# exceptiongroup
# resolvelib
# tomli
# typing-extensions
1 change: 0 additions & 1 deletion .config/requirements-test.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
ansible-core
black
coverage[toml]
mypy
pre-commit
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,4 @@ cython_debug/
/src/*/_version.py

.DS_Store
_readthedocs
97 changes: 43 additions & 54 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,24 @@ ci:
autofix_commit_msg: "chore: auto fixes from pre-commit.com hooks"

skip:
# https://github.com/pre-commit-ci/issues/issues/55
- lock
- deps
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
- repo: https://github.com/rbubley/mirrors-prettier
rev: v3.4.2
hooks:
- id: prettier
always_run: true
additional_dependencies:
- prettier
- prettier-plugin-sort-json
- repo: https://github.com/streetsidesoftware/cspell-cli
rev: v8.17.1
hooks:
- id: cspell
name: Spell check with cspell
- repo: https://github.com/pre-commit/pre-commit-hooks.git
rev: v5.0.0
hooks:
- id: check-added-large-files
Expand All @@ -18,43 +33,26 @@ repos:
- id: detect-private-key
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/asottile/add-trailing-comma.git
rev: v3.1.0
hooks:
- id: add-trailing-comma

- repo: https://github.com/Lucas-C/pre-commit-hooks.git
rev: v1.5.5
hooks:
- id: remove-tabs
exclude: >
(?x)^(
.config/pydoclint-baseline.txt
)$
- repo: https://github.com/pycontribs/mirrors-prettier
rev: v3.4.2
hooks:
- id: prettier
always_run: true
additional_dependencies:
- prettier
- prettier-plugin-toml
- prettier-plugin-sort-json
- id: mixed-line-ending
- id: fix-byte-order-marker
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: debug-statements
language_version: python3

- 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.9.3
rev: v0.9.4
hooks:
- id: ruff
args:
Expand All @@ -64,16 +62,14 @@ repos:
- id: ruff-format # must be after ruff
types_or: [python, pyi]

- repo: https://github.com/psf/black # must be after ruff
rev: 25.1.0
hooks:
- id: black

- repo: https://github.com/streetsidesoftware/cspell-cli
rev: v8.17.1
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.14.1
hooks:
- id: cspell
name: Spell check with cspell
- id: mypy
additional_dependencies:
- pytest
- tox
- types-PyYAML

- repo: https://github.com/jsh9/pydoclint
rev: "0.6.0"
Expand All @@ -92,35 +88,28 @@ repos:
- tox
- pyyaml

- repo: https://github.com/pre-commit/mirrors-mypy.git
rev: v1.14.1
hooks:
- id: mypy
additional_dependencies:
- pytest
- tox
- types-PyYAML
# Override default pre-commit '--ignore-missing-imports'
args: [--strict]

# Keep last due to being considerably slower than the others:
- repo: local
hooks:
- id: up
- id: deps
# To run it execute: `pre-commit run pip-compile-upgrade --hook-stage manual`
name: Upgrade constraints files and requirements
files: ^(pyproject\.toml|requirements\.txt)$
files: ^(pyproject\.toml|\.config/.*)$
always_run: true
language: python
entry: python3 -m uv pip compile --python-version=3.10 -q --all-extras --output-file=.config/constraints.txt pyproject.toml --upgrade
language_version: "3.10" # minimal we support officially https://github.com/astral-sh/uv/issues/3883
entry: python3 -m uv pip compile -q --all-extras --universal --output-file=.config/constraints.txt pyproject.toml --upgrade
pass_filenames: false
stages:
- manual
additional_dependencies:
- uv>=0.4.3
- id: deps
- uv>=0.5.25
- id: lock
name: Check constraints files and requirements
files: ^(pyproject\.toml|requirements\.txt)$
files: ^(pyproject\.toml|\.config/.*)$
language: python
entry: python3 -m uv pip compile --python-version=3.10 -q --all-extras --output-file=.config/constraints.txt pyproject.toml
language_version: "3.10" # minimal we support officially https://github.com/astral-sh/uv/issues/3883
entry: python3 -m uv pip compile -q --all-extras --universal --output-file=.config/constraints.txt pyproject.toml
pass_filenames: false
additional_dependencies:
- uv>=0.4.3
- uv>=0.5.25
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ build:
python: "3.11"
commands:
- pip install --user tox
- python3 -m tox -e docs -- --strict --site-dir=_readthedocs/html/
- python3 -m tox -e docs
python:
install:
- method: pip
Expand Down
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
4 changes: 2 additions & 2 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
"esbenp.prettier-vscode",
"gruntfuggly.triggertaskonsave",
"markis.code-coverage",
"ms-python.black-formatter",
"ms-python.debugpy",
"ms-python.mypy-type-checker",
"ms-python.pylint",
"ms-python.python",
"sonarsource.sonarlint-vscode",
"streetsidesoftware.code-spell-checker"
"streetsidesoftware.code-spell-checker",
"tamasfe.even-better-toml"
]
}
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"source.fixAll": "explicit",
"source.organizeImports": "explicit"
},
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.formatOnSave": true
},
"flake8.importStrategy": "fromEnvironment",
Expand Down
17 changes: 12 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ documentation = "https://ansible.readthedocs.io/projects/tox-ansible/"
homepage = "https://github.com/ansible/tox-ansible"
repository = "https://github.com/ansible/tox-ansible"

[tool.black]
line-length = 100

[tool.coverage.report]
exclude_also = ["if TYPE_CHECKING:", "pragma: no cover"]
fail_under = 81
Expand Down Expand Up @@ -375,6 +372,7 @@ git_describe_command = [
"v*.*"
]
local_scheme = "no-local-version"
tag_regex = "^(?P<prefix>v)?(?P<version>\\d+[^\\+]*)(?P<suffix>.*)?$"
write_to = "src/tox_ansible/_version.py"

[tool.tomlsort]
Expand All @@ -384,5 +382,14 @@ sort_table_keys = true

[tool.uv.pip]
annotation-style = "line"
custom-compile-command = "tox run deps"
no-emit-package = ["ansible-core", "pip", "resolvelib", "typing_extensions", "uv"]
custom-compile-command = "tox run -e deps"
no-emit-package = [
"ansible-core",
"exceptiongroup",
"pip",
"resolvelib",
"ruamel-yaml-clib",
"tomli",
"typing_extensions",
"uv"
]
20 changes: 14 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tox]
requires =
tox>=4.11.3
tox-uv
tox>=4.23.2
tox-uv>=1.20.2
env_list =
py
deps
Expand All @@ -28,6 +28,7 @@ pass_env =
USER
set_env =
!milestone: PIP_CONSTRAINT = {toxinidir}/.config/constraints.txt
!milestone: UV_CONSTRAINT = {toxinidir}/.config/constraints.txt
COVERAGE_COMBINED = {envdir}/.coverage
COVERAGE_FILE = {env:COVERAGE_FILE:{envdir}/.coverage.{envname}}
COVERAGE_PROCESS_START = {toxinidir}/pyproject.toml
Expand Down Expand Up @@ -56,10 +57,13 @@ deps =
extras =
set_env =
PIP_CONSTRAINT = /dev/null
UV_CONSTRAINT = /dev/null
commands_pre =
commands =
-pre-commit run --all-files --show-diff-on-failure --hook-stage manual up
-pre-commit autoupdate
pre-commit run --all-files --show-diff-on-failure --hook-stage manual deps
pre-commit run --all-files --show-diff-on-failure lock
pre-commit autoupdate
tox -e lint
git diff --exit-code
env_dir = {toxworkdir}/lint

Expand All @@ -70,19 +74,22 @@ skip_install = false
extras =
docs
set_env =
DYLD_FALLBACK_LIBRARY_PATH = /opt/homebrew/lib:{env:LD_LIBRARY_PATH}
NO_COLOR = 1
TERM = dump
commands =
mkdocs build {posargs:}
mkdocs build {posargs:--strict --site-dir=_readthedocs/html/}

[testenv:lint]
description = Enforce quality standards under {basepython}
skip_install = true
deps =
pre-commit
pre-commit-uv
pre-commit-uv>=4.1.4
uv>=0.5.25
set_env =
PIP_CONSTRAINT = /dev/null
UV_CONSTRAINT = /dev/null
commands =
pre-commit run --show-diff-on-failure --all-files

Expand All @@ -94,6 +101,7 @@ deps =
set_env =
{[testenv]set_env}
PIP_CONSTRAINT = /dev/null
UV_CONSTRAINT = /dev/null

[testenv:pkg]
description =
Expand Down

0 comments on commit 6b51c44

Please sign in to comment.