Skip to content

Commit dd278cb

Browse files
authored
update github-action to look for black version in "dependency-groups" (#4606)
"dependency-groups" is the mechanism for storing package requirements in `pyproject.toml`, recommended for formatting tools (see https://packaging.python.org/en/latest/specifications/dependency-groups/ ) this change allow the black action to look also in those locations when determining the version of black to install
1 parent dbb14ea commit dd278cb

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

CHANGES.md

+2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@
5151
<!-- For example, Docker, GitHub Actions, pre-commit, editors -->
5252

5353
- Fix the version check in the vim file to reject Python 3.8 (#4567)
54+
- Enhance GitHub Action `psf/black` to read Black version from an additional
55+
section in pyproject.toml: `[project.dependency-groups]` (#4606)
5456

5557
### Documentation
5658

action/main.py

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def read_version_specifier_from_pyproject() -> str:
7171
return f"=={version}"
7272

7373
arrays = [
74+
*pyproject.get("dependency-groups", {}).values(),
7475
pyproject.get("project", {}).get("dependencies"),
7576
*pyproject.get("project", {}).get("optional-dependencies", {}).values(),
7677
]

docs/integrations/github_actions.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ the `pyproject.toml` file. `version` can be any
3737
[valid version specifier](https://packaging.python.org/en/latest/glossary/#term-Version-Specifier)
3838
or just the version number if you want an exact version. To read the version from the
3939
`pyproject.toml` file instead, set `use_pyproject` to `true`. This will first look into
40-
the `tool.black.required-version` field, then the `project.dependencies` array and
41-
finally the `project.optional-dependencies` table. The action defaults to the latest
42-
release available on PyPI. Only versions available from PyPI are supported, so no commit
43-
SHAs or branch names.
40+
the `tool.black.required-version` field, then the `dependency-groups` table, then the
41+
`project.dependencies` array and finally the `project.optional-dependencies` table.
42+
The action defaults to the latest release available on PyPI. Only versions available
43+
from PyPI are supported, so no commit SHAs or branch names.
4444

4545
If you want to include Jupyter Notebooks, _Black_ must be installed with the `jupyter`
4646
extra. Installing the extra and including Jupyter Notebook files can be configured via

0 commit comments

Comments
 (0)