File tree Expand file tree Collapse file tree
src/check_python_versions/sources Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,7 +4,10 @@ Changelog
440.24.1 (unreleased)
55-------------------
66
7- - Nothing changed yet.
7+ - Improve tox environment name parsing: accept dotted names (e.g. py3.14),
8+ more specific pypy versions (pypy311). `GH #38
9+ <https://github.com/mgedmin/check-python-versions/issues/38> `_ and `GH #50
10+ <https://github.com/mgedmin/check-python-versions/issues/50> `_.
811
912
10130.24.0 (2025-11-13)
Original file line number Diff line number Diff line change @@ -101,14 +101,18 @@ def tox_env_to_py_version(env: str) -> Version | None:
101101
102102 If the environment name has dashes, only the first part is considered,
103103 e.g. py34-django20 becomes '3.4', and jython-docs becomes 'jython'.
104+ (This is probably incorrect, I think tox itself allows the Python
105+ factor to be in any position, e.g. orange-py3.11.)
104106 """
105107 if '-' in env :
106108 # e.g. py34-coverage, pypy-subunit
107109 env = env .partition ('-' )[0 ]
108- if env .startswith ('pypy' ):
109- return Version .from_string ('PyPy' + env [4 :])
110- elif env .startswith ('py' ) and len (env ) >= 4 and env [2 :].isdigit ():
111- return Version .from_string (f'{ env [2 ]} .{ env [3 :]} ' )
110+ if env .startswith ('pypy3' ):
111+ return Version .from_string ('PyPy3' )
112+ if env == 'pypy' or env .startswith ('pypy2' ):
113+ return Version .from_string ('PyPy' )
114+ elif m := re .match (r'^py([2-3])[.]?([0-9]+)t?$' , env ):
115+ return Version .from_string (f'{ m [1 ]} .{ m [2 ]} ' )
112116 else :
113117 return None
114118
Original file line number Diff line number Diff line change @@ -91,9 +91,16 @@ def test_brace_expand(s, expected):
9191@pytest .mark .parametrize ('s, expected' , [
9292 ('py36' , '3.6' ),
9393 ('py37-lint' , '3.7' ),
94- ('py310' , '3.10' ), # future-proofness!
94+ ('py3.9' , '3.9' ),
95+ ('py310' , '3.10' ),
96+ ('py3.10' , '3.10' ),
97+ ('py314t' , '3.14' ),
98+ ('py3.14t' , '3.14' ),
9599 ('pypy' , 'PyPy' ),
100+ ('pypy2' , 'PyPy' ),
96101 ('pypy3' , 'PyPy3' ),
102+ ('pypy311' , 'PyPy3' ),
103+ ('pypy3.11' , 'PyPy3' ),
97104 ('pylint' , None ),
98105 ('flake8' , None ),
99106])
You can’t perform that action at this time.
0 commit comments