-
Notifications
You must be signed in to change notification settings - Fork 417
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
Add API type definitions through stub files #207
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.
Thanks for preparing this!
Just a couple of initial questions, without looking at the .pyi
file details as yet.
I think I made the changes to the right setup.py, I was mildly confused as there's another one at the top level
IIRC that got added (#7) to help out folk who pointed installers at the top-level GitHub URL, which would then fail because the code is in a subdirectory. (I've added #209 as a reminder to sort this out)
Contents of generated files taken from #207
Contents of generated files taken from #207
Contents of generated files taken from #207
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.
A few questions from an initial pass (just looking over the smaller files).
Contents of generated files taken from daviddrysdale#207
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.
Thanks for the updates; a couple more questions as I work through the PR.
@@ -0,0 +1,82 @@ | |||
from .asyoutypeformatter import AsYouTypeFormatter as AsYouTypeFormatter |
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.
Are the X as X
parts needed?
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.
It is required, although looking at the docs it seems it might also be possible to put in __all__
-- though in other stub files I've seen it like this and thought it was the canonical approach
https://mypy.readthedocs.io/en/stable/config_file.html#confval-implicit_reexport (note the last line that implicit re-export is disabled for stubs -- the docs could be written more clearly here on the inverse of explicit re-exports)
from .phonemetadata import NumberFormat as NumberFormat | ||
from .phonemetadata import PhoneMetadata as PhoneMetadata | ||
from .phonemetadata import PhoneNumberDesc as PhoneNumberDesc | ||
from .phonemetadata import REGION_CODE_FOR_NON_GEO_ENTITY as REGION_CODE_FOR_NON_GEO_ENTITY |
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.
Maybe make the layout of the imports match __init__.py
more closely?
Or is this (and the X as X
parts) something tool-derived that's easier to leave as-is?
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.
The from X import Y as Y
was autogenerated, yes -- mypy.stubgen
was able to infer a lot of stuff, but I had to manually correct a lot of types, and all private variables/class variables/functions I had to hand write, as stubgen didn't pick them up.
Contents of generated files taken from daviddrysdale#207
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.
Phew, I've finished looking over the .pyi
files! (I still want to check over the packaging changes btw)
Contents of generated files taken from #207
Given that there is a debian directory in this repo are you responsible for publishing new versions? |
Nope. I included the |
We lock 8.12.44. See daviddrysdale/python-phonenumbers#207
@daviddrysdale
xref #200
closes #202
closes #203
This PR has the stubs, automatic checking of the stubs with
mypy.stubgen
, and changes tosetup.py
to support packaging type stubs (I think I made the changes to the rightsetup.py
, I was mildly confused as there's another one at the top level)A