-
Notifications
You must be signed in to change notification settings - Fork 244
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
Define conventions for stubs #22
Comments
We should define what stubs are and why we need them. |
Related idea (to avoid needing to use |
Related issue with some discussion about an alternative extension ( |
pytypedecl is a rather mature approach that solves a number of issues by abandoning Python syntax, namely:
As I understand it, stubs are useful for typing existing third-party libraries, builtins and C extensions. Maybe we should prefer to only have one obvious way to do it? (I won't argue for that longer, just wanted to get a definitive answer here.) If we want stubs to be Python, I believe that it should be Python with no tricks. |
Overloading would be solved by having stubs sport a custom syntax. |
Mypy provides an optional, alternative file extension for stubs, but all stubs bundled with mypy still use the I don't like the idea of having a completely different syntax for stubs. There are just a few differences that would be useful to have for stubs, including support for overloading and potentially an implicit Without stubs for standard library modules and third-party modules type checking (and static analysis in general) will not be terribly effective, at least until most third-party modules get migrated to static typing (which will likely take a while, since most of them have to support Python 2). I think that having a standard format for library stubs that is compatible with this PEP would be very useful, if only to discourage every tool maker from designing their own stub format. It doesn't need to happen within this PEP, though. |
Yes.
Regarding the implicit
Or if you really want to use
The assignment flags the desire to export the name. Since stubs are never imported by the "real" Python interpreter (i.e. never used or seen at runtime) we don't need an implementation of this. But for various other reasons, if you do manage to import a stub module, it should in general parse and load without errors. (But using |
I like the assignment proposal, as it's more explicit than the |
Here is a link to the typeshed repo. |
Some additional context: Our intention is to use typeshed to centrally collect stubs for the standard library and 3rd party modules, and we can agree on stub conventions using the typeshed issue tracker. The typeshed repo will likely be moved away from my personal github account (since no individual should own it) -- check the typeshed readme to see if this move has happened already. |
I am assuming we only need to add the |
Tentatively closing as the "as" issue is now in the PEP. |
The PEP should define some conventions for library stubs. Here are some things that might be relevant:
Undefined(...)
exclusively, so that a parser that processes the stubs doesn't need to be able to access comments?__all__
, or should this be implicit? What about visibility of names imported from other modules?stubs
are considered stubs automatically?The text was updated successfully, but these errors were encountered: