Skip to content

Commit be62dea

Browse files
GitHub Action: add support for the required-version "major-version-only" format when using pyproject.toml (#4770)
Co-authored-by: GiGaGon <107241144+MeGaGiGaGon@users.noreply.github.com>
1 parent 903bef5 commit be62dea

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

CHANGES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
4545

4646
<!-- For example, Docker, GitHub Actions, pre-commit, editors -->
4747

48+
- Enhance GitHub Action `psf/black` to support the `required-version` major-version-only
49+
"stability" format when using pyproject.toml (#4770)
50+
4851
### Documentation
4952

5053
<!-- Major changes to documentation and policies. Small docs changes

action/main.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,11 @@ def read_version_specifier_from_pyproject() -> str:
6868

6969
version = pyproject.get("tool", {}).get("black", {}).get("required-version")
7070
if version is not None:
71-
return f"=={version}"
71+
# Match the two supported usages of `required-version`:
72+
if "." in version:
73+
return f"=={version}"
74+
else:
75+
return f"~={version}.0"
7276

7377
arrays = [
7478
*pyproject.get("dependency-groups", {}).values(),

0 commit comments

Comments
 (0)