setup-cfg-fmt
setup-cfg-fmt copied to clipboard
`python_requires` not written when only `--min-py3-version` is specified
See repro:
def test_guess_python_min_version(tmpdir):
setup_cfg = tmpdir.join('setup.cfg')
setup_cfg.write(
'[metadata]\n'
'name = pkg\n'
'version = 1.0\n',
)
assert main((str(setup_cfg), '--min-py3-version=3.8'))
$ pytest -vvv -k test_guess_python_min_version tests/setup_cfg_fmt_test.py
========================================= test session starts ==========================================
platform darwin -- Python 3.9.15, pytest-6.2.4, py-1.10.0, pluggy-0.13.1 -- /Users/mxr/src/mxr/unkey/venv/bin/python
cachedir: .pytest_cache
rootdir: /Users/mxr/src/asottile/setup-cfg-fmt
collected 67 items / 66 deselected / 1 selected
tests/setup_cfg_fmt_test.py::test_guess_python_min_version FAILED [100%]
=============================================== FAILURES ===============================================
____________________________________ test_guess_python_min_version _____________________________________
tmpdir = local('/private/var/folders/mg/2_7nx7493qg0vn9jhdp951tw0000gp/T/pytest-of-mxr/pytest-10/test_guess_python_min_version0')
def test_guess_python_min_version(tmpdir):
setup_cfg = tmpdir.join('setup.cfg')
setup_cfg.write(
'[metadata]\n'
'name = pkg\n'
'version = 1.0\n',
)
> assert main((str(setup_cfg), '--min-py3-version=3.8'))
E AssertionError: assert 0
E + where 0 = main(('/private/var/folders/mg/2_7nx7493qg0vn9jhdp951tw0000gp/T/pytest-of-mxr/pytest-10/test_guess_python_min_version0/setup.cfg', '--min-py3-version=3.8'))
tests/setup_cfg_fmt_test.py:667: AssertionError
======================================= short test summary info ========================================
FAILED tests/setup_cfg_fmt_test.py::test_guess_python_min_version - AssertionError: assert 0
=================================== 1 failed, 66 deselected in 0.17s ===================================
probably worth fixing -- I think this can be fixed with a None
check after trying tox and classifiers and if an explicit minimum version is passed then use that (otherwise do nothing)
The behavior repros when --min-py3-version
is not passed too and a default is used for min_py3_version
. So should the fix change the parsing code to determine when absolutely nothing is passed in, or could the fix just set python_requires
to whatever the minimum is after ingesting all sources (tox envlist, python_requires in setup.cfg, min_py3_version flag, etc)?
yeah probably should do it for the default too -- I guess there'd then be no way to avoid python_requires
being set by setup-cfg-fmt
-- but I think that's a good thing (everything should set it always)
Going to try to get a PR for this out this week
Working on this and the behavior I'm writing is "set python_requires to whatever the minimum is after ingesting all sources (tox envlist, python_requires in setup.cfg, min_py3_version flag, etc)" but I wanted to confirm if this is really the desired behavior. For example the test test_min_version_removes_classifiers
would not longer rewrite python_requires
, classifiers, etc to be >=3.4
because >=3.2
is already in python_requires
. Is that what you want?
Perhaps the right behavior is: if min_py3_version
is passed in, use that to determine the min, otherwise, try to guess the min based on all the other sources. That has the convenient behavior of being able to drop/support python versions in the setup.cfg metadata by simply changing the min_py3_version
flag
yeah the latter probably makes more sense
So I realized from the test_min_py3_version_updates_python_requires
test that min_py3_version
should only override python_requires
when py27 is not supported in python_requires
, which makes the implementation more complicated. Wdyt about min_py3_version
being the floor for python_requires
even if py27 is listed? (Effectively changing it to min_py_version
)
I'm fine killing python 2 support if it's easy -- actually probably about time
sg