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

Set MYPY_CONFIG_FILE_DIR environment variable #7968

Closed
blueyed opened this issue Nov 18, 2019 · 8 comments · Fixed by #9403 or #9414
Closed

Set MYPY_CONFIG_FILE_DIR environment variable #7968

blueyed opened this issue Nov 18, 2019 · 8 comments · Fixed by #9403 or #9414

Comments

@blueyed
Copy link
Contributor

blueyed commented Nov 18, 2019

In addition to / as an alternative to #7967 mypy could set an environment variable of the config file being used.

This could be used with e.g. mypy_path then (mypy_path = $MYPY_CONFIGFILE/src), and also with defaults like cache_dir.

@JukkaL
Copy link
Collaborator

JukkaL commented Nov 19, 2019

I like this better than #7967, since this preserves backward compatibility. My proposal for the name of the variable is MYPY_CONFIG_FILE_DIR.

@blueyed blueyed changed the title Set MYPY_CONFIGFILE environment variable Set MYPY_CONFIG_FILE_DIR environment variable Nov 19, 2019
@mridullpandey
Copy link

hi @blueyed i want work on it will you please elaborate it

@blueyed
Copy link
Contributor Author

blueyed commented Feb 23, 2020

@mridullpandey
What is unclear here?
It should set MYPY_CONFIG_FILE_DIR in os.environ, so that it can be expanded / is available while parsing the config.

@blueyed
Copy link
Contributor Author

blueyed commented Feb 24, 2020

btw: I think $MYPY_CONFIG_FILE(_PATH) might be more flexible: it would provide the actual file (which might be mypy.ini, setup.cfg etc), and could also be used as $MYPY_CONFIG_FILE/../… to have its directory then.
While $MYPY_CONFIG_FILE_DIR might be more explicit, we might end up with adding $MYPY_CONFIG_FILE_PATH additionally afterwards.

@JukkaL
Copy link
Collaborator

JukkaL commented Feb 28, 2020

@blueyed Do you have a use case for using the path to the config file, instead of the directory where it's located? Using .. after a path to a file looks odd to me (though it's not hard to support), and I'd rather avoid it.

@mridullpandey Config file parsing is implemented in mypy.config_parser. In particular, expand_path seems relevant.

@blueyed
Copy link
Contributor Author

blueyed commented Feb 28, 2020

@JukkaL
Not really, but thought about it when adding PYTEST_CONFIG_{FILE,DIR} to pytest, and figured it might be more flexible, since you cannot determine the ini file being used from the dir (due to different names).
As for pytest I've thought that processes/tests being run by pytest then might be able to get the used config file location, but have not thought much about a use case.

$file/.. is a bit weird, but gets resolved fine via os.path.{normpath,realpath}.

So I am +0 myself on using the file - mainly to avoid having to add another env var later, and given that it is more explicit/precise. But it has the downside of having to append "/.." for the more typical use case (this issue).

@joybh98
Copy link
Contributor

joybh98 commented Mar 7, 2020

i'm taking this issue

@gvanrossum
Copy link
Member

PR was reverted (it broke CI).

@gvanrossum gvanrossum reopened this Sep 4, 2020
gvanrossum added a commit that referenced this issue Sep 4, 2020
Let's see what it will take to make CI pass.

Resubmit of #9403.

Fixes #7968.

Co-authored-by: blueyed
gvanrossum added a commit that referenced this issue Sep 4, 2020
… try)

Let's see what it will take to make CI pass.

Resubmit of #9403.

Fixes #7968.

Co-authored-by: blueyed
gvanrossum added a commit that referenced this issue Sep 4, 2020
… try)

Let's see what it will take to make CI pass.

Resubmit of #9403.

Fixes #7968.

Co-authored-by: aghast <[email protected]>
gvanrossum added a commit that referenced this issue Sep 4, 2020
… try) (#9414)

(This fixes the mistake I introduced in the previous version.)

Resubmit of #9403.

Fixes #7968.

Co-authored-by: aghast <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment