-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Alternative extension for stubs #345
Comments
Sounds reasonable. This would have a secondary benefit of making it easy avoid accidentally importing a module stub as a real module. A minor issue is that default syntax highlighting in editors would not work for the stub files. I'd probably prefer an extension with just a single dot. It also needs to be something that is not in use (it should not be used by cython, etc.). .pys seems to be used in Windows (or was). Maybe .pyi, where i stands for an interface definition? Have you thought about how this would work exactly? Maybe go through all directories in the search path, and for each directory, first look for a file with the new extension and then for a file with the normal .py extension. |
Pyi seems to have been taken. http://www.filesuffix.com/en/extension/pyi As for getting it to work, I imagine it'd be best to emulate python's import scheme (which would involve going through all the directories in the search path). I believe the resolution you described should work. |
Not sure about .mypy, since these would be used for just a subset of files. .pyi was used by Cognos, but apparently more recent versions use .pyj (8.x was released around 2009, based on some Googling), so I doubt there much room for confusion: PYI file is a Cognos Model File. Cognos is a world leader in Business Intelligence solutions that improve and direct corporate performance. In Cognos Transformer version 8.x, models saved in binary format now use the .pyj file extension. In Transformer version 7.x, models saved in binary format used the .pyi file extension. |
.pyi sounds good. Is build.py the only module that needs to be touched to implement this? |
Yes, I think only build.py needs to be touched. |
Upped priority, as this is blocking #346. |
This is now implemented, but we aren't going to change std lib stub extension to .pyi, at least for now. .pyi is just an alternative extension for stubs, which can be handy because Python VMs ignore these files. If both a .pyi and a .py file exists in the same directory, .pyi takes precedence. Quote from me, from the discussion related to the above pull request (I should also mention that @gvanrossum was against changing the default extension):
Another potential use case is making local changes to a mypy stub and using it with the .pyi extension. |
In addition to looking for for python files in the stubs folder or specified by MYPYPATH, it'd be nice to a alternative extension .py.s or something that signified it's a stub for the matching module.
This would be particularly nice for python2.x support since one could define .py and .py.s or have mypy compile to both (like typescript -> javascript)
This would have a similar goal as #25
The text was updated successfully, but these errors were encountered: