gh-101688: Implement types.get_original_bases by Gobot1234 · Pull Request #101827 · python/cpython (original) (raw)

Gobot1234

Implements the methods described.

A couple of questions:

@Gobot1234

sobolevn

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@Gobot1234

@Gobot1234

@Gobot1234

@sobolevn

JelleZijlstra

@Gobot1234 Gobot1234 changed the titlegh-101688: Implement typing.get_orig_class and get_orig_bases gh-101688: Implement typing.get_orig_class and types.get_orig_bases

Feb 25, 2023

@Gobot1234

@Gobot1234

@Gobot1234

@Gobot1234

Conflicts:

Lib/test/test_typing.py

@Gobot1234

AlexWaygood

AlexWaygood

@Gobot1234

@Gobot1234 @AlexWaygood

Co-authored-by: Alex Waygood Alex.Waygood@Gmail.com

@AlexWaygood

@gvanrossum, how's this look to you now? Any more suggestions re. the docs?

musashay23

@gvanrossum

Who is musashay? Spammer? Bot?

@AlexWaygood

Who is musashay? Spammer? Bot?

No idea

gvanrossum

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still not excited about the use of assert. Do we do this often in other examples?

@Gobot1234

@AlexWaygood

@AlexWaygood

Still not excited about the use of assert. Do we do this often in other examples?

I feel like the closest stdlib analogues to this function are typing.get_args and typing.get_origin, and it's what we do there:

assert get_origin(Dict[str, int]) is dict
assert get_args(Dict[int, str]) == (int, str)
assert get_origin(Union[int, str]) is Union
assert get_args(Union[int, str]) == (int, str)

gvanrossum

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, sold.

gvanrossum

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant to approve.

@AlexWaygood

@AlexWaygood

@AlexWaygood

I'll merge once the CI finishes.

@AlexWaygood

@Gobot1234, are you up for adding a stub to typeshed and backporting it to typing_extensions? I can probably take a look soon, if you haven't got the time.

@Gobot1234

I can probably do the typeshed stub tonight but I don't know when I'll get to the typing extensions backport

kraj pushed a commit to YoeDistro/poky that referenced this pull request

Jun 1, 2023

@wangmingyu84 @alexandrebelloni

Changelog:

(From OE-Core rev: 2b1d07c7deb4f0247765bc737fb11a1747143edf)

Signed-off-by: Wang Mingyu wangmy@fujitsu.com Signed-off-by: Alexandre Belloni alexandre.belloni@bootlin.com

rpurdie pushed a commit to yoctoproject/poky that referenced this pull request

Jun 2, 2023

@wangmingyu84 @rpurdie

Changelog:

(From OE-Core rev: a37154b9166323d05cca970ebb37bee0d5250893)

Signed-off-by: Wang Mingyu wangmy@fujitsu.com Signed-off-by: Alexandre Belloni alexandre.belloni@bootlin.com Signed-off-by: Richard Purdie richard.purdie@linuxfoundation.org

halstead pushed a commit to openembedded/openembedded-core that referenced this pull request

Jun 2, 2023

@wangmingyu84 @rpurdie

Changelog:

Signed-off-by: Wang Mingyu wangmy@fujitsu.com Signed-off-by: Alexandre Belloni alexandre.belloni@bootlin.com

renovate bot referenced this pull request in allenporter/flux-local

Jun 3, 2023

@renovate

Mend
Renovate](https://renovatebot.com)

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
typing-extensions
(changelog)
==4.5.0 -> ==4.6.3
age](https://docs.renovatebot.com/merge-confidence/)
adoption](https://docs.renovatebot.com/merge-confidence/)
passing](https://docs.renovatebot.com/merge-confidence/)
confidence](https://docs.renovatebot.com/merge-confidence/)

Release Notes

python/typing_extensions

v4.6.3

Compare Source

v4.6.2

Compare Source

v4.6.1

Compare Source

v4.6.0

Compare Source

https://github.com/python/cpython/pull/232943294 https://github.com/python/cpython/pull/23383ll/23383. Both CPython PRs were originally by Yurii Karabas, and both were backported to Python >=3.9.1, but no earlier. Patch by Alex Waygood.

A side effect of one of the changes is that equality comparisons of Literal objects will now raise a TypeError if one of the Literal objects being compared has a mutable parameter. (Using mutable parameters with Literal is not supported by PEP 586 or by any major static type checkers.)

https://github.com/python/cpython/pull/293349334. (The CPython bugfix was backported to CPython 3.10.1 and 3.9.8, but no earlier.)

A side effect of one of the performance improvements is that the members of a runtime-checkable protocol are now considered “frozen” at runtime as soon as the class has been created. Monkey-patching attributes onto a runtime-checkable protocol will still work, but will have no impact on isinstance() checks comparing objects to the protocol. See "What's New in Python 3.12" for more details.

types.get_original_bases, introduced in Python 3.12 (CPythonhttps://github.com/python/cpython/pull/101827l/101827, originally by James Hilton-Balfe). Patch by Alex Waygood.

This function should always produce correct results when called on classes constructed using features from typing_extensions. However, it may produce incorrect results when called on some NamedTuple or TypedDict classes that use typing.{NamedTuple,TypedDict} on Python <=3.11.

https://github.com/python/cpython/pull/1040484048). Patch by Alex Waygood.


Configuration

📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 Automerge: Enabled.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.



This PR has been generated by Mend Renovate. View repository job log here.

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

daregit pushed a commit to daregit/yocto-combined that referenced this pull request

May 22, 2024

@wangmingyu84 @rpurdie

Changelog:

(From OE-Core rev: a37154b9166323d05cca970ebb37bee0d5250893)

Signed-off-by: Wang Mingyu wangmy@fujitsu.com Signed-off-by: Alexandre Belloni alexandre.belloni@bootlin.com Signed-off-by: Richard Purdie richard.purdie@linuxfoundation.org