|
| 1 | +# https://hatch.pypa.io/latest/config/environment/overview/ |
| 2 | +# --------------------------------------------------------- |
| 3 | +[envs.default] |
| 4 | +description = "Development environment" |
| 5 | +installer = "uv pip install" |
| 6 | +features = [ |
| 7 | + "tests", |
| 8 | + "types", |
| 9 | + "docs", |
| 10 | + "dev", |
| 11 | +] |
| 12 | + |
| 13 | +# --------------------------------------------------------- |
| 14 | +[envs.pkg] |
| 15 | +description = "package information" |
| 16 | +features = [ |
| 17 | + "tests", |
| 18 | + "dev", |
| 19 | +] |
| 20 | +[envs.pkg.scripts] |
| 21 | +show = [ |
| 22 | + "uv pip list --format=columns", |
| 23 | + 'python -c "import sys; print(sys.version); print(sys.executable)"', |
| 24 | +] |
| 25 | + |
| 26 | +# --------------------------------------------------------- |
| 27 | +[envs.lint] |
| 28 | +template = "lint" |
| 29 | +installer = "uv pip install" |
| 30 | +description = "lint and format" |
| 31 | +detached = true |
| 32 | +dependencies = ["pre-commit"] |
| 33 | + |
| 34 | +[envs.lint.scripts] |
| 35 | +run = "pre-commit run --all-files --show-diff-on-failure" |
| 36 | + |
| 37 | +# --------------------------------------------------------- |
| 38 | +[envs.types] |
| 39 | +template = "types" |
| 40 | +installer = "uv pip install" |
| 41 | +description = "Run the type checker" |
| 42 | +dev-mode = false |
| 43 | +features = ["tests", "types"] |
| 44 | + |
| 45 | +[envs.types.scripts] |
| 46 | +run = "mypy --install-types --non-interactive --ignore-missing-imports --config-file={root}/pyproject.toml {args:src tests}" |
| 47 | + |
| 48 | +# --------------------------------------------------------- |
| 49 | +[envs.docs] |
| 50 | +template = "docs" |
| 51 | +installer = "uv pip install" |
| 52 | +description = "build and check documentation" |
| 53 | +features = ["docs"] |
| 54 | +# Keep in sync with CI.yaml/docs, tox/docs and .readthedocs.yaml. |
| 55 | +python = "3.12" |
| 56 | + |
| 57 | +[envs.docs.scripts] |
| 58 | +build = "sphinx-build -W --keep-going --color -b html docs docs/_build" |
| 59 | +linkcheck = "sphinx-build -W --keep-going --color -b linkcheck docs docs/_build" |
| 60 | +doctest = "sphinx-build -W --keep-going --color -b doctest docs docs/_build" |
| 61 | +run = ["build", "linkcheck"] |
| 62 | +all = ["build", "linkcheck", "doctest"] |
| 63 | + |
| 64 | +# --------------------------------------------------------- |
| 65 | +[envs.changelog] |
| 66 | +template = "changelog" |
| 67 | +installer = "uv pip install" |
| 68 | +description = "build changelog with towncrier" |
| 69 | +dev-mode = false |
| 70 | +dependencies = ["towncrier"] |
| 71 | + |
| 72 | +[envs.changelog.scripts] |
| 73 | +run = "towncrier build --version main --draft" |
| 74 | + |
| 75 | +# --------------------------------------------------------- |
| 76 | +[envs.tests] |
| 77 | +template = "tests" |
| 78 | +#installer = "uv pip install" |
| 79 | +description = "Run the tests suite" |
| 80 | +dev-mode = false |
| 81 | +features = ["tests"] |
| 82 | + |
| 83 | +[[envs.tests.matrix]] |
| 84 | +python = ["3.9", "3.10", "3.11", "3.12", "3.13"] |
| 85 | + |
| 86 | +[envs.tests.env-vars] |
| 87 | +COVERAGE_PROCESS_START = "pyproject.toml" |
| 88 | +COVERAGE_FILE = "report/.coverage.{matrix:python}" |
| 89 | + |
| 90 | +[envs.tests.overrides] |
| 91 | +# To allow environment variable overwrite |
| 92 | +env.COVERAGE_FILE.env-vars = "COVERAGE_FILE" |
| 93 | +env.COVERAGE_PROCESS_START.env-vars = "COVERAGE_PROCESS_START" |
| 94 | + |
| 95 | +[envs.tests.scripts] |
| 96 | +run = "pytest {args:-n auto}" |
| 97 | +test-cov = "python -m pytest --cov=subliminal --cov-report= --cov-fail-under=0 {args:-n auto}" |
| 98 | +test-cov-core = "python -m pytest -m core --cov=subliminal --cov-report= --cov-fail-under=0 {args:-n auto}" |
| 99 | +run-cov = [ |
| 100 | + "test-cov", |
| 101 | + "coverage report --skip-covered --show-missing --fail-under=80", |
| 102 | +] |
| 103 | +run-cov-core = [ |
| 104 | + "test-cov-core", |
| 105 | + """\ |
| 106 | + coverage report --skip-covered --show-missing --fail-under=100 \ |
| 107 | + --omit='src/subliminal/cli.py,src/subliminal/converters/*,src/subliminal/providers/*,src/subliminal/refiners/*' \ |
| 108 | + """, |
| 109 | +] |
| 110 | + |
| 111 | +# --------------------------------------------------------- |
| 112 | +[envs.coverage] |
| 113 | +template = "coverage" |
| 114 | +installer = "uv pip install" |
| 115 | +description = "combine coverage files" |
| 116 | +detached = true |
| 117 | +dependencies = [ |
| 118 | + "coverage[toml]>=7.3.2", |
| 119 | +] |
| 120 | +env-vars = { COVERAGE_FILE = "report/.coverage" } |
| 121 | +# To allow environment variable overwrite |
| 122 | +overrides = { env.COVERAGE_FILE.env-vars = "COVERAGE_FILE" } |
| 123 | + |
| 124 | +[envs.coverage.scripts] |
| 125 | +run = [ |
| 126 | + "- coverage combine report", |
| 127 | + "coverage report --sort=-Cover --show-missing --skip-covered --skip-empty", |
| 128 | +] |
0 commit comments