Skip to content

Add Protocol, runtime_checkable, Final, final, Literal, and TypedDict to typing on Python 2 #648

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

Closed
ilevkivskyi opened this issue Jun 16, 2019 · 0 comments · Fixed by #649
Assignees

Comments

@ilevkivskyi
Copy link
Member

These should be essentially just copied from typing_extensions.

@ilevkivskyi ilevkivskyi self-assigned this Jun 16, 2019
ilevkivskyi added a commit that referenced this issue Jun 16, 2019
Fixes #643

(Use ignore whitespace option to review this, since it mostly just indents a bunch of stuff.)

PR summary:
* Update Travis config to run on a bunch of newer Python versions (including 3.8-dev).
* Only run `typing` tests on Python 3.6 or older, starting from Python 3.7 development of `typing` moved to CPython repo, where it was significantly reworked. We still run `typing_extension` tests on all versions.
* Update `repr()` tests in `typing_extensions` to conditionally expect correct module name.
* Add `TypedDict` to `__all__`.
* Use `Final`, `Literal`, etc. from `typing` if those are available (as we do for other things).
* Rename `@runtime` to `@runtime_checkable` in `typing_extensions` (I think we can keep `@runtime` in `typing_extensions` as an alias for backwards compatibility).

Note this only updates Python 3 version of `typing_extensions`. There will be a corresponding update for the Python 2 version of `typing_extensions` as part of #648
ilevkivskyi added a commit that referenced this issue Jun 17, 2019
…t to typing (#649)

Fixes #648

This essentially just moves a bunch of code and tests from Python 2 version of `typing_extensions` to Python 2 version of `typing`. We don't need to copy the definitions in the former, and can just re-export them from `typing`, since there is not built-in `typing` module on Python 2, so that we can always assume the latest version of `typing` (we will just need to release them in right order, `typing` first, and then update dependency in `typing_extensions`).

Notable changes apart from the code move:
* Like on Python 3, keep `runtime` in `typing_extensions` as an alias for `runtime_checkable` for backwards compatibility (the former is not included in `__all__`)
* Update `GenericMeta.__new__` and `GenericMeta.__getitem__` instead of almost identical overrides in `_ProtocolMeta`.
JelleZijlstra pushed a commit to python/typing_extensions that referenced this issue May 19, 2022
Fixes python/typing#643

(Use ignore whitespace option to review this, since it mostly just indents a bunch of stuff.)

PR summary:
* Update Travis config to run on a bunch of newer Python versions (including 3.8-dev).
* Only run `typing` tests on Python 3.6 or older, starting from Python 3.7 development of `typing` moved to CPython repo, where it was significantly reworked. We still run `typing_extension` tests on all versions.
* Update `repr()` tests in `typing_extensions` to conditionally expect correct module name.
* Add `TypedDict` to `__all__`.
* Use `Final`, `Literal`, etc. from `typing` if those are available (as we do for other things).
* Rename `@runtime` to `@runtime_checkable` in `typing_extensions` (I think we can keep `@runtime` in `typing_extensions` as an alias for backwards compatibility).

Note this only updates Python 3 version of `typing_extensions`. There will be a corresponding update for the Python 2 version of `typing_extensions` as part of python/typing#648
JelleZijlstra pushed a commit to python/typing_extensions that referenced this issue May 19, 2022
…t to typing (#649)

Fixes python/typing#648

This essentially just moves a bunch of code and tests from Python 2 version of `typing_extensions` to Python 2 version of `typing`. We don't need to copy the definitions in the former, and can just re-export them from `typing`, since there is not built-in `typing` module on Python 2, so that we can always assume the latest version of `typing` (we will just need to release them in right order, `typing` first, and then update dependency in `typing_extensions`).

Notable changes apart from the code move:
* Like on Python 3, keep `runtime` in `typing_extensions` as an alias for `runtime_checkable` for backwards compatibility (the former is not included in `__all__`)
* Update `GenericMeta.__new__` and `GenericMeta.__getitem__` instead of almost identical overrides in `_ProtocolMeta`.
JelleZijlstra pushed a commit to python/typing_extensions that referenced this issue May 19, 2022
Fixes python/typing#643

(Use ignore whitespace option to review this, since it mostly just indents a bunch of stuff.)

PR summary:
* Update Travis config to run on a bunch of newer Python versions (including 3.8-dev).
* Only run `typing` tests on Python 3.6 or older, starting from Python 3.7 development of `typing` moved to CPython repo, where it was significantly reworked. We still run `typing_extension` tests on all versions.
* Update `repr()` tests in `typing_extensions` to conditionally expect correct module name.
* Add `TypedDict` to `__all__`.
* Use `Final`, `Literal`, etc. from `typing` if those are available (as we do for other things).
* Rename `@runtime` to `@runtime_checkable` in `typing_extensions` (I think we can keep `@runtime` in `typing_extensions` as an alias for backwards compatibility).

Note this only updates Python 3 version of `typing_extensions`. There will be a corresponding update for the Python 2 version of `typing_extensions` as part of python/typing#648
JelleZijlstra pushed a commit to python/typing_extensions that referenced this issue May 19, 2022
…t to typing (#649)

Fixes python/typing#648

This essentially just moves a bunch of code and tests from Python 2 version of `typing_extensions` to Python 2 version of `typing`. We don't need to copy the definitions in the former, and can just re-export them from `typing`, since there is not built-in `typing` module on Python 2, so that we can always assume the latest version of `typing` (we will just need to release them in right order, `typing` first, and then update dependency in `typing_extensions`).

Notable changes apart from the code move:
* Like on Python 3, keep `runtime` in `typing_extensions` as an alias for `runtime_checkable` for backwards compatibility (the former is not included in `__all__`)
* Update `GenericMeta.__new__` and `GenericMeta.__getitem__` instead of almost identical overrides in `_ProtocolMeta`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant