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

MYPYPATH should override mypy_path in config file (not extend it) #17778

Open
jonaslalin opened this issue Sep 18, 2024 · 1 comment
Open

MYPYPATH should override mypy_path in config file (not extend it) #17778

jonaslalin opened this issue Sep 18, 2024 · 1 comment
Labels

Comments

@jonaslalin
Copy link

Feature

The MYPYPATH environment variable should override the mypy_path config file option (not extend it).

Pitch

I propose the ability to override the mypy_path config file option with the the MYPYPATH environment variable. To make Visual Studio Code work with the Mypy extension for namespace packages, it is necessary to set mypy_path and explicit_package_bases, whereas I would like to disable the mypy_path option when running Tox (to typecheck the installed package). It is usually the case that environment variables have higher precedence over config file options, and this change would make Mypy consistent with the expected behavior.

@brianschubert
Copy link

I don’t think it will be possible to change the semantics of MYPYPATH and mypy_path at this point, since many workflows likely rely on the current documented behavior.

We could new options to help support overriding/ignoring mypy_path, but that a) would further complicate how mypy’s search path is defined (which already can be confusing), and b) is arguably redundant, since this can already be done by using separate config files.

I’m a little surprised that you need to set those config options to make the extension work. Maybe there are other configurations you haven’t considered? It sounds like you have the extension set up to use the bundled mypy binary to type check the in-tree sources. Have you tried using the "fromEnvironment" mypy binary to type check the installed package instead?

Also, in case it helps your usecase, do note that the relationship between mypy_path and MYPYPATH is actually the other way around: mypy_path extends MYPYPATH, and is only searched if a match isn’t found in MYPYPATH. In that sense, MYPYPATH already “overrides” mypy_path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants