-
Notifications
You must be signed in to change notification settings - Fork 113
Open
0 / 10 of 1 issue completedLabels
Protocolstyping semanticstyping-module features, spec compliance, etctyping-module features, spec compliance, etc
Milestone
Description
Subtasks (these do not all need to be completed before the alpha):
- Understand
Protocol
-instance types as a different kind of type to otherInstance
types (structural types vs nominal types) - Implement subtyping and assignability relations between different structural types, and between structural types and nominal types
- Emit errors on invalid
Protocol
class definitions - Emit errors on
isinstance()
andissubclass()
runtime checks againstProtocol
classes that are not decorated with@runtime_checkable
- Experiment with removing existing
Type
variants such asType::AlwaysTruthy
and replacing them withProtocol
types
PRs:
- [red-knot] Initial tests for protocols ruff#17436
- [red-knot] Understand
typing.Protocol
andtyping_extensions.Protocol
as equivalent ruff#17446 - [red-knot] Add
KnownFunction
variants foris_protocol
,get_protocol_members
andruntime_checkable
ruff#17450 - [red-knot] Fix MRO inference for protocol classes; allow inheritance from subscripted
Generic[]
; forbid subclassing unsubscriptedGeneric
ruff#17452 - [red-knot] Correctly identify protocol classes ruff#17487
- [red-knot] Detect (some) invalid protocols ruff#17488
- [red-knot] Move
InstanceType
to its own submodule ruff#17525 - [red-knot] Add more tests for protocol members ruff#17550
- [red-knot] Emit a diagnostic if a non-protocol is passed to
get_protocol_members
ruff#17551 - [red-knot] Infer the members of a protocol class ruff#17556
- [red-knot] Emit diagnostics for isinstance() and issubclass() calls where a non-runtime-checkable protocol is the second argument ruff#17561
- [red-knot] Ban direct instantiations of
Protocol
classes ruff#17597 - [red-knot] Add more tests for protocols ruff#17603
- [red-knot] micro-optimise
ClassLiteral::is_protocol
ruff#17703 - [red-knot] Add a new
Type::ProtocolInstance
variant (take 2!) ruff#17682 - [red-knot] Ban direct instantiation of generic protocols as well as non-generic ones ruff#17741
Sub-issues
Metadata
Metadata
Assignees
Labels
Protocolstyping semanticstyping-module features, spec compliance, etctyping-module features, spec compliance, etc