Skip to content

Commit fc289c0

Browse files
authored
Fail on mismatched python spec attributes (#2824)
Closes #2754
1 parent af4b558 commit fc289c0

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

docs/changelog/2754.bugfix.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Setting ``[testenv] basepython = python3`` will no longer override the Python interpreter version requested by a factor,
2+
such as ``py311`` - by :user:`stephenfin`.

src/tox/tox_env/python/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def _validate_base_python(env_name: str, base_pythons: list[str], ignore_base_py
154154
if any(
155155
getattr(spec_base, key) != getattr(spec_name, key)
156156
for key in ("implementation", "major", "minor", "micro", "architecture")
157-
if getattr(spec_base, key) is not None and getattr(spec_name, key) is not None
157+
if getattr(spec_name, key) is not None
158158
):
159159
msg = f"env name {env_name} conflicting with base python {base_python}"
160160
if ignore_base_python_conflict:

tests/tox_env/python/test_python_api.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ def test_base_python_env_no_conflict(env: str, base_python: list[str], ignore_co
9595
("py3", ["py2"], ["py2"]),
9696
("py38", ["py39"], ["py39"]),
9797
("py38", ["py38", "py39"], ["py39"]),
98+
("py38", ["python3"], ["python3"]),
9899
("py310", ["py38", "py39"], ["py38", "py39"]),
99100
("py3.11.1", ["py3.11.2"], ["py3.11.2"]),
100101
("py3-64", ["py3-32"], ["py3-32"]),

0 commit comments

Comments
 (0)