Skip to content
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

Merged
merged 2 commits into from
Jul 30, 2019

Conversation

hetmankp
Copy link
Contributor

This closes #7272; all options in the configuration file that deal with paths will be expanded for the user home directory and environment variables.

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.
@hetmankp hetmankp force-pushed the topic/config-expand-vars branch from c6d6be4 to f376e57 Compare July 29, 2019 09:34
@msullivan msullivan self-requested a review July 29, 2019 18:36
@@ -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)),
Copy link
Collaborator

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?

Copy link
Collaborator

@msullivan msullivan left a 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.

@hetmankp
Copy link
Contributor Author

Ok, let me know if that's what you had in mind.

@msullivan msullivan merged commit d044c2e into python:master Jul 30, 2019
@msullivan
Copy link
Collaborator

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,
Copy link
Contributor

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?

Suggested change
'junit_xml': str,
'junit_xml': expand_path

Copy link
Contributor Author

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.

Copy link
Contributor

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

ilevkivskyi pushed a commit that referenced this pull request Mar 6, 2020
…_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`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: Do expansion on all path options in configuration
3 participants