From 070b92bf1d780477fefbb1ff64fde7b51fe306e1 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Fri, 25 Oct 2024 21:56:26 +0100 Subject: [PATCH 1/2] Use the PEP 735 [dependency-groups] table --- .github/workflows/builddoc.yml | 2 +- .github/workflows/create-release.yml | 5 +--- .github/workflows/lint.yml | 8 ++--- .github/workflows/main.yml | 14 ++++----- .github/workflows/transifex.yml | 4 +-- pyproject.toml | 45 ++++++++++++++++++++++++++++ tox.ini | 16 +++++----- 7 files changed, 68 insertions(+), 26 deletions(-) diff --git a/.github/workflows/builddoc.yml b/.github/workflows/builddoc.yml index 7f8471deecb..8955cf2988a 100644 --- a/.github/workflows/builddoc.yml +++ b/.github/workflows/builddoc.yml @@ -36,7 +36,7 @@ jobs: version: latest enable-cache: false - name: Install dependencies - run: uv pip install .[docs] + run: uv pip install . --group docs - name: Render the documentation run: > sphinx-build diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 7d854e764b8..5d07fcbd18d 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -41,10 +41,7 @@ jobs: enable-cache: false - name: Install build dependencies (pypa/build, twine) - run: | - uv pip install build "twine>=5.1" - # resolution fails without betterproto - uv pip install pypi-attestations==0.0.22 betterproto==2.0.0b6 + run: uv pip install --group package - name: Build distribution run: python -m build diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index a3b5cf7ae52..7e72b6f6fd0 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -55,7 +55,7 @@ jobs: version: latest enable-cache: false - name: Install dependencies - run: uv pip install ".[lint,test]" + run: uv pip install -r pyproject.toml --group package --group test --group types - name: Type check with mypy run: mypy @@ -76,7 +76,7 @@ jobs: version: latest enable-cache: false - name: Install dependencies - run: uv pip install ".[lint,test]" + run: uv pip install -r pyproject.toml --group package --group test --group types - name: Type check with pyright run: pyright @@ -97,7 +97,7 @@ jobs: version: latest enable-cache: false - name: Install dependencies - run: uv pip install --upgrade sphinx-lint + run: uv pip install --group lint - name: Lint documentation with sphinx-lint run: make doclinter @@ -118,7 +118,7 @@ jobs: version: latest enable-cache: false - name: Install dependencies - run: uv pip install --upgrade twine build + run: uv pip install --group package - name: Lint with twine run: | python -m build . diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1758254c633..7e7bdb6dab2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -67,7 +67,7 @@ jobs: version: latest enable-cache: false - name: Install dependencies - run: uv pip install .[test] + run: uv pip install . --group test - name: Install Docutils ${{ matrix.docutils }} run: uv pip install --upgrade "docutils~=${{ matrix.docutils }}.0" - name: Test with pytest @@ -198,7 +198,7 @@ jobs: version: latest enable-cache: false - name: Install dependencies - run: uv pip install .[test] + run: uv pip install . --group test - name: Test with pytest run: python -m pytest -vv --durations 25 env: @@ -227,7 +227,7 @@ jobs: version: latest enable-cache: false - name: Install dependencies - run: uv pip install .[test] + run: uv pip install . --group test - name: Test with pytest run: python -m pytest -vv --durations 25 env: @@ -262,7 +262,7 @@ jobs: version: latest enable-cache: false - name: Install dependencies - run: uv pip install .[test] + run: uv pip install . --group test - name: Install Docutils' HEAD run: uv pip install "docutils @ git+https://repo.or.cz/docutils.git#subdirectory=docutils" - name: Test with pytest @@ -296,7 +296,7 @@ jobs: enable-cache: false - name: Install dependencies run: | - uv pip install .[test] --resolution lowest-direct + uv pip install . --group test --resolution lowest-direct uv pip install alabaster==1.0.0 - name: Test with pytest run: python -m pytest -n logical --dist=worksteal -vv --durations 25 @@ -326,7 +326,7 @@ jobs: version: latest enable-cache: false - name: Install dependencies - run: uv pip install .[test] + run: uv pip install . --group test - name: Test with pytest run: python -m pytest -vv --durations 25 env: @@ -357,7 +357,7 @@ jobs: version: latest enable-cache: false - name: Install dependencies - run: uv pip install .[test] pytest-cov + run: uv pip install . --group test pytest-cov - name: Test with pytest run: python -m pytest -vv --cov . --cov-append --cov-config pyproject.toml env: diff --git a/.github/workflows/transifex.yml b/.github/workflows/transifex.yml index 09437cb7ece..56246266515 100644 --- a/.github/workflows/transifex.yml +++ b/.github/workflows/transifex.yml @@ -41,7 +41,7 @@ jobs: version: latest enable-cache: false - name: Install dependencies - run: uv pip install --upgrade babel jinja2 + run: uv pip install --group translations - name: Extract translations from source code run: python utils/babel_runner.py extract - name: Push translations to transifex.com @@ -77,7 +77,7 @@ jobs: version: latest enable-cache: false - name: Install dependencies - run: uv pip install --upgrade babel jinja2 + run: uv pip install --group translations - name: Extract translations from source code run: python utils/babel_runner.py extract - name: Pull translations from transifex.com diff --git a/pyproject.toml b/pyproject.toml index d63af5241b4..631e2bff232 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -130,6 +130,48 @@ sphinx-quickstart = "sphinx.cmd.quickstart:main" sphinx-apidoc = "sphinx.ext.apidoc:main" sphinx-autogen = "sphinx.ext.autosummary.generate:main" +[dependency-groups] +docs = [ + "sphinxcontrib-websupport", +] +lint = [ + "ruff==0.11.0", + "sphinx-lint>=0.9", +] +package = [ + "betterproto==2.0.0b6", # resolution fails without betterproto + "build", + "pypi-attestations==0.0.22", + "twine>=5.1", +] +test = [ + "pytest>=8.0", + "pytest-xdist[psutil]>=3.4", + "cython>=3.0", # for Cython compilation + "defusedxml>=0.7.1", # for secure XML/HTML parsing + "setuptools>=70.0", # for Cython compilation + "typing_extensions>=4.9", # for typing_extensions.Unpack +] +translations = [ + "babel>=2.13", + "Jinja2>=3.1", +] +types = [ + "mypy==1.15.0", + "pyright==1.1.397", + { include-group = "type-stubs" }, +] +type-stubs = [ + # align with versions used elsewhere + "types-colorama==0.4.15.20240311", + "types-defusedxml==0.7.0.20240218", + "types-docutils==0.21.0.20241128", + "types-Pillow==10.2.0.20240822", + "types-Pygments==2.19.0.20250305", + "types-requests==2.32.0.20250306", + "types-urllib3==1.26.25.14", +] + [tool.flit.module] name = "sphinx" @@ -420,3 +462,6 @@ reportUnusedFunction = "none" reportUnusedImport = "none" reportUnusedVariable = "none" reportWildcardImportFromLibrary = "none" + +[tool.uv] +default-groups = "all" diff --git a/tox.ini b/tox.ini index 674013fdc08..23b239c7ffc 100644 --- a/tox.ini +++ b/tox.ini @@ -20,7 +20,7 @@ passenv = READTHEDOCS description = py{311,312,313,314}: Run unit tests against {envname}. -extras = +dependency_groups = test setenv = PYTHONWARNINGS = error @@ -31,8 +31,9 @@ commands= [testenv:lint] description = Run linters. -extras = +dependency_groups = lint + types # If you update any of these commands, don't forget to update the equivalent # GitHub Workflow step commands = @@ -43,7 +44,7 @@ commands = [testenv:docs] description = Build documentation. -extras = +dependency_groups = docs commands = python -c "import shutil; shutil.rmtree('./build/sphinx', ignore_errors=True) if '{env:CLEAN:}' else None" @@ -52,7 +53,7 @@ commands = [testenv:docs-live] description = Build documentation. -extras = +dependency_groups = docs deps = sphinx-autobuild @@ -70,7 +71,7 @@ commands = [testenv:ruff] description = Run ruff formatting and linting. -extras = +dependency_groups = lint commands = ruff format . @@ -79,8 +80,7 @@ commands = [testenv:mypy] description = Run mypy type checking. -extras = - lint - test +dependency_groups = + types commands = mypy {posargs} From 7c236e65e2f2d4333ee747b1af795d53c32aafa3 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Thu, 20 Mar 2025 18:08:35 +0000 Subject: [PATCH 2/2] whitespace --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 631e2bff232..dd50b0aa6ef 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -148,7 +148,7 @@ test = [ "pytest>=8.0", "pytest-xdist[psutil]>=3.4", "cython>=3.0", # for Cython compilation - "defusedxml>=0.7.1", # for secure XML/HTML parsing + "defusedxml>=0.7.1", # for secure XML/HTML parsing "setuptools>=70.0", # for Cython compilation "typing_extensions>=4.9", # for typing_extensions.Unpack ]