-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
PEP: Distributing and Packaging Type Information #415
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just three small comments from me.
pep-0561.rst
Outdated
3. A third party would like to share stub files for a package, but the | ||
maintainer does not want to include them in the source of the package. | ||
|
||
This PEP aims to support these scenarios and make them simple to add to packaging and deploy. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is too long
pep-0561.rst
Outdated
... | ||
) | ||
|
||
Stub Only Packages |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would move this section below the next one so that the order will match the order of three numbered options above.
pep-0561.rst
Outdated
For package maintainers wishing to ship stub files containing all of their | ||
type information, it is prefered that the ``*.pyi`` stubs are alongside the | ||
corresponding ``*.py`` files. However, the stubs may be put in a sub-folder | ||
of the Python sources, th the same name the ``*.py`` files are in. For |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
th the same -> with the same
I think the string is OK |
Thanks for the review @ilevkivskyi! I should have addressed all of your comments. |
Since the PEP is formatted correctly (the tests pass) I have merged it, so you officially have PEP number 461. Time to post to python-ideas! |
Thanks! Though it is 561. I will write up a post for python-ideas now. |
Dang. I can't fix the commit message. :-( |
Well, if you are fast, you can |
No, that didn't work. Oh well.
|
I'd appreciate some clear advice for libraries that support Python 2.7 (--3.6), and want to support type hints in the same package. Our aim is to add another layer of analysis to our CI, but a low-effort and non-breaking way to distribute type hints to users would be great - HypothesisWorks/hypothesis#200 proposes to add stub files alongside the corresponding .py files and then wait for tooling to catch up 😄 In particular, the current draft PEP doesn't specify if this is sufficient, or whether we'll also need to add some metadata to |
@Zac-HD The relevant section on the latest draft https://www.python.org/dev/peps/pep-0561/#stub-only-packages indicates that an additional keyword is required in calls to |
For projects that want to natively offer typing information, shipping As far as packaging tools go, the fact that |
mypy does not currently support this, if the Python files are in
Actually, that is not the main intent of this PEP, it is one of the encouraged changes for sure (and a side effect of the changes proposed in this PEP), but it is not the only change the PEP is trying to bring. And yes, sadly distutils will not be getting the new metadata built in, so I am not sure older versions will get it unless they use setuptools or something else that will add support for it. |
I'm OK with requiring a newish setuptools/pip/whatever to get the type stubs - so long as old tools can still install the code! |
Am I right that |
Yes that is correct. The standard will work on any Python version back to 2.7. |
Perhaps that header should be changed? There's really nothing about the PEP that only applies to 3.7, because it requires no changes to Python itself, only to type checkers. |
If we change features in *typing.py* they only tend to be added to the
latest Python version. Maybe we need some clarification near the top of the
PEP. Can someone volunteer some text?
|
I plan on making a POC implementation of the distutils extension when I have time either later today or tomorrow.
A couple points Im not sure about:
should the keyword be a boolean about whether the package is stubbed or not? Then
stubbed == True
inline == False
andtype unsafe == None
.Mixed inline/stubbed packages - I originally wrote a version with an additional option for this, but it seemed to make things more complicated than needed.