Skip to content

Improve protocols documentation#14577

Merged
hauntsaninja merged 3 commits intopython:masterfrom
hauntsaninja:docs3
Feb 2, 2023
Merged

Improve protocols documentation#14577
hauntsaninja merged 3 commits intopython:masterfrom
hauntsaninja:docs3

Conversation

@hauntsaninja
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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 and others added 2 commits February 2, 2023 12:09
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
@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