Min version in envlist, when less than the default value for `min-py3-version`, is overridden
Closed this issue · 4 comments
When setup-cfg-fmt
is run on a library with no arguments and no config except tox.ini
with an envlist
, then the tool uses a minimum version parsed from tox.ini
. For example this test passes:
def test_guess_python_envlist_py38(tmpdir):
tmpdir.join('tox.ini').write('[tox]\nenvlist = py38\n')
setup_cfg = tmpdir.join('setup.cfg')
setup_cfg.write(
'[metadata]\n'
'name = pkg\n'
'version = 1.0\n',
)
assert main((str(setup_cfg), ))
assert setup_cfg.read() == (
'[metadata]\n'
'name = pkg\n'
'version = 1.0\n'
'classifiers =\n'
' Programming Language :: Python :: 3\n'
' Programming Language :: Python :: 3 :: Only\n'
' Programming Language :: Python :: Implementation :: CPython\n'
'\n'
'[options]\n'
'python_requires = >=3.8\n'
)
$ pytest -q -k test_guess_python_envlist_py38 tests\setup_cfg_fmt_test.py
. [100%]
1 passed, 66 deselected in 0.04s
But when envlist
has a lower minimum version (ex: py36
) than the default, then python_requires
gets set to >= 3.7
incorrectly.
def test_guess_python_envlist_py36(tmpdir):
tmpdir.join('tox.ini').write('[tox]\nenvlist = py36\n')
setup_cfg = tmpdir.join('setup.cfg')
setup_cfg.write(
'[metadata]\n'
'name = pkg\n'
'version = 1.0\n',
)
assert main((str(setup_cfg), ))
assert setup_cfg.read() == (
'[metadata]\n'
'name = pkg\n'
'version = 1.0\n'
'classifiers =\n'
' Programming Language :: Python :: 3\n'
' Programming Language :: Python :: 3 :: Only\n'
' Programming Language :: Python :: Implementation :: CPython\n'
'\n'
'[options]\n'
'python_requires = >=3.6.1\n'
)
$ pytest -q -k test_guess_python_envlist_py36 tests\setup_cfg_fmt_test.py
F [100%]
============================================================== FAILURES ==============================================================
___________________________________________________ test_guess_python_envlist_py36 ___________________________________________________
tmpdir = local('C:\\Users\\maxr\\AppData\\Local\\Temp\\pytest-of-maxr\\pytest-20\\test_guess_python_envlist_py360')
def test_guess_python_envlist_py36(tmpdir):
tmpdir.join('tox.ini').write('[tox]\nenvlist = py36\n')
setup_cfg = tmpdir.join('setup.cfg')
setup_cfg.write(
'[metadata]\n'
'name = pkg\n'
'version = 1.0\n',
)
assert main((str(setup_cfg), ))
> assert setup_cfg.read() == (
'[metadata]\n'
'name = pkg\n'
'version = 1.0\n'
'classifiers =\n'
' Programming Language :: Python :: 3\n'
' Programming Language :: Python :: 3 :: Only\n'
' Programming Language :: Python :: Implementation :: CPython\n'
'\n'
'[options]\n'
'python_requires = >=3.6.1\n'
)
E AssertionError: assert '[metadata]\n...res = >=3.7\n' == '[metadata]\n...s = >=3.6.1\n'
E Skipping 225 identical leading characters in diff, use -v to show
E - res = >=3.6.1
E ? ^^^
E + res = >=3.7
E ? ^
tests\setup_cfg_fmt_test.py:639: AssertionError
-------------------------------------------------------- Captured stdout call --------------------------------------------------------
Rewriting C:\Users\maxr\AppData\Local\Temp\pytest-of-maxr\pytest-20\test_guess_python_envlist_py360\setup.cfg
====================================================== short test summary info =======================================================
FAILED tests/setup_cfg_fmt_test.py::test_guess_python_envlist_py36 - AssertionError: assert '[metadata]\n...res = >=3.7\n' == '[metadata]\n...s = >=3.6.1\n'
1 failed, 66 deselected in 0.07s
yeah, setup-cfg-fmt
takes tox
as the source of truth -- that's the only way to make it stable (otherwise it would never update)
a bit unfortunate, but intentional
Hmm but here it's not taking tox as the source of truth when the version in tox is < the default min version of the tool. This is because the check here:
setup-cfg-fmt/setup_cfg_fmt.py
Lines 215 to 216 in aff5adb
can't discern if someone is specifying a min version explicitly or not.
It feels surprising for users of setup-cfg-fmt
to have their own library's min version updated when min-py3-version
's default changes (even if they still want to support an EOL'd Python version) - is that still intentional?
there's a trade off -- if it never decreases the value then the tox value would never get cleaned up
Got it thanks