Skip to content

Setting module search path in the config file #2323

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

Closed
JukkaL opened this issue Oct 25, 2016 · 5 comments
Closed

Setting module search path in the config file #2323

JukkaL opened this issue Oct 25, 2016 · 5 comments
Labels

Comments

@JukkaL
Copy link
Collaborator

JukkaL commented Oct 25, 2016

I wonder if we should support configuring the module search path (equivalent to MYPYPATH) in the mypy config file. I have a feeling that this was discussed before, but maybe we can revisit this.

Here's one particular use case I'm thinking about: specifying a directory for custom stubs. For example, I could have a stubs/ subdirectory in my repository for custom stubs that I've written. It seems reasonable to be able to add this directory to the search path automatically so I won't always have to use a script that sets MYPYPATH for running mypy correctly. If I use --silent-imports, a mypy run with accidentally missing search path items will pass without errors and can easily generate false negatives.

@ffigiel
Copy link
Contributor

ffigiel commented Oct 25, 2016

Yes, please. There's too much work with submitting stubs for 3rd party libraries to typeshed.

I managed to side-step this problem by adding ./stubs to MYPYPATH. That said, the config file would be a much more convenient place for this setting.

Here's my use case:

  • I run stubgen foo
  • Remove everything except for the things I use from the stub
  • Commit the stub

@gvanrossum gvanrossum added this to the 0.4.x milestone Oct 25, 2016
@gvanrossum
Copy link
Member

Yes, we should do this.

@megapctr Do you feel up to submitting a PR for this? If not we can try to do it.

@ffigiel
Copy link
Contributor

ffigiel commented Oct 25, 2016

I'm on it 👍

@ddfisher
Copy link
Collaborator

I agree that we want this, but for working on typeshed --custom-typeshed-dir (which should be ready for merge in #1588) should be a bit more convenient.

ddfisher pushed a commit that referenced this issue Oct 28, 2016
* Allow to specify mypy_path in config (#2323)

* Docs on the new stubs_dir config option

* Accept either a colon or a comma in config.mypy_path

* Add a test for mypy_path config setting

* Use os.pathsep instead of a colon

* Use typeshed commit from master

* Avoid cross-platform issues with mypy_path separators
@gvanrossum
Copy link
Member

Closed by #2329.

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

4 participants