Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion check-peps.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ def _validate_python_version(line_num: int, line: str) -> MessageIterator:
yield line_num, f"Python-Version minor part must not have leading zeros: {version}"

if micro == "":
return
continue
if minor == "x":
yield line_num, f"Python-Version micro part must be empty if minor part is 'x': {version}"
elif micro[0] == "0":
Expand Down
24 changes: 24 additions & 0 deletions pep_sphinx_extensions/tests/pep_lint/test_headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,3 +382,27 @@ def test_validate_python_version(line: str, expected_warnings: set):
assert warnings == [], warnings

assert found_warnings == expected_warnings


@pytest.mark.parametrize(
("line", "expected_warnings"),
[
(
"3.12, 4.0",
["Python-Version major part must be 1, 2, or 3: 4.0"],
),
(
"3.x, 3.01",
["Python-Version minor part must not have leading zeros: 3.01"],
),
(
"2.7, 3.0.a",
["Python-Version micro part must be numeric: 3.0.a"],
),
],
)
def test_validate_python_version_multiple(line: str, expected_warnings: list):
warnings = [
warning for (_, warning) in check_peps._validate_python_version(1, line)
]
assert warnings == expected_warnings, warnings
Loading