-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Sync recent typing and typing_extensions updates #3070
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
Sync recent typing and typing_extensions updates #3070
Conversation
It would be unfortunate if this were to fail with the upcoming mypy 0.710 release, so please let me know if anything is needed! |
This will at least need a typeshed sync, I am already working on updating the mypy part (will make a PR later today). |
OK, so the typeshed sync will have to be cherry-picked into the release branch? That makes for very tight timing since I am planning to release this Wednesday. Maybe the release should be delayed? (Then it would be next Monday.) See python/mypy#7009 |
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.
Looks fine to me.
@@ -19,6 +19,8 @@ _F = TypeVar('_F', bound=Callable[..., Any]) | |||
_TC = TypeVar('_TC', bound=Type[object]) | |||
class _SpecialForm: | |||
def __getitem__(self, typeargs: Any) -> Any: ... | |||
def runtime_checkable(cls: _TC) -> _TC: ... | |||
# This is just an alias for above kept for backwards compatibility. |
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.
Why not write it as runtime = runtime_checkable
?
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.
IIRC pytype and/or PyCharm didn't like function aliases in stubs, for example the attrs
entry in https://github.com/python/typeshed/blob/master/tests/pytype_blacklist.txt may be related to this.
@JelleZijlstra If you think it should ne OK, I can update this to use an actual alias.
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 don't recall that being an issue; it may have been fixed. In any case as far as I know other type checkers don't tend to use typing.pyi from typeshed.
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 looks like it was only for overloads https://youtrack.jetbrains.com/issue/PY-27788. I will update now.
This introduces the following updates: * Allow using `typing.TypedDict` (still support all the old forms) * Add a test for `typing.Literal` (it was already supported, but there were no tests) * Rename `@runtime` to `@runtime_checkable`, while keeping the alias in `typing_extensions` for backwards compatibility. (Note that `typing.Final` and `typing.Protocol` were already supported and there are tests.) See also python/typeshed#3070
This introduces the following updates: * Allow using `typing.TypedDict` (still support all the old forms) * Add a test for `typing.Literal` (it was already supported, but there were no tests) * Rename `@runtime` to `@runtime_checkable`, while keeping the alias in `typing_extensions` for backwards compatibility. (Note that `typing.Final` and `typing.Protocol` were already supported and there are tests.) See also python/typeshed#3070
This introduces the following updates: * Allow using `typing.TypedDict` (still support all the old forms) * Add a test for `typing.Literal` (it was already supported, but there were no tests) * Rename `@runtime` to `@runtime_checkable`, while keeping the alias in `typing_extensions` for backwards compatibility. (Note that `typing.Final` and `typing.Protocol` were already supported and there are tests.) See also python/typeshed#3070
This introduces the following updates: * Allow using `typing.TypedDict` (still support all the old forms) * Add a test for `typing.Literal` (it was already supported, but there were no tests) * Rename `@runtime` to `@runtime_checkable`, while keeping the alias in `typing_extensions` for backwards compatibility. (Note that `typing.Final` and `typing.Protocol` were already supported and there are tests.) See also python/typeshed#3070
This includes two things to sync up with recent runtime updates:
Final
,@final
,Literal
, andTypedDict
totyping
(typing_extensions
still defines or re-exports them)@typing.runtime
to@typing.runtime_checkable
, while keeping@runtime
as a backwards-compatible alias intyping_extensions
.Note this might need a mypy sync (if some mypy tests fail).
cc @gvanrossum