diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c7bf915..35c08b2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,13 +16,13 @@ repos: additional_dependencies: [ "tomli>=2.0.1" ] args: [ "--in-place", "--config", "./pyproject.toml" ] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.4.3" + rev: "v0.4.4" hooks: - id: ruff-format - id: ruff args: [ "--fix", "--unsafe-fixes", "--exit-non-zero-on-fix" ] - repo: https://github.com/tox-dev/pyproject-fmt - rev: "1.8.0" + rev: "2.0.4" hooks: - id: pyproject-fmt additional_dependencies: ["tox>=4.14.2"] diff --git a/pyproject.toml b/pyproject.toml index 00befe5..6b5915b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -67,33 +67,61 @@ urls.Tracker = "https://github.com/platformdirs/platformdirs/issues" [tool.hatch] build.hooks.vcs.version-file = "src/platformdirs/version.py" -build.targets.sdist.include = ["/src", "/tests", "/tox.ini"] +build.targets.sdist.include = [ + "/src", + "/tests", + "/tox.ini", +] version.source = "vcs" [tool.hatch.envs.default] description = "Development environment" -features = ["test", "docs", "type"] -scripts = { show = ["python -m pip list --format=columns", 'python -c "import sys; print(sys.executable)"'] } +features = [ + "test", + "docs", + "type", +] +scripts = { show = [ + "python -m pip list --format=columns", + 'python -c "import sys; print(sys.executable)"', +] } [tool.hatch.envs.test] template = "test" # dev-mode = false # cannot enable this until https://github.com/pypa/hatch/issues/1237 description = "Run the test suite" -matrix = [{ python = ["3.12", "3.11", "3.10", "3.9", "3.8", "pypy3.9"] }] -features = ["test"] +matrix = [ + { python = [ + "3.12", + "3.11", + "3.10", + "3.9", + "3.8", + "pypy3.9", + ] }, +] +features = [ + "test", +] env-vars = { COVERAGE_FILE = "report/.coverage.{matrix:python}", COVERAGE_PROCESS_START = "pyproject.toml", _COVERAGE_SRC = "src/platformdirs" } [tool.hatch.envs.test.scripts] -run = [""" +run = [ + """ pytest --junitxml report/junit.{matrix:python}.xml --cov src/platformdirs --cov tests \ --cov-config=pyproject.toml --no-cov-on-fail --cov-report term-missing:skip-covered --cov-context=test \ --cov-report html:report/html{matrix:python} --cov-report xml:report/coverage{matrix:python}.xml \ tests -"""] +""", +] [tool.hatch.envs.coverage] template = "coverage" description = "combine coverage files and generate diff" -dependencies = ["covdefaults>=2.3", "coverage[toml]>=7.3.2", "diff-cover>=8.0.1"] +dependencies = [ + "covdefaults>=2.3", + "coverage[toml]>=7.3.2", + "diff-cover>=8.0.1", +] env-vars = { COVERAGE_FILE = "report/.coverage" } [tool.hatch.envs.coverage.scripts] run = [ @@ -109,23 +137,35 @@ template = "type" description = "Run the type checker" python = "3.12" dev-mode = false -features = ["type", "test"] -scripts = { run = ["mypy --strict src", "mypy --strict tests"] } +features = [ + "type", + "test", +] +scripts = { run = [ + "mypy --strict src", + "mypy --strict tests", +] } [tool.hatch.envs.fix] template = "fix" description = "Run the pre-commit tool to lint and autofix issues" python = "3.12" detached = true -dependencies = ["pre-commit>=3.6"] -scripts = { "run" = ["pre-commit run --all-files --show-diff-on-failure"] } +dependencies = [ + "pre-commit>=3.6", +] +scripts = { "run" = [ + "pre-commit run --all-files --show-diff-on-failure", +] } [tool.hatch.envs.docs] template = "docs" description = "Build documentation using Sphinx" python = "3.12" dev-mode = false -features = ["docs"] +features = [ + "docs", +] [tool.hatch.envs.docs.scripts] build = [ """python -c "import glob; import subprocess; subprocess.call(['proselint'] + glob.glob('docs/*.rst'))" """, @@ -138,14 +178,29 @@ build = [ template = "readme" description = "check that the long description is valid" python = "3.12" -dependencies = ["build[virtualenv]>=1.0.3", "twine>=4.0.2", "check-wheel-contents>=0.6.0"] -scripts = { "run" = ["python -m build -o dist", "twine check dist/*.whl dist/*.tar.gz", "check-wheel-contents dist"] } +dependencies = [ + "build[virtualenv]>=1.0.3", + "twine>=4.0.2", + "check-wheel-contents>=0.6.0", +] +scripts = { "run" = [ + "python -m build -o dist", + "twine check dist/*.whl dist/*.tar.gz", + "check-wheel-contents dist", +] } [tool.ruff] -select = ["ALL"] +select = [ + "ALL", +] line-length = 120 target-version = "py38" -isort = { known-first-party = ["platformdirs", "tests"], required-imports = ["from __future__ import annotations"] } +isort = { known-first-party = [ + "platformdirs", + "tests", +], required-imports = [ + "from __future__ import annotations", +] } ignore = [ "ANN101", # Missing type annotation for `self` in method "D301", # Use `r"""` if any backslashes in a docstring @@ -186,13 +241,23 @@ wrap-summaries = 120 html.show_contexts = true html.skip_covered = false run.relative_files = true -paths.source = ["src", "**/site-packages"] +paths.source = [ + "src", + "**/site-packages", +] report.fail_under = 76 run.parallel = true -run.plugins = ["covdefaults"] +run.plugins = [ + "covdefaults", +] [tool.mypy] python_version = "3.11" show_error_codes = true strict = true -overrides = [{ module = ["appdirs.*", "jnius.*"], ignore_missing_imports = true }] +overrides = [ + { module = [ + "appdirs.*", + "jnius.*", + ], ignore_missing_imports = true }, +]