From 5647192ae1ba08b326fd94504a49a309dbf6a9ad Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Thu, 17 Apr 2025 14:04:49 +0100 Subject: [PATCH] [red-knot] Add `KnownFunction` variants for `is_protocol`, `get_protocol_members` and `runtime_checkable` --- crates/red_knot_python_semantic/src/types.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/crates/red_knot_python_semantic/src/types.rs b/crates/red_knot_python_semantic/src/types.rs index ed0174d27392a..68b849b6713cf 100644 --- a/crates/red_knot_python_semantic/src/types.rs +++ b/crates/red_knot_python_semantic/src/types.rs @@ -5896,6 +5896,12 @@ pub enum KnownFunction { Cast, /// `typing(_extensions).overload` Overload, + /// `typing(_extensions).is_protocol` + IsProtocol, + /// `typing(_extensions).get_protocol_members` + GetProtocolMembers, + /// `typing(_extensions).runtime_checkable` + RuntimeCheckable, /// `abc.abstractmethod` #[strum(serialize = "abstractmethod")] @@ -5957,6 +5963,9 @@ impl KnownFunction { | Self::Overload | Self::RevealType | Self::Final + | Self::IsProtocol + | Self::GetProtocolMembers + | Self::RuntimeCheckable | Self::NoTypeCheck => { matches!(module, KnownModule::Typing | KnownModule::TypingExtensions) } @@ -7195,6 +7204,9 @@ pub(crate) mod tests { | KnownFunction::RevealType | KnownFunction::AssertType | KnownFunction::AssertNever + | KnownFunction::IsProtocol + | KnownFunction::GetProtocolMembers + | KnownFunction::RuntimeCheckable | KnownFunction::NoTypeCheck => KnownModule::TypingExtensions, KnownFunction::IsSingleton