Add note to PEP-746 about raising NotImplementedError (#3822)

This commit is contained in:
Adrian Garcia Badaracco 2024-06-05 18:21:31 -05:00 committed by GitHub
parent 35940faeb0
commit 46e2cf7169
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 0 deletions

View File

@ -89,6 +89,13 @@ For example, to support a generic ``Gt`` metadata, one might write::
Implementations may be generic and may use overloads that return ``Literal[True]`` or ``Literal[False]``
to indicate if the metadata is valid for the given type.
Implementations may raise a NotImplementedError if they cannot determine if the metadata is valid for the given type.
Tools calling ``__supports_type__`` at runtime should catch this exception and treat it as if ``__supports_type__``
was not present; they should not take this as an indication that the metadata is invalid for the type.
Tools that use the metadata at runtime may choose to ignore the implementation of ``__supports_type__``; this PEP does not
specify how the method should be used at runtime, only that it may be available for use.
Backwards Compatibility
=======================