From 46e2cf7169955e54d80687ab19a7d237f9e02cf3 Mon Sep 17 00:00:00 2001 From: Adrian Garcia Badaracco <1755071+adriangb@users.noreply.github.com> Date: Wed, 5 Jun 2024 18:21:31 -0500 Subject: [PATCH] Add note to PEP-746 about raising NotImplementedError (#3822) --- peps/pep-0746.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/peps/pep-0746.rst b/peps/pep-0746.rst index cfcb290db..cf94f3203 100644 --- a/peps/pep-0746.rst +++ b/peps/pep-0746.rst @@ -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 =======================