-
Notifications
You must be signed in to change notification settings - Fork 428
Add imports of int values to .pyi files #225
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
Conversation
A statement like `from .local import THING` in `current.py` makes `THING` available in the current module, but this also acts as ani export (i.e. `current.THING` is defined). As of version 0.930 of mypy, the `stubtest` checker wants to see a type definition for such things, when they are ints or strings. Add the equivalent `from .local import THING` statements into the .pyi stub files, so `stubtest` can see the associated type definition. For autogenerated `*data/__init__.pyi` files, this involves a change to the metadata generation tool. Also: - Fix asyoutypeformatter.py to import `REGION_CODE_FOR_NON_GEO_ENTITY` from `phonemetadata` (the definition) rather than `phonenumberutil` (a re-export). - Rename local loop variables to start with an underscore in (autogenerator for) `*data/__init__.py` so they don't look like things that should be exported. - Drop version pin (==0.921) for mypy. Fixes #224.
from .alt_format_255 import PHONE_ALT_FORMAT_255 | ||
from .alt_format_27 import PHONE_ALT_FORMAT_27 | ||
from .alt_format_30 import PHONE_ALT_FORMAT_30 | ||
from .alt_format_31 import PHONE_ALT_FORMAT_31 | ||
from .alt_format_34 import PHONE_ALT_FORMAT_34 | ||
from .alt_format_350 import PHONE_ALT_FORMAT_350 | ||
from .alt_format_351 import PHONE_ALT_FORMAT_351 | ||
from .alt_format_352 import PHONE_ALT_FORMAT_352 | ||
from .alt_format_358 import PHONE_ALT_FORMAT_358 | ||
from .alt_format_359 import PHONE_ALT_FORMAT_359 | ||
from .alt_format_36 import PHONE_ALT_FORMAT_36 | ||
from .alt_format_372 import PHONE_ALT_FORMAT_372 | ||
from .alt_format_373 import PHONE_ALT_FORMAT_373 | ||
from .alt_format_380 import PHONE_ALT_FORMAT_380 | ||
from .alt_format_381 import PHONE_ALT_FORMAT_381 | ||
from .alt_format_385 import PHONE_ALT_FORMAT_385 | ||
from .alt_format_39 import PHONE_ALT_FORMAT_39 | ||
from .alt_format_43 import PHONE_ALT_FORMAT_43 | ||
from .alt_format_44 import PHONE_ALT_FORMAT_44 | ||
from .alt_format_49 import PHONE_ALT_FORMAT_49 | ||
from .alt_format_505 import PHONE_ALT_FORMAT_505 | ||
from .alt_format_506 import PHONE_ALT_FORMAT_506 | ||
from .alt_format_52 import PHONE_ALT_FORMAT_52 | ||
from .alt_format_54 import PHONE_ALT_FORMAT_54 | ||
from .alt_format_55 import PHONE_ALT_FORMAT_55 | ||
from .alt_format_58 import PHONE_ALT_FORMAT_58 | ||
from .alt_format_595 import PHONE_ALT_FORMAT_595 | ||
from .alt_format_61 import PHONE_ALT_FORMAT_61 | ||
from .alt_format_62 import PHONE_ALT_FORMAT_62 | ||
from .alt_format_64 import PHONE_ALT_FORMAT_64 | ||
from .alt_format_66 import PHONE_ALT_FORMAT_66 | ||
from .alt_format_675 import PHONE_ALT_FORMAT_675 | ||
from .alt_format_676 import PHONE_ALT_FORMAT_676 | ||
from .alt_format_679 import PHONE_ALT_FORMAT_679 | ||
from .alt_format_7 import PHONE_ALT_FORMAT_7 | ||
from .alt_format_81 import PHONE_ALT_FORMAT_81 | ||
from .alt_format_84 import PHONE_ALT_FORMAT_84 | ||
from .alt_format_855 import PHONE_ALT_FORMAT_855 | ||
from .alt_format_856 import PHONE_ALT_FORMAT_856 | ||
from .alt_format_90 import PHONE_ALT_FORMAT_90 | ||
from .alt_format_91 import PHONE_ALT_FORMAT_91 | ||
from .alt_format_94 import PHONE_ALT_FORMAT_94 | ||
from .alt_format_95 import PHONE_ALT_FORMAT_95 | ||
from .alt_format_971 import PHONE_ALT_FORMAT_971 | ||
from .alt_format_972 import PHONE_ALT_FORMAT_972 | ||
from .alt_format_995 import PHONE_ALT_FORMAT_995 |
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 didn't include these on the original types PR as I thought it'd mean you need to go all the way and add per-file typing -- brilliant that it seems to work!
(Sorry also for causing the extra work here, perhaps I cut some corners in the original work!)
A
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.
No, I don't think any corners were cut – it's just that the latest mypy
behaves differently from previous versions when checking relative imports of ints/strings from submodules: python/mypy#11843.
Copying across the relevant imports from .py to .pyi files seems to make things work again…
A statement like
from .local import THING
incurrent.py
makesTHING
available in the current module, but this also acts as aniexport (i.e.
current.THING
is defined).As of version 0.930 of mypy, the
stubtest
checker wants to see atype definition for such things, when they are ints or strings.
Add the equivalent
from .local import THING
statements into the.pyi stub files, so
stubtest
can see the associated type definition.For autogenerated
*data/__init__.pyi
files, this involves a change tothe metadata generation tool.
Also:
REGION_CODE_FOR_NON_GEO_ENTITY
from
phonemetadata
(the definition) rather thanphonenumberutil
(a re-export).
(autogenerator for)
*data/__init__.py
so they don't look likethings that should be exported.
mypy
version pin #224.