Repository navigation
Add stubs for typing_extensions module #1471
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
Changes from 1 commit
45f6393
b9326df
07a7be4
ccb20c0
ad65237
219cf5c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import sys | ||
| import typing | ||
| from typing import ( | ||
| ClassVar, ContextManager, Counter, DefaultDict, Deque, | ||
| NewType, overload, Text, TYPE_CHECKING, | ||
| ) | ||
|
|
||
| if sys.version_info >= (3, 3): | ||
| from typing import ChainMap | ||
|
|
||
| if sys.version_info >= (3, 5): | ||
| from typing import ( | ||
| AsyncIterable, AsyncIterator, AsyncContextManager, Coroutine, | ||
| ) | ||
|
|
||
| if sys.version_info >= (3, 6): | ||
| from typing import AsyncGenerator | ||
|
|
||
| if sys.version_info >= (3, 6): | ||
| from typing import Collection | ||
| else: | ||
| _T_co = typing.TypeVar('_T_co', covariant=True) | ||
| class Collection(typing.Sized, | ||
| typing.Iterable[_T_co], | ||
| typing.Container[_T_co], | ||
| typing.Generic[_T_co]): | ||
| ... | ||
|
|
||
| # Return type that indicates a function does not return. | ||
| # This type is equivalent to the None type, but the no-op Union is necessary to | ||
| # distinguish the None type from the None value. | ||
| NoReturn = typing.Union[None] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The stubs for typing currently don't define
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, any reason it isn't in
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It could be my fault. I probably just forgot to add the stub when I added
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ...now that I think about it, I have no idea -- it seems like an oversight? I'd prefer keeping that change separate from this PR to keep the git history clean -- I made a separate pull request to add NoReturn and can rebase/fix this one once the other one is merged? (Or vice-versa)
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I merged your other PR, so the comment and this line can now be replaced.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool, I updated this pull request.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @JelleZijlstra Ping -- not sure if you saw my comment up above? |
||
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.
To re-export this name, you need to say
ClassVar as ClassVar(this also goes for the rest of this file).Uh oh!
There was an error while loading. Please reload this page.
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 you sure? The stub seemed to work when I tried using it with mypy -- all the types seemed to be correctly re-exported and I was able to successfully typecheck my test files. Or is there something I'm missing?
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 think mypy doesn't implement that part of PEP 484 correctly.
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.
Huh, you're right! I did not know PEP 484 said that. Fixed.