diff --git a/.config/constraints.txt b/.config/constraints.txt index 88ad135..368cde2 100644 --- a/.config/constraints.txt +++ b/.config/constraints.txt @@ -1,74 +1,73 @@ -# -# This file is autogenerated by pip-compile with Python 3.10 -# by the following command: -# -# pip-compile --all-extras --no-annotate --output-file=.config/constraints.txt --strip-extras --unsafe-package=ruamel-yaml-clib pyproject.toml -# -babel==2.17.0 -beautifulsoup4==4.13.3 -cairocffi==1.7.1 -cairosvg==2.7.1 -certifi==2025.1.31 -cffi==1.17.1 -charset-normalizer==3.4.1 -click==8.1.8 -colorama==0.4.6 -coverage==7.6.12 -csscompressor==0.9.5 -cssselect2==0.7.0 -defusedxml==0.7.1 -dnspython==2.7.0 -exceptiongroup==1.2.2 -ghp-import==2.1.0 -griffe==1.5.7 -hjson==3.1.0 -htmlmin2==0.1.13 -idna==3.10 -iniconfig==2.0.0 -jinja2==3.1.5 -jsmin==3.0.1 -linkchecker==10.5.0 -markdown==3.7 -markdown-exec==1.10.0 -markdown-include==0.8.1 -markupsafe==3.0.2 -mergedeep==1.3.4 -mkdocs==1.6.1 -mkdocs-autorefs==1.3.1 -mkdocs-gen-files==0.5.0 -mkdocs-get-deps==0.2.0 -mkdocs-htmlproofer-plugin==1.3.0 -mkdocs-macros-plugin==1.3.7 -mkdocs-material==9.6.4 -mkdocs-material-extensions==1.3.1 -mkdocs-minify-plugin==0.8.0 -mkdocs-monorepo-plugin==1.1.0 -mkdocstrings==0.28.1 -mkdocstrings-python==1.15.0 -packaging==24.2 -paginate==0.5.7 -pathspec==0.12.1 -pillow==11.1.0 -platformdirs==4.3.6 -pluggy==1.5.0 -pycparser==2.22 -pygments==2.19.1 -pymdown-extensions==10.14.3 -pytest==8.3.4 -python-dateutil==2.9.0.post0 -python-slugify==8.0.4 -pyyaml==6.0.2 -pyyaml-env-tag==0.1 -regex==2024.11.6 -requests==2.32.3 -six==1.17.0 -soupsieve==2.6 -super-collections==0.5.3 -termcolor==2.5.0 -text-unidecode==1.3 -tinycss2==1.4.0 -tomli==2.2.1 -typing-extensions==4.12.2 -urllib3==2.3.0 -watchdog==6.0.0 -webencodings==0.5.1 +# This file was autogenerated by uv via the following command: +# tox run -e deps +babel==2.17.0 # via mkdocs-material +beautifulsoup4==4.13.3 # via linkchecker, mkdocs-htmlproofer-plugin +cairocffi==1.7.1 # via cairosvg +cairosvg==2.7.1 # via mkdocs-ansible (pyproject.toml) +certifi==2025.1.31 # via requests +cffi==1.17.1 # via cairocffi +charset-normalizer==3.4.1 # via requests +click==8.1.8 # via mkdocs +colorama==0.4.6 # via griffe, mkdocs-material +coverage==7.6.12 # via mkdocs-ansible (pyproject.toml) +csscompressor==0.9.5 # via mkdocs-minify-plugin +cssselect2==0.7.0 # via cairosvg +defusedxml==0.7.1 # via cairosvg +dnspython==2.7.0 # via linkchecker +exceptiongroup==1.2.2 # via pytest +execnet==2.1.1 # via pytest-xdist +ghp-import==2.1.0 # via mkdocs +griffe==1.5.7 # via mkdocstrings-python +hjson==3.1.0 # via mkdocs-macros-plugin, super-collections +htmlmin2==0.1.13 # via mkdocs-minify-plugin +idna==3.10 # via requests +iniconfig==2.0.0 # via pytest +jinja2==3.1.5 # via mkdocs, mkdocs-macros-plugin, mkdocs-material, mkdocstrings +jsmin==3.0.1 # via mkdocs-minify-plugin +linkchecker==10.5.0 # via mkdocs-ansible (pyproject.toml) +markdown==3.7 # via markdown-include, mkdocs, mkdocs-autorefs, mkdocs-htmlproofer-plugin, mkdocs-material, mkdocstrings, pymdown-extensions +markdown-exec==1.10.0 # via mkdocs-ansible (pyproject.toml) +markdown-include==0.8.1 # via mkdocs-ansible (pyproject.toml) +markupsafe==3.0.2 # via jinja2, mkdocs, mkdocs-autorefs, mkdocstrings +mergedeep==1.3.4 # via mkdocs, mkdocs-get-deps +mkdocs==1.6.1 # via mkdocs-autorefs, mkdocs-gen-files, mkdocs-htmlproofer-plugin, mkdocs-macros-plugin, mkdocs-material, mkdocs-minify-plugin, mkdocs-monorepo-plugin, mkdocstrings, mkdocs-ansible (pyproject.toml) +mkdocs-autorefs==1.3.1 # via mkdocstrings, mkdocstrings-python +mkdocs-gen-files==0.5.0 # via mkdocs-ansible (pyproject.toml) +mkdocs-get-deps==0.2.0 # via mkdocs, mkdocstrings +mkdocs-htmlproofer-plugin==1.3.0 # via mkdocs-ansible (pyproject.toml) +mkdocs-macros-plugin==1.3.7 # via mkdocs-ansible (pyproject.toml) +mkdocs-material==9.6.4 # via mkdocs-ansible (pyproject.toml) +mkdocs-material-extensions==1.3.1 # via mkdocs-material, mkdocs-ansible (pyproject.toml) +mkdocs-minify-plugin==0.8.0 # via mkdocs-ansible (pyproject.toml) +mkdocs-monorepo-plugin==1.1.0 # via mkdocs-ansible (pyproject.toml) +mkdocstrings==0.28.1 # via mkdocstrings-python, mkdocs-ansible (pyproject.toml) +mkdocstrings-python==1.16.0 # via mkdocs-ansible (pyproject.toml) +packaging==24.2 # via mkdocs, mkdocs-macros-plugin, pytest +paginate==0.5.7 # via mkdocs-material +pathspec==0.12.1 # via mkdocs, mkdocs-macros-plugin +pillow==11.1.0 # via cairosvg, mkdocs-ansible (pyproject.toml) +platformdirs==4.3.6 # via mkdocs-get-deps +pluggy==1.5.0 # via pytest +pycparser==2.22 # via cffi +pygments==2.19.1 # via mkdocs-material +pymdown-extensions==10.14.3 # via markdown-exec, mkdocs-material, mkdocstrings, mkdocs-ansible (pyproject.toml) +pytest==8.3.4 # via pytest-plus, pytest-xdist, mkdocs-ansible (pyproject.toml) +pytest-plus==0.8.1 # via mkdocs-ansible (pyproject.toml) +pytest-xdist==3.6.1 # via mkdocs-ansible (pyproject.toml) +python-dateutil==2.9.0.post0 # via ghp-import, mkdocs-macros-plugin +python-slugify==8.0.4 # via mkdocs-monorepo-plugin +pyyaml==6.0.2 # via mkdocs, mkdocs-get-deps, mkdocs-macros-plugin, pymdown-extensions, pyyaml-env-tag +pyyaml-env-tag==0.1 # via mkdocs +regex==2024.11.6 # via mkdocs-material +requests==2.32.3 # via linkchecker, mkdocs-htmlproofer-plugin, mkdocs-material +six==1.17.0 # via python-dateutil +soupsieve==2.6 # via beautifulsoup4 +super-collections==0.5.3 # via mkdocs-macros-plugin +termcolor==2.5.0 # via mkdocs-macros-plugin +text-unidecode==1.3 # via python-slugify +tinycss2==1.4.0 # via cairosvg, cssselect2 +tomli==2.2.1 # via pytest +typing-extensions==4.12.2 # via beautifulsoup4, mkdocstrings-python +urllib3==2.3.0 # via requests +watchdog==6.0.0 # via mkdocs +webencodings==0.5.1 # via cssselect2, tinycss2 diff --git a/.config/dictionary.txt b/.config/dictionary.txt index 4fc8163..99dbf4b 100644 --- a/.config/dictionary.txt +++ b/.config/dictionary.txt @@ -4,6 +4,7 @@ PYTHONPYCACHEPREFIX REQPASS Roboto TOXENV +addopts ansiblelint arithmatex autobuild @@ -35,6 +36,7 @@ mkdocstrings mypy notest outdir +posargs pycontribs pylint pymdown @@ -44,9 +46,12 @@ pyproject pyupgrade ruamel setuptools +showlocals smartsymbols sourcegraph squidfunk superfences tasklist +testpaths tomli +tomlsort diff --git a/.config/requirements-lock.txt b/.config/requirements-lock.txt new file mode 100644 index 0000000..6d2dce7 --- /dev/null +++ b/.config/requirements-lock.txt @@ -0,0 +1,64 @@ +# This file was autogenerated by uv via the following command: +# tox run -e deps +babel==2.17.0 # via mkdocs-material +beautifulsoup4==4.13.3 # via linkchecker, mkdocs-htmlproofer-plugin +cairocffi==1.7.1 # via cairosvg +cairosvg==2.7.1 # via mkdocs-ansible (pyproject.toml) +certifi==2025.1.31 # via requests +cffi==1.17.1 # via cairocffi +charset-normalizer==3.4.1 # via requests +click==8.1.8 # via mkdocs +colorama==0.4.6 # via griffe, mkdocs-material +csscompressor==0.9.5 # via mkdocs-minify-plugin +cssselect2==0.7.0 # via cairosvg +defusedxml==0.7.1 # via cairosvg +dnspython==2.7.0 # via linkchecker +ghp-import==2.1.0 # via mkdocs +griffe==1.5.7 # via mkdocstrings-python +hjson==3.1.0 # via mkdocs-macros-plugin, super-collections +htmlmin2==0.1.13 # via mkdocs-minify-plugin +idna==3.10 # via requests +jinja2==3.1.5 # via mkdocs, mkdocs-macros-plugin, mkdocs-material, mkdocstrings +jsmin==3.0.1 # via mkdocs-minify-plugin +linkchecker==10.5.0 # via mkdocs-ansible (pyproject.toml) +markdown==3.7 # via markdown-include, mkdocs, mkdocs-autorefs, mkdocs-htmlproofer-plugin, mkdocs-material, mkdocstrings, pymdown-extensions +markdown-exec==1.10.0 # via mkdocs-ansible (pyproject.toml) +markdown-include==0.8.1 # via mkdocs-ansible (pyproject.toml) +markupsafe==3.0.2 # via jinja2, mkdocs, mkdocs-autorefs, mkdocstrings +mergedeep==1.3.4 # via mkdocs, mkdocs-get-deps +mkdocs==1.6.1 # via mkdocs-autorefs, mkdocs-gen-files, mkdocs-htmlproofer-plugin, mkdocs-macros-plugin, mkdocs-material, mkdocs-minify-plugin, mkdocs-monorepo-plugin, mkdocstrings, mkdocs-ansible (pyproject.toml) +mkdocs-autorefs==1.3.1 # via mkdocstrings, mkdocstrings-python +mkdocs-gen-files==0.5.0 # via mkdocs-ansible (pyproject.toml) +mkdocs-get-deps==0.2.0 # via mkdocs, mkdocstrings +mkdocs-htmlproofer-plugin==1.3.0 # via mkdocs-ansible (pyproject.toml) +mkdocs-macros-plugin==1.3.7 # via mkdocs-ansible (pyproject.toml) +mkdocs-material==9.6.4 # via mkdocs-ansible (pyproject.toml) +mkdocs-material-extensions==1.3.1 # via mkdocs-material, mkdocs-ansible (pyproject.toml) +mkdocs-minify-plugin==0.8.0 # via mkdocs-ansible (pyproject.toml) +mkdocs-monorepo-plugin==1.1.0 # via mkdocs-ansible (pyproject.toml) +mkdocstrings==0.28.1 # via mkdocstrings-python, mkdocs-ansible (pyproject.toml) +mkdocstrings-python==1.16.0 # via mkdocs-ansible (pyproject.toml) +packaging==24.2 # via mkdocs, mkdocs-macros-plugin +paginate==0.5.7 # via mkdocs-material +pathspec==0.12.1 # via mkdocs, mkdocs-macros-plugin +pillow==11.1.0 # via cairosvg, mkdocs-ansible (pyproject.toml) +platformdirs==4.3.6 # via mkdocs-get-deps +pycparser==2.22 # via cffi +pygments==2.19.1 # via mkdocs-material +pymdown-extensions==10.14.3 # via markdown-exec, mkdocs-material, mkdocstrings, mkdocs-ansible (pyproject.toml) +python-dateutil==2.9.0.post0 # via ghp-import, mkdocs-macros-plugin +python-slugify==8.0.4 # via mkdocs-monorepo-plugin +pyyaml==6.0.2 # via mkdocs, mkdocs-get-deps, mkdocs-macros-plugin, pymdown-extensions, pyyaml-env-tag +pyyaml-env-tag==0.1 # via mkdocs +regex==2024.11.6 # via mkdocs-material +requests==2.32.3 # via linkchecker, mkdocs-htmlproofer-plugin, mkdocs-material +six==1.17.0 # via python-dateutil +soupsieve==2.6 # via beautifulsoup4 +super-collections==0.5.3 # via mkdocs-macros-plugin +termcolor==2.5.0 # via mkdocs-macros-plugin +text-unidecode==1.3 # via python-slugify +tinycss2==1.4.0 # via cairosvg, cssselect2 +typing-extensions==4.12.2 # via beautifulsoup4, mkdocstrings-python +urllib3==2.3.0 # via requests +watchdog==6.0.0 # via mkdocs +webencodings==0.5.1 # via cssselect2, tinycss2 diff --git a/.config/requirements-test.in b/.config/requirements-test.in index 7093b61..eb4a25d 100644 --- a/.config/requirements-test.in +++ b/.config/requirements-test.in @@ -1,2 +1,4 @@ coverage pytest +pytest-plus +pytest-xdist diff --git a/.config/requirements.in b/.config/requirements.in index 9ab279a..233b96b 100644 --- a/.config/requirements.in +++ b/.config/requirements.in @@ -1,16 +1,16 @@ -cairosvg>=2.6.0 -linkchecker>=10.3.0 -markdown-exec>=1.3.0 +cairosvg>=2.7.1 +linkchecker>=10.5.0 +markdown-exec>=1.10.0 markdown-include>=0.8.1 -mkdocs-gen-files>=0.4.0 -mkdocs-htmlproofer-plugin>=0.10.2 -mkdocs-macros-plugin -mkdocs-material-extensions>=1.1.1 -mkdocs-material>=9.0.13 -mkdocs-minify-plugin>=0.6.2 -mkdocs-monorepo-plugin>=1.0.4 -mkdocs>=1.4.2 -mkdocstrings-python>=0.8.3 -mkdocstrings>=0.21.2 -pillow>=9.4.0 -pymdown-extensions>=9.9.2 +mkdocs-gen-files>=0.5.0 +mkdocs-htmlproofer-plugin>=1.3.0 +mkdocs-macros-plugin>=1.3.7 +mkdocs-material-extensions>=1.3.1 +mkdocs-material>=9.6.4 +mkdocs-minify-plugin>=0.8.0 +mkdocs-monorepo-plugin>=1.1.0 +mkdocs>=1.6.1 +mkdocstrings-python>=0.16.0 +mkdocstrings>=0.28.1 +pillow>=11.1.0 +pymdown-extensions>=10.14.3 diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml index dc16990..c7e7d6e 100644 --- a/.github/workflows/tox.yml +++ b/.github/workflows/tox.yml @@ -18,7 +18,7 @@ jobs: tox: uses: ansible/team-devtools/.github/workflows/tox.yml@main with: - jobs_producing_coverage: 7 + jobs_producing_coverage: 6 other_names: | docs lint diff --git a/.gitignore b/.gitignore index 9a5e7f3..bb35ad0 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ site src/mkdocs_ansible/_version.py .cache _readthedocs +*.lcov diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 530ed27..a9f0883 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,10 +3,7 @@ ci: # format compatible with commitlint autoupdate_commit_msg: "chore: pre-commit autoupdate" autoupdate_schedule: monthly - autofix_commit_msg: | - chore: auto fixes from pre-commit.com hooks - - for more information, see https://pre-commit.ci + autofix_commit_msg: "chore: auto fixes from pre-commit.com hooks" skip: # https://github.com/pre-commit-ci/issues/issues/55 - pip-compile @@ -15,16 +12,15 @@ 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: v4.0.0-alpha.8 + rev: v3.5.1 hooks: - id: prettier always_run: true additional_dependencies: - - prettier - - prettier-plugin-toml - - prettier-plugin-sort-json + - prettier@3.2.4 + - prettier-plugin-sort-json@3.1.0 - repo: https://github.com/streetsidesoftware/cspell-cli rev: v8.17.2 hooks: @@ -39,6 +35,11 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks.git 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 @@ -64,26 +65,35 @@ repos: files: \.(yaml|yml)$ types: [file, yaml] entry: yamllint --strict - - repo: https://github.com/PyCQA/isort - rev: 6.0.0 - hooks: - - id: isort - args: - # https://github.com/pre-commit/mirrors-isort/issues/9#issuecomment-624404082 - - --filter-files - - repo: https://github.com/psf/black - rev: 25.1.0 - hooks: - - id: black - language_version: python3 - repo: https://github.com/asottile/pyupgrade # keep it after flake8 rev: v3.19.1 hooks: - id: pyupgrade args: ["--py39-plus"] + - 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.6 + hooks: + - id: ruff + 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.14.1 + rev: v1.15.0 hooks: - id: mypy # empty args needed in order to match mypy cli behavior @@ -96,29 +106,27 @@ repos: args: - --output-format=colorized additional_dependencies: ["mkdocs-macros-plugin"] - - repo: https://github.com/jazzband/pip-tools - rev: 7.4.1 + - # keep at bottom as these are slower + repo: local hooks: - id: pip-compile - name: lock - alias: lock - always_run: true - entry: pip-compile --upgrade -q --no-annotate --output-file=.config/constraints.txt pyproject.toml --all-extras --strip-extras --unsafe-package ruamel-yaml-clib - files: ^.config\/requirements.*$ + name: Check constraints files and requirements + files: ^(pyproject\.toml|\.config/.*)$ language: python 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 - stages: [manual] additional_dependencies: - - pip>=22.3.1 - - id: pip-compile - name: deps - alias: deps + - uv>=0.5.21 + - id: lock + name: Update requirements-lock.txt + alias: lock always_run: true - entry: pip-compile -q --no-annotate --output-file=.config/constraints.txt pyproject.toml --all-extras --strip-extras --unsafe-package ruamel-yaml-clib - files: ^.config\/requirements.*$ + entry: python3 -m uv pip compile -q --upgrade --output-file=.config/requirements-lock.txt pyproject.toml --strip-extras + files: ^(pyproject\.toml|\.config/.*)$ language: python language_version: "3.10" # minimal we support officially pass_filenames: false + stages: [manual] additional_dependencies: - - pip>=22.3.1 + - uv>=0.5.21 diff --git a/.taplo.toml b/.taplo.toml new file mode 100644 index 0000000..0709f9a --- /dev/null +++ b/.taplo.toml @@ -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 diff --git a/.yamllint b/.yamllint index 2772c3c..e651aae 100644 --- a/.yamllint +++ b/.yamllint @@ -3,8 +3,7 @@ rules: comments: # prettier compatibility min-spaces-from-content: 1 - document-start: - present: true + document-start: disable indentation: level: error indent-sequences: consistent diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..0ba9516 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,6 @@ +codecov: + require_ci_to_pass: true +comment: false +coverage: + status: + patch: true # we want github annotations diff --git a/cspell.config.yaml b/cspell.config.yaml index c02988e..15fe57f 100644 --- a/cspell.config.yaml +++ b/cspell.config.yaml @@ -9,10 +9,11 @@ dictionaries: - bash - words - python +enabled: true ignorePaths: - cspell.config.yaml # The requirements file - - .config/constraints.txt + - .config/*.txt # Test fixtures generated from outside - test/**/*.result - src/ansiblelint/schemas/*.json diff --git a/pyproject.toml b/pyproject.toml index cb40447..6d23d14 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,20 +1,12 @@ [build-system] +build-backend = "setuptools.build_meta" requires = [ - "setuptools >= 65.3.0", # required by pyproject+setuptools_scm integration - "setuptools_scm[toml] >= 7.0.5", # required for "no-local-version" scheme - + "setuptools >= 65.3.0", # required by pyproject+setuptools_scm integration and editable installs + "setuptools_scm[toml] >= 7.0.5" # required for "no-local-version" scheme ] -build-backend = "setuptools.build_meta" [project] -requires-python = ">=3.10" -dynamic = ["version", "dependencies", "optional-dependencies"] -name = "mkdocs-ansible" -description = "Ansible MkDocs Theme based on mkdocs-material" -readme = "docs/README.md" -authors = [{ "name" = "Ansible by Red Hat", "email" = "info@ansible.com" }] -maintainers = [{ "name" = "Ansible by Red Hat", "email" = "info@ansible.com" }] -license = { text = "MIT" } +authors = [{"email" = "info@ansible.com", "name" = "Ansible by Red Hat"}] classifiers = [ "Development Status :: 5 - Production/Stable", "Environment :: Web Environment", @@ -28,39 +20,61 @@ classifiers = [ 'Programming Language :: Python :: 3.13', "Topic :: Documentation", "Topic :: Software Development :: Documentation", - "Topic :: Text Processing :: Markup :: HTML", + "Topic :: Text Processing :: Markup :: HTML" ] +description = "Ansible MkDocs Theme based on mkdocs-material" +dynamic = ["version", "dependencies", "optional-dependencies"] keywords = ["ansible", "mkdocs", "theme"] +license = {text = "MIT"} +maintainers = [{"email" = "info@ansible.com", "name" = "Ansible by Red Hat"}] +name = "mkdocs-ansible" +readme = "docs/README.md" +requires-python = ">=3.10" + +[project.entry-points."mkdocs.themes"] +ansible = "mkdocs_ansible" [project.urls] -homepage = "https://github.com/ansible/mkdocs-ansible" +changelog = "https://github.com/ansible/mkdocs-ansible/releases" documentation = "https://ansible.readthedocs.io/projects/mkdocs-ansible/" +homepage = "https://github.com/ansible/mkdocs-ansible" repository = "https://github.com/ansible/mkdocs-ansible" -changelog = "https://github.com/ansible/mkdocs-ansible/releases" +[tool.codespell] +# indention is a typo in ruamel.yaml's API +ignore-words-list = "indention" +skip = ".tox,.mypy_cache,build,.git,.eggs,pip-wheel-metadata" -[project.entry-points."mkdocs.themes"] -ansible = "mkdocs_ansible" +# Keep this default because xml/report do not know to use load it from config file: +# data_file = ".coverage" +[tool.coverage.paths] +source = ["src", "test", ".tox/*/site-packages"] [tool.coverage.report] -exclude_lines = ["pragma: no cover", "if TYPE_CHECKING:"] -omit = ["test/*", "src/mkdocs_ansible/_version.py"] +exclude_also = ["pragma: no cover", "if TYPE_CHECKING:"] # Increase it just so it would pass on any single-python run fail_under = 82 -skip_covered = true -skip_empty = true # During development we might remove code (files) with coverage data, and we dont want to fail: ignore_errors = true +omit = ["test/*", "src/mkdocs_ansible/_version.py"] show_missing = true +skip_covered = true +skip_empty = true [tool.coverage.run] +# Do not use branch until bug is fixes: +# https://github.com/nedbat/coveragepy/issues/605 +branch = false +concurrency = ["multiprocessing", "thread"] +parallel = true source = ["src"] [tool.mypy] -strict = true +exclude = "(.config|build|dist|test/local-content|site-packages|~/.pyenv|examples/playbooks/collections|plugins/modules)" +# https://github.com/python/mypy/issues/12664 python_version = "3.10" +strict = true warn_unused_configs = true -exclude = ['build'] [[tool.mypy.overrides]] module = ["mkdocs_ansible._version"] @@ -73,13 +87,28 @@ warn_unused_ignores = false # https://github.com/python/mypy/issues/13201 [tool.pylint.MASTER] ignore-paths = "^src/.*/(_version|_vendor).*$" -[tool.setuptools.dynamic] -dependencies = { file = [".config/requirements.in"] } -optional-dependencies.test = { file = [".config/requirements-test.in"] } +[tool.pytest.ini_options] +addopts = "-p no:pytest_cov --durations=10 --durations-min=1.0 --failed-first" +testpaths = ["test"] + +[tool.ruff] +cache-dir = "./.cache/.ruff" +exclude = [".config"] +fix = true +# Same as Black. +line-length = 88 +preview = true + +[tool.ruff.lint.pydocstyle] +convention = "google" [tool.setuptools] include-package-data = true +[tool.setuptools.dynamic] +dependencies = {file = [".config/requirements.in"]} +optional-dependencies.test = {file = [".config/requirements-test.in"]} + [tool.setuptools.package-data] "*" = ["*.css", "*.html", "*.js"] @@ -87,5 +116,26 @@ include-package-data = true where = ["src"] [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 = "^(?Pv)?(?P\\d+[^\\+]*)(?P.*)?$" write_to = "src/mkdocs_ansible/_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 = ["ansible-core", "pip", "resolvelib", "ruamel-yaml-clib", "uv"] diff --git a/test/__init__.py b/test/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tox.ini b/tox.ini index b3660ad..d359876 100644 --- a/tox.ini +++ b/tox.ini @@ -1,126 +1,119 @@ -# spell-checker:ignore linkcheck basepython changedir envdir envlist envname envsitepackagesdir passenv setenv testenv toxinidir toxworkdir usedevelop doctrees envpython posargs [tox] requires = + setuptools>=65.3 tox>=4.11.4 -envlist = - lint - pkg - docs - py - devel + tox-extra>=2.1 + tox-uv>=1.20.2 +env_list = + py + lint + pkg + docs + devel [testenv] description = - Run tests - devel: without constrained dependencies + Run tests + devel: without constrained dependencies +package = editable extras = - test -passenv = - CURL_CA_BUNDLE # https proxies, https://github.com/tox-dev/tox/issues/1437 - FORCE_COLOR - HOME - NO_COLOR - PYTEST_* # allows developer to define their own preferences - PYTEST_REQPASS # needed for CI - PYTHON* # PYTHONPYCACHEPREFIX, PYTHONIOENCODING, PYTHONBREAKPOINT,... - PY_COLORS - RTD_TOKEN - REQUESTS_CA_BUNDLE # https proxies - SETUPTOOLS_SCM_DEBUG - SSL_CERT_FILE # https proxies - SSH_AUTH_SOCK # may be needed by git when running with progressive - LANG - LC_* -setenv = - COVERAGE_FILE = {envdir}/.coverage.{envname} - ; COVERAGE_PROCESS_START={toxinidir}/pyproject.toml - PIP_CONSTRAINT = {toxinidir}/.config/constraints.txt - devel,pkg: PIP_CONSTRAINT = /dev/null - PIP_DISABLE_PIP_VERSION_CHECK = 1 - PRE_COMMIT_COLOR = always - FORCE_COLOR = 1 -allowlist_externals = - sh + test +pass_env = + CI + CURL_CA_BUNDLE + FORCE_COLOR + HOME + LANG + LC_* + NO_COLOR + PYTEST_REQPASS + PYTHON* + PYTHONBREAKPOINT + PYTHONIOENCODING + PYTHONPYCACHEPREFIX + PY_COLORS + REQUESTS_CA_BUNDLE + RTD_TOKEN + SETUPTOOLS_SCM_DEBUG + SSH_AUTH_SOCK + SSL_CERT_FILE + UV_* +set_env = + COVERAGE_FILE = {env_dir}/.coverage.{env_name} + COVERAGE_PROCESS_START = {tox_root}/pyproject.toml + FORCE_COLOR = 1 + PIP_CONSTRAINT = {tox_root}/.config/constraints.txt + PIP_DISABLE_PIP_VERSION_CHECK = 1 + PRE_COMMIT_COLOR = always + UV_CONSTRAINT = {tox_root}/.config/constraints.txt + deps, devel, lint, pkg: PIP_CONSTRAINT = /dev/null + deps, devel, lint, pkg: UV_CONSTRAINT = /dev/null commands_pre = - sh -c "rm -f .coverage* coverage.xml 2>/dev/null || true" + sh -c "rm -f {env_dir}/.coverage.* 2>/dev/null || true" commands = - coverage run -m pytest {posargs} - sh -c "coverage combine -a -q --data-file={envdir}/.coverage {toxworkdir}/*/.coverage.* && coverage xml --data-file={envdir}/.coverage -o {envdir}/coverage.xml --fail-under=0 && coverage report --data-file={envdir}/.coverage" -package = editable + coverage run -m pytest {posargs:} + {py,py310,py311,py312,py313}: sh -c "coverage combine -q --data-file={env_dir}/.coverage {env_dir}/.coverage.* && coverage xml --data-file={env_dir}/.coverage -o {env_dir}/coverage.xml --ignore-errors --fail-under=0 && COVERAGE_FILE={env_dir}/.coverage coverage lcov --fail-under=0 --ignore-errors -q && COVERAGE_FILE={env_dir}/.coverage coverage report --fail-under=0 --ignore-errors" +allowlist_externals = + sh +editable = true [testenv:lint] description = Run all linters -# pip compile includes python version in output constraints, so we want to -# be sure that version does not change randomly. -basepython = python3.10 -deps = - pre-commit>=2.6.0 - pre-commit-uv>=0.5.0 - setuptools>=65.3.0 - pytest>=7.2.0 # to updated schemas +base_python = python3.10 skip_install = true +deps = + pre-commit>=4.0.1 + pre-commit-uv>=4.1.4 + pytest>=7.2.2 # to updated schemas + setuptools>=65.3 +pass_env = + {[testenv]pass_env} + PRE_COMMIT_HOME +commands_pre = commands = - {envpython} -m pre_commit run --all-files --show-diff-on-failure {posargs:} -passenv = - {[testenv]passenv} - PRE_COMMIT_HOME -setenv = - {[testenv]setenv} - # avoid messing pre-commit with out own constraints - PIP_CONSTRAINT= -[testenv:deps] -description = Bump all test dependencies -# we reuse the lint environment -envdir = {toxworkdir}/lint + {env_python} -m pre_commit run --all-files --show-diff-on-failure {posargs:} + +[testenv:pkg] +description = + Build package, verify metadata, install package and assert behavior when ansible is missing. skip_install = true -basepython = python3.10 deps = - {[testenv:lint]deps} -setenv = - # without his upgrade would likely not do anything - PIP_CONSTRAINT = /dev/null + build>=1.0.3 + pip + twine>=4.0.1 commands = - pre-commit run --all-files --show-diff-on-failure --hook-stage manual lock - # Update pre-commit hooks - pre-commit autoupdate - # We fail if files are modified at the end - git diff --exit-code + {env_python} -c 'import os.path, shutil, sys; \ + dist_dir = os.path.join("{tox_root}", "dist"); \ + os.path.isdir(dist_dir) or sys.exit(0); \ + print("Removing \{!s\} contents...".format(dist_dir), file=sys.stderr); \ + shutil.rmtree(dist_dir)' + {env_python} -m build --outdir {tox_root}/dist/ {tox_root} + twine check --strict {tox_root}/dist/* + sh -c 'python3 -m pip install "mkdocs-ansible[lock] @ file://$(echo {tox_root}/dist/*.whl)"' + python3 -m pip uninstall -y mkdocs-ansible [testenv:docs] description = Builds docs -extras = - docs -setenv = - # Disable colors until markdown-exec supports it: - # https://github.com/pawamoy/markdown-exec/issues/11 - NO_COLOR = 1 - TERM = dump +package = editable skip_install = false -usedevelop = true +extras = + docs +set_env = + DYLD_FALLBACK_LIBRARY_PATH = /opt/homebrew/lib:{env:LD_LIBRARY_PATH} + NO_COLOR = 1 + TERM = dump commands = - mkdocs build -v -c --strict --site-dir=_readthedocs/html/ {posargs:} - linkchecker -f linkcheckerrc _readthedocs/html/ + mkdocs build -v -c --strict --site-dir=_readthedocs/html/ {posargs:} + linkchecker -f linkcheckerrc _readthedocs/html/ -[testenv:pkg] -description = - Build package, verify metadata, install package and assert behavior when ansible is missing. -deps = - build >= 1.0.3 - pip - twine >= 4.0.1 +[testenv:deps] +description = Bump all test dependencies +base_python = python3.10 skip_install = true -# Ref: https://twitter.com/di_codes/status/1044358639081975813 +deps = + {[testenv:lint]deps} +commands_pre = commands = - # build wheel and sdist using PEP-517 - {envpython} -c 'import os.path, shutil, sys; \ - dist_dir = os.path.join("{toxinidir}", "dist"); \ - os.path.isdir(dist_dir) or sys.exit(0); \ - print("Removing \{!s\} contents...".format(dist_dir), file=sys.stderr); \ - shutil.rmtree(dist_dir)' - {envpython} -m build --outdir {toxinidir}/dist/ {toxinidir} - # Validate metadata using twine - twine check --strict {toxinidir}/dist/* - # Install the wheel - sh -c 'python3 -m pip install "mkdocs-ansible[lock] @ file://$(echo {toxinidir}/dist/*.whl)"' - # Uninstall it - python3 -m pip uninstall -y mkdocs-ansible + pre-commit run --all-files --show-diff-on-failure --hook-stage manual lock + pre-commit autoupdate +env_dir = {work_dir}/lint