Skip to content

Commit cdcc699

Browse files
committed
pre-commit
1 parent d9b4d24 commit cdcc699

File tree

5 files changed

+32
-16
lines changed

5 files changed

+32
-16
lines changed

src/setuptools_scm/_config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ def _check_tag_regex(value: str | Pattern[str] | None) -> Pattern[str]:
4242
group_names = regex.groupindex.keys()
4343
if regex.groups == 0 or (regex.groups > 1 and "version" not in group_names):
4444
raise ValueError(
45-
f"Expected tag_regex '{regex.pattern}' to contain a single match group or a group named"
46-
" 'version' to identify the version part of any tag."
45+
f"Expected tag_regex '{regex.pattern}' to contain a single match group or"
46+
" a group named 'version' to identify the version part of any tag."
4747
)
4848

4949
return regex
@@ -105,7 +105,7 @@ class Configuration:
105105

106106
parent: _t.PathT | None = None
107107

108-
def __post_init__(self):
108+
def __post_init__(self) -> None:
109109
self.tag_regex = _check_tag_regex(self.tag_regex)
110110

111111
@property

src/setuptools_scm/_entrypoints.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def _call_version_scheme(
110110
entrypoint: str,
111111
given_value: _t.VERSION_SCHEMES,
112112
default: str | None = None,
113-
) -> str | None:
113+
) -> str:
114114
found_any_implementation = False
115115
for scheme in _iter_version_schemes(entrypoint, given_value):
116116
found_any_implementation = True
@@ -119,10 +119,12 @@ def _call_version_scheme(
119119
return result
120120
if not found_any_implementation:
121121
raise ValueError(
122-
f'Couldn\'t find any implementations for entrypoint "{entrypoint}" with value "{given_value}".'
122+
f'Couldn\'t find any implementations for entrypoint "{entrypoint}"'
123+
f' with value "{given_value}".'
123124
)
124125
if default is not None:
125126
return default
126127
raise ValueError(
127-
f'None of the "{entrypoint}" entrypoints matching "{given_value}" returned a value.'
128+
f'None of the "{entrypoint}" entrypoints matching "{given_value}"'
129+
" returned a value."
128130
)

src/setuptools_scm/version.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ def _parse_version_tag(
6767
return result
6868

6969
raise ValueError(
70-
f'The tag_regex "{config.tag_regex.pattern}" matched tag "{tag}", however the matched'
71-
" group has no value."
70+
f'The tag_regex "{config.tag_regex.pattern}" matched tag "{tag}", '
71+
"however the matched group has no value."
7272
)
7373
else:
7474
log.debug("tag %r did not parse", tag)

testing/test_config.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ def test_config_overrides(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> No
110110
def test_config_bad_regex(tag_regex: str) -> None:
111111
with pytest.raises(
112112
ValueError,
113-
match=f"Expected tag_regex '{re.escape(tag_regex)}' to contain a single match group or a group named 'version' to identify the version part of any tag.",
113+
match=(
114+
f"Expected tag_regex '{re.escape(tag_regex)}' to contain a single match"
115+
" group or a group named 'version' to identify the version part of any"
116+
" tag."
117+
),
114118
):
115-
Configuration(tag_regex=tag_regex)
119+
Configuration(tag_regex=re.compile(tag_regex))

testing/test_version.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import re
34
from dataclasses import replace
45
from datetime import date
56
from datetime import timedelta
@@ -192,9 +193,12 @@ def test_tag_regex1(tag: str, expected: str) -> None:
192193
def test_regex_match_but_no_version() -> None:
193194
with pytest.raises(
194195
ValueError,
195-
match=r'The tag_regex "\(\?P<version>\)\.\*" matched tag "v1", however the matched group has no value',
196+
match=(
197+
r'The tag_regex "\(\?P<version>\)\.\*" matched tag "v1", '
198+
" however the matched group has no value"
199+
),
196200
):
197-
meta("v1", config=replace(c, tag_regex="(?P<version>).*"))
201+
meta("v1", config=replace(c, tag_regex=re.compile("(?P<version>).*")))
198202

199203

200204
@pytest.mark.issue("https://github.com/pypa/setuptools_scm/issues/471")
@@ -424,11 +428,14 @@ def __repr__(self) -> str:
424428
def test_no_matching_entrypoints(config_key: str) -> None:
425429
version = meta(
426430
"1.0",
427-
config=replace(c, **{config_key: "nonexistant"}),
431+
config=replace(c, **{config_key: "nonexistant"}), # type: ignore
428432
)
429433
with pytest.raises(
430434
ValueError,
431-
match=r'Couldn\'t find any implementations for entrypoint "setuptools_scm\..*?" with value "nonexistant"',
435+
match=(
436+
r'Couldn\'t find any implementations for entrypoint "setuptools_scm\..*?"'
437+
' with value "nonexistant"'
438+
),
432439
):
433440
format_version(version)
434441

@@ -438,11 +445,14 @@ def test_all_entrypoints_return_none() -> None:
438445
"1.0",
439446
config=replace(
440447
c,
441-
version_scheme=lambda v: None,
448+
version_scheme=lambda v: None, # type: ignore
442449
),
443450
)
444451
with pytest.raises(
445452
ValueError,
446-
match=r'None of the "setuptools_scm.version_scheme" entrypoints matching .*? returned a value.',
453+
match=(
454+
'None of the "setuptools_scm.version_scheme" entrypoints matching'
455+
r" .*? returned a value."
456+
),
447457
):
448458
format_version(version)

0 commit comments

Comments
 (0)