Add API type definitions through stub files#207
Add API type definitions through stub files#207daviddrysdale merged 35 commits intodaviddrysdale:devfrom
Conversation
daviddrysdale
left a comment
There was a problem hiding this comment.
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
daviddrysdale
left a comment
There was a problem hiding this comment.
A few questions from an initial pass (just looking over the smaller files).
Contents of generated files taken from daviddrysdale#207
daviddrysdale
left a comment
There was a problem hiding this comment.
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.
Are the X as X parts needed?
There was a problem hiding this comment.
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.
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.
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
daviddrysdale
left a comment
There was a problem hiding this comment.
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.pyto 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