Sync recent typing and typing_extensions updates#3070
Sync recent typing and typing_extensions updates#3070ilevkivskyi merged 5 commits intopython:masterfrom
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 |
| 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.
Why not write it as runtime = runtime_checkable?
There was a problem hiding this comment.
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.
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.
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, andTypedDicttotyping(typing_extensionsstill defines or re-exports them)@typing.runtimeto@typing.runtime_checkable, while keeping@runtimeas a backwards-compatible alias intyping_extensions.Note this might need a mypy sync (if some mypy tests fail).
cc @gvanrossum