-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add modules and packages keys to config #9891
Conversation
This adds configuration file support for specifying packages and modules. I tried to preserve existing semantics between the config file and command line. If the command line specifies anything, it overrides the config file, if the config file contains both package/module and files keys, the later key is ignored. Also add tests and basic docs for the new keys.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, this fixes an inconsistency in the features supported by the command line vs. the config file.
Overall looks good, just a few nits. Thanks for also updating the docs!
mypy/config_parser.py
Outdated
@@ -278,6 +280,13 @@ def parse_section(prefix: str, template: Options, | |||
if 'follow_imports' not in results: | |||
results['follow_imports'] = 'error' | |||
results[options_key] = v | |||
if key in ('files', 'packages', 'modules'): | |||
if all(('packages' in results.keys() or 'modules' in results.keys(), | |||
results.get('files'))): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style nit: This was a bit difficult to understand. I think it would better to use and
instead of all()
, and you can just use 'packages' in results
, without using keys()
, I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fair. I started with something that generated a list and tested it and didn't refactor it out as far as I should have. Fixed.
mypy/config_parser.py
Outdated
if key in ('files', 'packages', 'modules'): | ||
if all(('packages' in results.keys() or 'modules' in results.keys(), | ||
results.get('files'))): | ||
print("May only specify one of: module/package, files, or command. Ignoring key.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does 'command' here refer to?
Please include the name of the key in the error message. Currently it may not be clear what is being ignored.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, and I'll remove command, that's part of the corresponding CLI error message that I preserved but doesn't apply here.
Addresses comments, adds new test to ensure that the key order is honored as documented and error message presents keys correctly.
Anything further here? I'd be happy to make other tweaks if necessary. |
Thanks for working on this, it looks like this was superseded by #13404 |
Description
Fixes #9883
This adds configuration file support for specifying packages and
modules. I tried to preserve existing semantics between the config file
and command line. If the command line specifies anything, it overrides
the config file, if the config file contains both package/module and
files keys, the later key is ignored.
Test Plan
Added a new version of the package and module command line test that retrieves the values from the configuration file.