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 packages spread over multiple directories via __path__ manipulation #1456

Closed
JukkaL opened this issue Apr 29, 2016 · 4 comments
Closed

Comments

@JukkaL
Copy link
Collaborator

JukkaL commented Apr 29, 2016

It's possible to manipulate __path__ in packages to let a package span multiple directories. For example, some files of package p.q can be in x/p/q and remaining files are in y/p/q. It's difficult to detect this automatically, but we could support a special entry in MYPYPATH for this:

export MYPYPATH=package(p.q,x,y)

(I'm working on some internal Dropbox code that uses this idiom.)

Any positive number of directories can be included. By including a single directory, it's possible to only pick a particular module/package from a site packages directory. This can be useful for third party modules that are annotated and don't have stubs in typeshed. Including the entire site packages directory in MYPYPATH would likely result in mypy getting very confused, as most of the code would probably not be mypy compatible. Example:

export MYPYPATH=package(mypackage,/path/site-packages)

Spaces around entries within package(...) should be stripped.

This is followup to #1422 and based on an offline discussion we had a while back.

@emmatyping
Copy link
Collaborator

Is this as necessary once #4403 is completed?

@JukkaL
Copy link
Collaborator Author

JukkaL commented Jan 29, 2020

This doesn't seem important any more.

@JukkaL JukkaL closed this as completed Jan 29, 2020
@AudriusButkevicius
Copy link

What does "important anymore" mean?
Is this supported, will not be supported, is there a way around this?

@JelleZijlstra
Copy link
Member

I'm guessing Jukka initially brought this up because some internal Dropbox code used the idiom, and that code was eventually cleaned up. Mypy is unlikely to add support for highly dynamic patterns like manual manipulation of the __path__ property absent a very compelling use case.

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

No branches or pull requests

4 participants