From 5d950212d6c964f86a949333c0a6e11cea296c49 Mon Sep 17 00:00:00 2001 From: Eric Sampson Date: Mon, 29 Sep 2025 11:24:43 -0500 Subject: [PATCH 1/7] GitHub Action add support for "major only" `required-version` when using pyproject.toml --- CHANGES.md | 2 ++ action/main.py | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index f6ec50fe8ba..24ea4f9c22b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -44,6 +44,8 @@ ### Integrations +- Enhance GitHub Action `psf/black` to support the `required-version` + major-version-only "stability" format when using pyproject.toml ### Documentation diff --git a/action/main.py b/action/main.py index f7fdda7efb6..7469f200eae 100644 --- a/action/main.py +++ b/action/main.py @@ -68,7 +68,11 @@ def read_version_specifier_from_pyproject() -> str: version = pyproject.get("tool", {}).get("black", {}).get("required-version") if version is not None: - return f"=={version}" + # Match the two supported usages of `required-version`: + if "." in version: + return f"=={version}" + else: + return f"~={version}" arrays = [ *pyproject.get("dependency-groups", {}).values(), From aa4fc1f9e2fef6e3b9219ad350a73ee652f321c8 Mon Sep 17 00:00:00 2001 From: Eric Sampson Date: Mon, 29 Sep 2025 11:41:29 -0500 Subject: [PATCH 2/7] lint trailing whitespace --- CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 24ea4f9c22b..89fed7119b3 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -44,7 +44,7 @@ ### Integrations -- Enhance GitHub Action `psf/black` to support the `required-version` +- Enhance GitHub Action `psf/black` to support the `required-version` major-version-only "stability" format when using pyproject.toml ### Documentation From 869c319cad9a6a7e8cdb3966a73a7882f5e37656 Mon Sep 17 00:00:00 2001 From: Eric Sampson Date: Mon, 29 Sep 2025 11:58:18 -0500 Subject: [PATCH 3/7] add PR link --- CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 89fed7119b3..b7784341d99 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -45,7 +45,7 @@ - Enhance GitHub Action `psf/black` to support the `required-version` - major-version-only "stability" format when using pyproject.toml + major-version-only "stability" format when using pyproject.toml (#4770) ### Documentation From bf95e76beb6034dbf26801c03711a76c65a99c8d Mon Sep 17 00:00:00 2001 From: Eric Sampson Date: Mon, 29 Sep 2025 12:13:12 -0500 Subject: [PATCH 4/7] more lint --- CHANGES.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index b7784341d99..65ea87499a6 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -43,9 +43,8 @@ ### Integrations - -- Enhance GitHub Action `psf/black` to support the `required-version` - major-version-only "stability" format when using pyproject.toml (#4770) +- Enhance GitHub Action `psf/black` to support the `required-version` major-version-only + "stability" format when using pyproject.toml (#4770) ### Documentation @@ -1677,6 +1676,7 @@ and the first release covered by our new ## 18.9b0 - numeric literals are now formatted by _Black_ (#452, #461, #464, #469): + - numeric literals are normalized to include `_` separators on Python 3.6+ code - added `--skip-numeric-underscore-normalization` to disable the above behavior and @@ -1726,6 +1726,7 @@ and the first release covered by our new - typing stub files (`.pyi`) now have blank lines added after constants (#340) - `# fmt: off` and `# fmt: on` are now much more dependable: + - they now work also within bracket pairs (#329) - they now correctly work across function/class boundaries (#335) From 24399956f1db9e571fbed40b144935d57d2b238c Mon Sep 17 00:00:00 2001 From: Eric Sampson Date: Mon, 29 Sep 2025 12:16:48 -0500 Subject: [PATCH 5/7] revert incidental formatting changes --- CHANGES.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 65ea87499a6..a23baf21892 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1676,7 +1676,6 @@ and the first release covered by our new ## 18.9b0 - numeric literals are now formatted by _Black_ (#452, #461, #464, #469): - - numeric literals are normalized to include `_` separators on Python 3.6+ code - added `--skip-numeric-underscore-normalization` to disable the above behavior and @@ -1726,7 +1725,6 @@ and the first release covered by our new - typing stub files (`.pyi`) now have blank lines added after constants (#340) - `# fmt: off` and `# fmt: on` are now much more dependable: - - they now work also within bracket pairs (#329) - they now correctly work across function/class boundaries (#335) From 1bdd7fc69d7a964b4830bfc7a1c919787b042cd7 Mon Sep 17 00:00:00 2001 From: Eric Sampson Date: Mon, 29 Sep 2025 14:02:56 -0500 Subject: [PATCH 6/7] Update CHANGES.md Co-authored-by: GiGaGon <107241144+MeGaGiGaGon@users.noreply.github.com> --- CHANGES.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index a23baf21892..d3e8b3d82ff 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -43,6 +43,8 @@ ### Integrations + + - Enhance GitHub Action `psf/black` to support the `required-version` major-version-only "stability" format when using pyproject.toml (#4770) From eb75696913fc92d15eed26ff803023f740f9364f Mon Sep 17 00:00:00 2001 From: Eric Sampson Date: Mon, 29 Sep 2025 17:24:19 -0500 Subject: [PATCH 7/7] Update main.py compat string --- action/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action/main.py b/action/main.py index 7469f200eae..2cabc9772ba 100644 --- a/action/main.py +++ b/action/main.py @@ -72,7 +72,7 @@ def read_version_specifier_from_pyproject() -> str: if "." in version: return f"=={version}" else: - return f"~={version}" + return f"~={version}.0" arrays = [ *pyproject.get("dependency-groups", {}).values(),