Skip to content

Conversation

hauntsaninja
Copy link
Collaborator

Linking #13681

:py:func:`isinstance` with protocols is not completely safe at runtime.
For example, signatures of methods are not checked. The runtime
implementation only checks that all protocol members are defined.
implementation only checks that all protocol members exist,
Copy link
Member

Choose a reason for hiding this comment

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

It also doesn't check attributes at all, only methods, if I recall correctly. That might be worth mentioning.

Copy link
Member

@ilevkivskyi ilevkivskyi Feb 2, 2023

Choose a reason for hiding this comment

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

isinstance() checks both, but issubclass() checks only methods.

@hauntsaninja hauntsaninja merged commit 7bde0d6 into python:master Feb 2, 2023
@hauntsaninja hauntsaninja deleted the docs3 branch February 2, 2023 20:43
hauntsaninja added a commit that referenced this pull request Feb 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants