-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Support expansion of all path configuration options #7273
Conversation
This commit modifies parsing of all configuration options dealing with paths so that they may be able to expand user home directories and environment variables as per the 'cache_dir' configuration.
c6d6be4
to
f376e57
Compare
mypy/config_parser.py
Outdated
@@ -63,8 +64,9 @@ def split_and_match_files(paths: str) -> List[str]: | |||
'python_version': parse_version, | |||
'strict_optional_whitelist': lambda s: s.split(), | |||
'custom_typing_module': str, | |||
'custom_typeshed_dir': str, | |||
'mypy_path': lambda s: [p.strip() for p in re.split('[,:]', s)], | |||
'custom_typeshed_dir': lambda s: os.path.expandvars(os.path.expanduser(s)), |
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.
How about defining a function that does the two expansions together?
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.
Looks good in general. One code organization request.
Ok, let me know if that's what you had in mind. |
Yeah! |
'custom_typeshed_dir': str, | ||
'mypy_path': lambda s: [p.strip() for p in re.split('[,:]', s)], | ||
'custom_typeshed_dir': expand_path, | ||
'mypy_path': lambda s: [expand_path(p.strip()) for p in re.split('[,:]', s)], | ||
'files': split_and_match_files, | ||
'quickstart_file': str, | ||
'junit_xml': str, |
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.
Would enabling environment variable interpolation for this config key be as simple as this?
'junit_xml': str, | |
'junit_xml': expand_path |
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.
Would enabling environment variable interpolation for this config key be as simple as this?
Yes. Probably should have done this for junit_xml
and quickstart_file
as well.
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.
Alright, I'll include that in my PR #8479
…_file config keys (#8479) Expands on the goal of #7273 Exactly what the title says. The docs say this: > Some flags support user home directory and environment variable expansion. To refer to the user home directory, use ~ at the beginning of the path. To expand environment variables use $VARNAME or ${VARNAME}. This would add `quickstart_file` and `junit_xml` to the flags that support environment variable expansion. The only downside I see here is if someone decides they want their JUnit XML ouput file or quickstart file something weird like `$file`
This closes #7272; all options in the configuration file that deal with paths will be expanded for the user home directory and environment variables.