Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't put an underscore in the version portion of Python 3.10 compatibility tags #355

Merged
merged 2 commits into from Dec 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 1 addition & 5 deletions packaging/tags.py
Expand Up @@ -827,11 +827,7 @@ def interpreter_version(**kwargs):

def _version_nodot(version):
# type: (PythonVersion) -> str
if any(v >= 10 for v in version):
sep = "_"
else:
sep = ""
return sep.join(map(str, version))
return "".join(map(str, version))


def sys_tags(**kwargs):
Expand Down
66 changes: 33 additions & 33 deletions tests/test_tags.py
Expand Up @@ -190,9 +190,9 @@ def test_python_version_nodot(self, monkeypatch):
"version_info,version_str",
[
((1, 2, 3), "12"),
((1, 12, 3), "1_12"),
((11, 2, 3), "11_2"),
((11, 12, 3), "11_12"),
((1, 12, 3), "112"),
((11, 2, 3), "112"),
((11, 12, 3), "1112"),
((1, 2, 13), "12"),
],
)
Expand Down Expand Up @@ -822,20 +822,20 @@ def test_iterator_returned(self):

def test_all_args(self):
result_iterator = tags.cpython_tags(
(3, 11), ["cp3_11d", "cp3_11"], ["plat1", "plat2"]
(3, 11), ["cp311d", "cp311"], ["plat1", "plat2"]
)
result = list(result_iterator)
assert result == [
tags.Tag("cp3_11", "cp3_11d", "plat1"),
tags.Tag("cp3_11", "cp3_11d", "plat2"),
tags.Tag("cp3_11", "cp3_11", "plat1"),
tags.Tag("cp3_11", "cp3_11", "plat2"),
tags.Tag("cp3_11", "abi3", "plat1"),
tags.Tag("cp3_11", "abi3", "plat2"),
tags.Tag("cp3_11", "none", "plat1"),
tags.Tag("cp3_11", "none", "plat2"),
tags.Tag("cp3_10", "abi3", "plat1"),
tags.Tag("cp3_10", "abi3", "plat2"),
tags.Tag("cp311", "cp311d", "plat1"),
tags.Tag("cp311", "cp311d", "plat2"),
tags.Tag("cp311", "cp311", "plat1"),
tags.Tag("cp311", "cp311", "plat2"),
tags.Tag("cp311", "abi3", "plat1"),
tags.Tag("cp311", "abi3", "plat2"),
tags.Tag("cp311", "none", "plat1"),
tags.Tag("cp311", "none", "plat2"),
tags.Tag("cp310", "abi3", "plat1"),
tags.Tag("cp310", "abi3", "plat2"),
tags.Tag("cp39", "abi3", "plat1"),
tags.Tag("cp39", "abi3", "plat2"),
tags.Tag("cp38", "abi3", "plat1"),
Expand Down Expand Up @@ -905,11 +905,11 @@ def test_abi_defaults(self, monkeypatch):
assert tags.Tag("cp38", "none", "any") in result

def test_abi_defaults_needs_underscore(self, monkeypatch):
monkeypatch.setattr(tags, "_cpython_abis", lambda _1, _2: ["cp3_11"])
monkeypatch.setattr(tags, "_cpython_abis", lambda _1, _2: ["cp311"])
result = list(tags.cpython_tags((3, 11), platforms=["any"]))
assert tags.Tag("cp3_11", "cp3_11", "any") in result
assert tags.Tag("cp3_11", "abi3", "any") in result
assert tags.Tag("cp3_11", "none", "any") in result
assert tags.Tag("cp311", "cp311", "any") in result
assert tags.Tag("cp311", "abi3", "any") in result
assert tags.Tag("cp311", "none", "any") in result

def test_platforms_defaults(self, monkeypatch):
monkeypatch.setattr(tags, "_platform_tags", lambda: ["plat1"])
Expand All @@ -919,7 +919,7 @@ def test_platforms_defaults(self, monkeypatch):
def test_platforms_defaults_needs_underscore(self, monkeypatch):
monkeypatch.setattr(tags, "_platform_tags", lambda: ["plat1"])
result = list(tags.cpython_tags((3, 11), abis=["whatever"]))
assert tags.Tag("cp3_11", "whatever", "plat1") in result
assert tags.Tag("cp311", "whatever", "plat1") in result

def test_major_only_python_version(self):
result = list(tags.cpython_tags((3,), ["abi"], ["plat"]))
Expand Down Expand Up @@ -1057,14 +1057,14 @@ def test_all_args(self):
]

def test_all_args_needs_underscore(self):
result = list(tags.compatible_tags((3, 11), "cp3_11", ["plat1", "plat2"]))
result = list(tags.compatible_tags((3, 11), "cp311", ["plat1", "plat2"]))
assert result == [
tags.Tag("py3_11", "none", "plat1"),
tags.Tag("py3_11", "none", "plat2"),
tags.Tag("py311", "none", "plat1"),
tags.Tag("py311", "none", "plat2"),
tags.Tag("py3", "none", "plat1"),
tags.Tag("py3", "none", "plat2"),
tags.Tag("py3_10", "none", "plat1"),
tags.Tag("py3_10", "none", "plat2"),
tags.Tag("py310", "none", "plat1"),
tags.Tag("py310", "none", "plat2"),
tags.Tag("py39", "none", "plat1"),
tags.Tag("py39", "none", "plat2"),
tags.Tag("py38", "none", "plat1"),
Expand All @@ -1085,10 +1085,10 @@ def test_all_args_needs_underscore(self):
tags.Tag("py31", "none", "plat2"),
tags.Tag("py30", "none", "plat1"),
tags.Tag("py30", "none", "plat2"),
tags.Tag("cp3_11", "none", "any"),
tags.Tag("py3_11", "none", "any"),
tags.Tag("cp311", "none", "any"),
tags.Tag("py311", "none", "any"),
tags.Tag("py3", "none", "any"),
tags.Tag("py3_10", "none", "any"),
tags.Tag("py310", "none", "any"),
tags.Tag("py39", "none", "any"),
tags.Tag("py38", "none", "any"),
tags.Tag("py37", "none", "any"),
Expand Down Expand Up @@ -1124,11 +1124,11 @@ def test_default_python_version(self, monkeypatch):

def test_default_python_version_needs_underscore(self, monkeypatch):
monkeypatch.setattr(sys, "version_info", (3, 11))
result = list(tags.compatible_tags(interpreter="cp3_11", platforms=["plat"]))
result = list(tags.compatible_tags(interpreter="cp311", platforms=["plat"]))
assert result == [
tags.Tag("py3_11", "none", "plat"),
tags.Tag("py311", "none", "plat"),
tags.Tag("py3", "none", "plat"),
tags.Tag("py3_10", "none", "plat"),
tags.Tag("py310", "none", "plat"),
tags.Tag("py39", "none", "plat"),
tags.Tag("py38", "none", "plat"),
tags.Tag("py37", "none", "plat"),
Expand All @@ -1139,10 +1139,10 @@ def test_default_python_version_needs_underscore(self, monkeypatch):
tags.Tag("py32", "none", "plat"),
tags.Tag("py31", "none", "plat"),
tags.Tag("py30", "none", "plat"),
tags.Tag("cp3_11", "none", "any"),
tags.Tag("py3_11", "none", "any"),
tags.Tag("cp311", "none", "any"),
tags.Tag("py311", "none", "any"),
tags.Tag("py3", "none", "any"),
tags.Tag("py3_10", "none", "any"),
tags.Tag("py310", "none", "any"),
tags.Tag("py39", "none", "any"),
tags.Tag("py38", "none", "any"),
tags.Tag("py37", "none", "any"),
Expand Down