Skip to content
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

gh-74690: Avoid a costly type check where possible in _ProtocolMeta.__subclasscheck__ #112717

Merged
merged 3 commits into from
Dec 4, 2023

Conversation

AlexWaygood
Copy link
Member

@AlexWaygood AlexWaygood commented Dec 4, 2023

This speeds up issubclass(int, typing.SupportsIndex) by around 6%.

The approach is to move the code around a bit so that we delegate the type-checking to type.__subclasscheck__ wherever possible; type.__subclasscheck__ can do it faster. We now only check from _ProtocolMeta.__subclasscheck__ whether other is an instance of type if we know we're about to raise an exception anyway, and we want the issubclass() arg 2 must be a type message to take priority over the other error message we could potentially give the user.

Copy link
Contributor

@barneygale barneygale left a comment

Choose a reason for hiding this comment

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

Looks good! Is it important that the "issubclass() arg 1 must be a class" error message takes precedence over the others? It's not obvious to me that it should, but I'm not very familiar with this code.

@AlexWaygood
Copy link
Member Author

AlexWaygood commented Dec 4, 2023

Thanks for the review! :D

Looks good! Is it important that the "issubclass() arg 1 must be a class" error message takes precedence over the others? It's not obvious to me that it should, but I'm not very familiar with this code.

Yeah, so to clarify, with the type checks, this is the behaviour we get with this PR branch:

Python 3.13.0a2+ (heads/main:9560e0d6d7, Dec  4 2023, 13:50:58) [MSC v.1932 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import typing as t
>>> @t.runtime_checkable
... class Foo(t.Protocol):
...     X = 1
...
>>> issubclass("not a class", Foo)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
    issubclass("not a class", Foo)
    ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\alexw\coding\fast-cpython\Lib\typing.py", line 1842, in __subclasscheck__
    _type_check_subclasscheck_second_arg(other)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^
  File "C:\Users\alexw\coding\fast-cpython\Lib\typing.py", line 1796, in _type_check_subclasscheck_second_arg
    raise TypeError('issubclass() arg 1 must be a class')
TypeError: issubclass() arg 1 must be a class

But without the type checks, we'd get this behaviour instead:

>>> import typing as t
>>> @t.runtime_checkable
... class Foo(t.Protocol):
...     X = 1
...
>>> issubclass("not a class", Foo)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
    issubclass("not a class", Foo)
    ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\alexw\coding\fast-cpython\Lib\typing.py", line 1847, in __subclasscheck__
    raise TypeError(
    ...<2 lines>...
    )
TypeError: Protocols with non-method members don't support issubclass(). Non-method members: 'X'.

It wouldn't be the worst thing in the world if we had that error message instead. But the fact that Foo has non-method members is clearly not the most significant problem with this person's code! So I definitely prefer to prioritise the "issubclass() arg 1 must be a class" message, if possible :)

@AlexWaygood
Copy link
Member Author

I added a docstring in 3c7eb19 -- does that make things a bit clearer? :)

@barneygale
Copy link
Contributor

It does indeed! Thank you.

@AlexWaygood AlexWaygood enabled auto-merge (squash) December 4, 2023 18:59
Lib/typing.py Outdated Show resolved Hide resolved
@AlexWaygood AlexWaygood merged commit 2ed20d3 into python:main Dec 4, 2023
29 checks passed
@AlexWaygood AlexWaygood deleted the protocolmeta-subclasscheck branch December 4, 2023 19:35
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Feb 26, 2024
Release 4.10.0 (February 24, 2024)

This feature release adds support for PEP 728 (TypedDict with extra
items) and PEP 742 (``TypeIs``).

There are no changes since 4.10.0rc1.

Release 4.10.0rc1 (February 17, 2024)

- Add support for PEP 728, supporting the `closed` keyword argument and the
  special `__extra_items__` key for TypedDict. Patch by Zixuan James Li.
- Add support for PEP 742, adding `typing_extensions.TypeIs`. Patch
  by Jelle Zijlstra.
- Drop runtime error when a read-only `TypedDict` item overrides a mutable
  one. Type checkers should still flag this as an error. Patch by Jelle
  Zijlstra.
- Speedup `issubclass()` checks against simple runtime-checkable protocols by
  around 6% (backporting python/cpython#112717, by Alex
  Waygood).
- Fix a regression in the implementation of protocols where `typing.Protocol`
  classes that were not marked as `@runtime_checkable` would be unnecessarily
  introspected, potentially causing exceptions to be raised if the protocol had
  problematic members. Patch by Alex Waygood, backporting
  python/cpython#113401.
halstead pushed a commit to yoctoproject/poky that referenced this pull request Feb 28, 2024
Changelog:
============
-Add support for PEP 728, supporting the closed keyword argument and the special
 __extra_items__ key for TypedDict.
-Add support for PEP 742, adding typing_extensions.TypeIs.
-Drop runtime error when a read-only TypedDict item overrides a mutable one.
 Type checkers should still flag this as an error.
-Speedup issubclass() checks against simple runtime-checkable protocols by
 around 6% (backporting python/cpython#112717
-Fix a regression in the implementation of protocols where typing.Protocol
 classes that were not marked as @runtime_checkable would be unnecessarily
 introspected, potentially causing exceptions to be raised if the protocol had
 problematic members.

(From OE-Core rev: 0a1b1a2eefa66ff5d8eb12085d3ecfed0eff7ac1)

Signed-off-by: Wang Mingyu <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
halstead pushed a commit to openembedded/openembedded-core that referenced this pull request Feb 28, 2024
Changelog:
============
-Add support for PEP 728, supporting the closed keyword argument and the special
 __extra_items__ key for TypedDict.
-Add support for PEP 742, adding typing_extensions.TypeIs.
-Drop runtime error when a read-only TypedDict item overrides a mutable one.
 Type checkers should still flag this as an error.
-Speedup issubclass() checks against simple runtime-checkable protocols by
 around 6% (backporting python/cpython#112717
-Fix a regression in the implementation of protocols where typing.Protocol
 classes that were not marked as @runtime_checkable would be unnecessarily
 introspected, potentially causing exceptions to be raised if the protocol had
 problematic members.

Signed-off-by: Wang Mingyu <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
halstead pushed a commit to yoctoproject/poky that referenced this pull request Feb 28, 2024
Changelog:
============
-Add support for PEP 728, supporting the closed keyword argument and the special
 __extra_items__ key for TypedDict.
-Add support for PEP 742, adding typing_extensions.TypeIs.
-Drop runtime error when a read-only TypedDict item overrides a mutable one.
 Type checkers should still flag this as an error.
-Speedup issubclass() checks against simple runtime-checkable protocols by
 around 6% (backporting python/cpython#112717
-Fix a regression in the implementation of protocols where typing.Protocol
 classes that were not marked as @runtime_checkable would be unnecessarily
 introspected, potentially causing exceptions to be raised if the protocol had
 problematic members.

(From OE-Core rev: 0a1b1a2eefa66ff5d8eb12085d3ecfed0eff7ac1)

Signed-off-by: Wang Mingyu <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
halstead pushed a commit to yoctoproject/poky that referenced this pull request Feb 28, 2024
Changelog:
============
-Add support for PEP 728, supporting the closed keyword argument and the special
 __extra_items__ key for TypedDict.
-Add support for PEP 742, adding typing_extensions.TypeIs.
-Drop runtime error when a read-only TypedDict item overrides a mutable one.
 Type checkers should still flag this as an error.
-Speedup issubclass() checks against simple runtime-checkable protocols by
 around 6% (backporting python/cpython#112717
-Fix a regression in the implementation of protocols where typing.Protocol
 classes that were not marked as @runtime_checkable would be unnecessarily
 introspected, potentially causing exceptions to be raised if the protocol had
 problematic members.

(From OE-Core rev: 2fee4e85e88bea2ac7c42a1c93a3049258a47c45)

Signed-off-by: Wang Mingyu <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
halstead pushed a commit to openembedded/openembedded-core that referenced this pull request Feb 28, 2024
Changelog:
============
-Add support for PEP 728, supporting the closed keyword argument and the special
 __extra_items__ key for TypedDict.
-Add support for PEP 742, adding typing_extensions.TypeIs.
-Drop runtime error when a read-only TypedDict item overrides a mutable one.
 Type checkers should still flag this as an error.
-Speedup issubclass() checks against simple runtime-checkable protocols by
 around 6% (backporting python/cpython#112717
-Fix a regression in the implementation of protocols where typing.Protocol
 classes that were not marked as @runtime_checkable would be unnecessarily
 introspected, potentially causing exceptions to be raised if the protocol had
 problematic members.

Signed-off-by: Wang Mingyu <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
halstead pushed a commit to yoctoproject/poky that referenced this pull request Feb 28, 2024
Changelog:
============
-Add support for PEP 728, supporting the closed keyword argument and the special
 __extra_items__ key for TypedDict.
-Add support for PEP 742, adding typing_extensions.TypeIs.
-Drop runtime error when a read-only TypedDict item overrides a mutable one.
 Type checkers should still flag this as an error.
-Speedup issubclass() checks against simple runtime-checkable protocols by
 around 6% (backporting python/cpython#112717
-Fix a regression in the implementation of protocols where typing.Protocol
 classes that were not marked as @runtime_checkable would be unnecessarily
 introspected, potentially causing exceptions to be raised if the protocol had
 problematic members.

(From OE-Core rev: 2fee4e85e88bea2ac7c42a1c93a3049258a47c45)

Signed-off-by: Wang Mingyu <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
halstead pushed a commit to yoctoproject/poky that referenced this pull request Feb 28, 2024
Changelog:
============
-Add support for PEP 728, supporting the closed keyword argument and the special
 __extra_items__ key for TypedDict.
-Add support for PEP 742, adding typing_extensions.TypeIs.
-Drop runtime error when a read-only TypedDict item overrides a mutable one.
 Type checkers should still flag this as an error.
-Speedup issubclass() checks against simple runtime-checkable protocols by
 around 6% (backporting python/cpython#112717
-Fix a regression in the implementation of protocols where typing.Protocol
 classes that were not marked as @runtime_checkable would be unnecessarily
 introspected, potentially causing exceptions to be raised if the protocol had
 problematic members.

(From OE-Core rev: 5b138eb2bf420f1dc81db76b2eb7d74fd88c0c29)

Signed-off-by: Wang Mingyu <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
halstead pushed a commit to openembedded/openembedded-core that referenced this pull request Feb 28, 2024
Changelog:
============
-Add support for PEP 728, supporting the closed keyword argument and the special
 __extra_items__ key for TypedDict.
-Add support for PEP 742, adding typing_extensions.TypeIs.
-Drop runtime error when a read-only TypedDict item overrides a mutable one.
 Type checkers should still flag this as an error.
-Speedup issubclass() checks against simple runtime-checkable protocols by
 around 6% (backporting python/cpython#112717
-Fix a regression in the implementation of protocols where typing.Protocol
 classes that were not marked as @runtime_checkable would be unnecessarily
 introspected, potentially causing exceptions to be raised if the protocol had
 problematic members.

Signed-off-by: Wang Mingyu <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
halstead pushed a commit to yoctoproject/poky that referenced this pull request Feb 28, 2024
Changelog:
============
-Add support for PEP 728, supporting the closed keyword argument and the special
 __extra_items__ key for TypedDict.
-Add support for PEP 742, adding typing_extensions.TypeIs.
-Drop runtime error when a read-only TypedDict item overrides a mutable one.
 Type checkers should still flag this as an error.
-Speedup issubclass() checks against simple runtime-checkable protocols by
 around 6% (backporting python/cpython#112717
-Fix a regression in the implementation of protocols where typing.Protocol
 classes that were not marked as @runtime_checkable would be unnecessarily
 introspected, potentially causing exceptions to be raised if the protocol had
 problematic members.

(From OE-Core rev: 5b138eb2bf420f1dc81db76b2eb7d74fd88c0c29)

Signed-off-by: Wang Mingyu <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
halstead pushed a commit to yoctoproject/poky that referenced this pull request Feb 28, 2024
Changelog:
============
-Add support for PEP 728, supporting the closed keyword argument and the special
 __extra_items__ key for TypedDict.
-Add support for PEP 742, adding typing_extensions.TypeIs.
-Drop runtime error when a read-only TypedDict item overrides a mutable one.
 Type checkers should still flag this as an error.
-Speedup issubclass() checks against simple runtime-checkable protocols by
 around 6% (backporting python/cpython#112717
-Fix a regression in the implementation of protocols where typing.Protocol
 classes that were not marked as @runtime_checkable would be unnecessarily
 introspected, potentially causing exceptions to be raised if the protocol had
 problematic members.

(From OE-Core rev: 5b138eb2bf420f1dc81db76b2eb7d74fd88c0c29)

Signed-off-by: Wang Mingyu <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
halstead pushed a commit to yoctoproject/poky that referenced this pull request Feb 28, 2024
Changelog:
============
-Add support for PEP 728, supporting the closed keyword argument and the special
 __extra_items__ key for TypedDict.
-Add support for PEP 742, adding typing_extensions.TypeIs.
-Drop runtime error when a read-only TypedDict item overrides a mutable one.
 Type checkers should still flag this as an error.
-Speedup issubclass() checks against simple runtime-checkable protocols by
 around 6% (backporting python/cpython#112717
-Fix a regression in the implementation of protocols where typing.Protocol
 classes that were not marked as @runtime_checkable would be unnecessarily
 introspected, potentially causing exceptions to be raised if the protocol had
 problematic members.

(From OE-Core rev: 955ab06da61db7393ad54a87e5f2536f0dae3cf2)

Signed-off-by: Wang Mingyu <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
halstead pushed a commit to openembedded/openembedded-core that referenced this pull request Feb 28, 2024
Changelog:
============
-Add support for PEP 728, supporting the closed keyword argument and the special
 __extra_items__ key for TypedDict.
-Add support for PEP 742, adding typing_extensions.TypeIs.
-Drop runtime error when a read-only TypedDict item overrides a mutable one.
 Type checkers should still flag this as an error.
-Speedup issubclass() checks against simple runtime-checkable protocols by
 around 6% (backporting python/cpython#112717
-Fix a regression in the implementation of protocols where typing.Protocol
 classes that were not marked as @runtime_checkable would be unnecessarily
 introspected, potentially causing exceptions to be raised if the protocol had
 problematic members.

Signed-off-by: Wang Mingyu <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
halstead pushed a commit to yoctoproject/poky that referenced this pull request Feb 28, 2024
Changelog:
============
-Add support for PEP 728, supporting the closed keyword argument and the special
 __extra_items__ key for TypedDict.
-Add support for PEP 742, adding typing_extensions.TypeIs.
-Drop runtime error when a read-only TypedDict item overrides a mutable one.
 Type checkers should still flag this as an error.
-Speedup issubclass() checks against simple runtime-checkable protocols by
 around 6% (backporting python/cpython#112717
-Fix a regression in the implementation of protocols where typing.Protocol
 classes that were not marked as @runtime_checkable would be unnecessarily
 introspected, potentially causing exceptions to be raised if the protocol had
 problematic members.

(From OE-Core rev: 955ab06da61db7393ad54a87e5f2536f0dae3cf2)

Signed-off-by: Wang Mingyu <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
halstead pushed a commit to yoctoproject/poky that referenced this pull request Feb 28, 2024
Changelog:
============
-Add support for PEP 728, supporting the closed keyword argument and the special
 __extra_items__ key for TypedDict.
-Add support for PEP 742, adding typing_extensions.TypeIs.
-Drop runtime error when a read-only TypedDict item overrides a mutable one.
 Type checkers should still flag this as an error.
-Speedup issubclass() checks against simple runtime-checkable protocols by
 around 6% (backporting python/cpython#112717
-Fix a regression in the implementation of protocols where typing.Protocol
 classes that were not marked as @runtime_checkable would be unnecessarily
 introspected, potentially causing exceptions to be raised if the protocol had
 problematic members.

(From OE-Core rev: 955ab06da61db7393ad54a87e5f2536f0dae3cf2)

Signed-off-by: Wang Mingyu <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
halstead pushed a commit to yoctoproject/poky that referenced this pull request Feb 28, 2024
Changelog:
============
-Add support for PEP 728, supporting the closed keyword argument and the special
 __extra_items__ key for TypedDict.
-Add support for PEP 742, adding typing_extensions.TypeIs.
-Drop runtime error when a read-only TypedDict item overrides a mutable one.
 Type checkers should still flag this as an error.
-Speedup issubclass() checks against simple runtime-checkable protocols by
 around 6% (backporting python/cpython#112717
-Fix a regression in the implementation of protocols where typing.Protocol
 classes that were not marked as @runtime_checkable would be unnecessarily
 introspected, potentially causing exceptions to be raised if the protocol had
 problematic members.

(From OE-Core rev: 955ab06da61db7393ad54a87e5f2536f0dae3cf2)

Signed-off-by: Wang Mingyu <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
halstead pushed a commit to yoctoproject/poky that referenced this pull request Feb 29, 2024
Changelog:
============
-Add support for PEP 728, supporting the closed keyword argument and the special
 __extra_items__ key for TypedDict.
-Add support for PEP 742, adding typing_extensions.TypeIs.
-Drop runtime error when a read-only TypedDict item overrides a mutable one.
 Type checkers should still flag this as an error.
-Speedup issubclass() checks against simple runtime-checkable protocols by
 around 6% (backporting python/cpython#112717
-Fix a regression in the implementation of protocols where typing.Protocol
 classes that were not marked as @runtime_checkable would be unnecessarily
 introspected, potentially causing exceptions to be raised if the protocol had
 problematic members.

(From OE-Core rev: 91dd6f2878bcdbb6f9ba65927f6c6f981b0b3f1a)

Signed-off-by: Wang Mingyu <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
halstead pushed a commit to openembedded/openembedded-core that referenced this pull request Feb 29, 2024
Changelog:
============
-Add support for PEP 728, supporting the closed keyword argument and the special
 __extra_items__ key for TypedDict.
-Add support for PEP 742, adding typing_extensions.TypeIs.
-Drop runtime error when a read-only TypedDict item overrides a mutable one.
 Type checkers should still flag this as an error.
-Speedup issubclass() checks against simple runtime-checkable protocols by
 around 6% (backporting python/cpython#112717
-Fix a regression in the implementation of protocols where typing.Protocol
 classes that were not marked as @runtime_checkable would be unnecessarily
 introspected, potentially causing exceptions to be raised if the protocol had
 problematic members.

Signed-off-by: Wang Mingyu <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
halstead pushed a commit to yoctoproject/poky that referenced this pull request Feb 29, 2024
Changelog:
============
-Add support for PEP 728, supporting the closed keyword argument and the special
 __extra_items__ key for TypedDict.
-Add support for PEP 742, adding typing_extensions.TypeIs.
-Drop runtime error when a read-only TypedDict item overrides a mutable one.
 Type checkers should still flag this as an error.
-Speedup issubclass() checks against simple runtime-checkable protocols by
 around 6% (backporting python/cpython#112717
-Fix a regression in the implementation of protocols where typing.Protocol
 classes that were not marked as @runtime_checkable would be unnecessarily
 introspected, potentially causing exceptions to be raised if the protocol had
 problematic members.

(From OE-Core rev: 91dd6f2878bcdbb6f9ba65927f6c6f981b0b3f1a)

Signed-off-by: Wang Mingyu <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
halstead pushed a commit to yoctoproject/poky that referenced this pull request Feb 29, 2024
Changelog:
============
-Add support for PEP 728, supporting the closed keyword argument and the special
 __extra_items__ key for TypedDict.
-Add support for PEP 742, adding typing_extensions.TypeIs.
-Drop runtime error when a read-only TypedDict item overrides a mutable one.
 Type checkers should still flag this as an error.
-Speedup issubclass() checks against simple runtime-checkable protocols by
 around 6% (backporting python/cpython#112717
-Fix a regression in the implementation of protocols where typing.Protocol
 classes that were not marked as @runtime_checkable would be unnecessarily
 introspected, potentially causing exceptions to be raised if the protocol had
 problematic members.

(From OE-Core rev: 91dd6f2878bcdbb6f9ba65927f6c6f981b0b3f1a)

Signed-off-by: Wang Mingyu <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
halstead pushed a commit to yoctoproject/poky that referenced this pull request Feb 29, 2024
Changelog:
============
-Add support for PEP 728, supporting the closed keyword argument and the special
 __extra_items__ key for TypedDict.
-Add support for PEP 742, adding typing_extensions.TypeIs.
-Drop runtime error when a read-only TypedDict item overrides a mutable one.
 Type checkers should still flag this as an error.
-Speedup issubclass() checks against simple runtime-checkable protocols by
 around 6% (backporting python/cpython#112717
-Fix a regression in the implementation of protocols where typing.Protocol
 classes that were not marked as @runtime_checkable would be unnecessarily
 introspected, potentially causing exceptions to be raised if the protocol had
 problematic members.

(From OE-Core rev: 91dd6f2878bcdbb6f9ba65927f6c6f981b0b3f1a)

Signed-off-by: Wang Mingyu <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
halstead pushed a commit to yoctoproject/poky that referenced this pull request Feb 29, 2024
Changelog:
============
-Add support for PEP 728, supporting the closed keyword argument and the special
 __extra_items__ key for TypedDict.
-Add support for PEP 742, adding typing_extensions.TypeIs.
-Drop runtime error when a read-only TypedDict item overrides a mutable one.
 Type checkers should still flag this as an error.
-Speedup issubclass() checks against simple runtime-checkable protocols by
 around 6% (backporting python/cpython#112717
-Fix a regression in the implementation of protocols where typing.Protocol
 classes that were not marked as @runtime_checkable would be unnecessarily
 introspected, potentially causing exceptions to be raised if the protocol had
 problematic members.

(From OE-Core rev: 91dd6f2878bcdbb6f9ba65927f6c6f981b0b3f1a)

Signed-off-by: Wang Mingyu <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
halstead pushed a commit to yoctoproject/poky that referenced this pull request Feb 29, 2024
Changelog:
============
-Add support for PEP 728, supporting the closed keyword argument and the special
 __extra_items__ key for TypedDict.
-Add support for PEP 742, adding typing_extensions.TypeIs.
-Drop runtime error when a read-only TypedDict item overrides a mutable one.
 Type checkers should still flag this as an error.
-Speedup issubclass() checks against simple runtime-checkable protocols by
 around 6% (backporting python/cpython#112717
-Fix a regression in the implementation of protocols where typing.Protocol
 classes that were not marked as @runtime_checkable would be unnecessarily
 introspected, potentially causing exceptions to be raised if the protocol had
 problematic members.

(From OE-Core rev: 91dd6f2878bcdbb6f9ba65927f6c6f981b0b3f1a)

Signed-off-by: Wang Mingyu <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
halstead pushed a commit to yoctoproject/poky that referenced this pull request Mar 1, 2024
Changelog:
============
-Add support for PEP 728, supporting the closed keyword argument and the special
 __extra_items__ key for TypedDict.
-Add support for PEP 742, adding typing_extensions.TypeIs.
-Drop runtime error when a read-only TypedDict item overrides a mutable one.
 Type checkers should still flag this as an error.
-Speedup issubclass() checks against simple runtime-checkable protocols by
 around 6% (backporting python/cpython#112717
-Fix a regression in the implementation of protocols where typing.Protocol
 classes that were not marked as @runtime_checkable would be unnecessarily
 introspected, potentially causing exceptions to be raised if the protocol had
 problematic members.

(From OE-Core rev: 91dd6f2878bcdbb6f9ba65927f6c6f981b0b3f1a)

Signed-off-by: Wang Mingyu <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
daregit pushed a commit to daregit/yocto-combined that referenced this pull request May 22, 2024
Changelog:
============
-Add support for PEP 728, supporting the closed keyword argument and the special
 __extra_items__ key for TypedDict.
-Add support for PEP 742, adding typing_extensions.TypeIs.
-Drop runtime error when a read-only TypedDict item overrides a mutable one.
 Type checkers should still flag this as an error.
-Speedup issubclass() checks against simple runtime-checkable protocols by
 around 6% (backporting python/cpython#112717
-Fix a regression in the implementation of protocols where typing.Protocol
 classes that were not marked as @runtime_checkable would be unnecessarily
 introspected, potentially causing exceptions to be raised if the protocol had
 problematic members.

(From OE-Core rev: 91dd6f2878bcdbb6f9ba65927f6c6f981b0b3f1a)

Signed-off-by: Wang Mingyu <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Performance or resource usage topic-typing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants