Add note to PEP-746 about raising NotImplementedError (#3822)
This commit is contained in:
parent
35940faeb0
commit
46e2cf7169
|
@ -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
|
||||
=======================
|
||||
|
||||
|
|
Loading…
Reference in New Issue