-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Allow a module to be imported with no __init__.py(i) file in its path #2261
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
Conversation
Isn't this incompatible with CPython itself? |
I removed the error case from |
@kirbyfan64 In Python 2, it's a requirement to have Mypy runs in Python 3 mode by default, right, and I can see the flag (-py2) if a user explicitly asks for it, right? |
It's PEP 420. It's Python 3.3+ only, so the PR should at least contain a new version check somewhere. Also, PEP 420 changes the way the search path is used for namespace packages, so this PR still doesn't implement it properly. Even though this is indeed accepted in Python 3 I'm still pretty concerned about adding support for this to mypy. For example, this would seem to break the functionality of crawl_up() in mypy/main.py, which determines the proper directory to add the the search path by crawling up from a source file until it finds a directory that doesn't contain an I'd much rather see a compromise where mypy continues not to support PEP 420 namespace packages but you can work around it by dropping an empty |
Hmm, so is the recommended approach to add |
I suppose a flag is a possibility. I do think you're in a small minority
for not using `__init__.py` files.
|
Huh -- I would assume more people would stop using Anyway, if this is a relatively minor thing (as in most people don't wouldn't have a use for it) and the accepted solution is to use |
Closing for now. If you want to do the command line flag thing feel free to submit a new PR (you can even reopen this one). |
This change allows a user to import a module without the explicit need for an
__init__.py(i)
in the paths. For example, it a user wants to do the following:they now don't need to add an
__init__.py(i)
file into/project/app
.