Skip to content

Commit 29536ef

Browse files
committed
Update black
Change the versioning scheme to pin to the year. According to the documentation that is the stability cadence of the style.
1 parent fe1b004 commit 29536ef

5 files changed

Lines changed: 11 additions & 10 deletions

File tree

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
- name: "Lint plugin_template"
3131
working-directory: "plugin_template"
3232
run: |
33-
pip3 install black==24.3.0 flake8
33+
pip3 install black~=26.3 flake8
3434
black --version
3535
black --check --diff plugin-template utils.py
3636
flake8 plugin-template utils.py

plugin-template

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# /// script
33
# requires-python = ">=3.11"
44
# dependencies = [
5-
# "black==24.3.0",
5+
# "black~=26.3",
66
# "jamldump>=1.2.0,<1.3.0",
77
# "jinja2>=3.1.6,<3.2.0",
88
# "pyyaml>=6.0.3,<6.1.0",
@@ -378,7 +378,7 @@ def write_template_section(
378378
"current_version": utils.current_version(plugin_root_dir),
379379
"pulpdocs_branch": PULPDOCS_BRANCH,
380380
"is_pulpdocs_member": config["plugin_name"] in utils.get_pulpdocs_members(PULPDOCS_BRANCH),
381-
"black_version": utils.black_version(),
381+
"black_requirement": utils.black_requirement(),
382382
"config": config,
383383
**config,
384384
}

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# This needs to match the version in templates/github/lint_requirement.txt.j2
2-
black==24.3.0
1+
# This (black) is copied into templates/github/lint_requirement.txt.j2
2+
black~=26.3 # Pin Style to the year. https://black.readthedocs.io/en/stable/faq.html#how-stable-is-black-s-style
33
jamldump>=1.2.0,<1.3.0
44
jinja2
55
pyyaml

templates/github/lint_requirements.txt.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{% include 'header.j2' %}
22

33
{% if black -%}
4-
black=={{ black_version }}
4+
{{ black_requirement }}
55
{% endif -%}
66
bump-my-version
77
check-manifest

utils.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from datetime import timedelta
2+
from packaging.requirement import Requirement
23
from pathlib import Path
34
import re
45
import stat
@@ -94,12 +95,12 @@ def current_version(plugin_root_path):
9495
return current_version
9596

9697

97-
def black_version():
98-
PATTERN = re.compile(r"^black==(?P<version>.*)$")
98+
def black_requirement():
9999
requirements_file = Path(__file__).parent / "requirements.txt"
100100
for line in requirements_file.read_text().splitlines():
101-
if match := PATTERN.fullmatch(line):
102-
return match.group("version")
101+
requirement = Requirement(line)
102+
if requirement.name.lower() == "black":
103+
return line
103104

104105
raise ValueError("'black' not found in 'requirements.txt'")
105106

0 commit comments

Comments
 (0)