Repository navigation
fix: read exclude and non-cap from configuration files as lists - #411
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When
excludeornon-capcomes fromsetup.cfgortox.ini, configparser returns a string, and that string becomes the argparse default as-is.find_py_files()then loops over it character by character, so almost every path matches. For example, withdocformatter --check --recursive .checks nothing and exits 0. The same happens with the bracketed form used in the existingsetup.cfgtests (exclude = ["src/", "tests/"]) and with a string value inpyproject.toml.non-caphas the same problem; there it turns into a substring check.I couldn't find an issue for this. #276 touched the same code but was closed without merging.
Changes
Configurater._do_get_list_option()now builds the defaults for--excludeand--non-cap:["build", "dist"]is parsed withast.literal_eval.build,build distand one name per line all work, the same asnargs="*"on the command line.flargskeeps the raw values, so the existing tests are unaffected.Tests
New
TestListOptionsFromConfigFileintests/test_configuration_functions.py, 11 tests:setup.cfg/tox.iniwith bracketed, single, space-separated and multi-line valuespyproject.tomlwith a string and an array--check --recursiverun withexclude = buildOn current master 10 of them fail (the TOML array case already worked); with the fix all 11 pass.
Testing
Windows 10, Python 3.11:
/tmp, and the failure is the Windows-onlypreserve_line_endingcase./tmpfixtures,test_exclude_from_setup_cfgandtest_non_cap_from_setup_cfgdidn't run here. I checked those configs by hand and they now produce lists.configuration.py.