"Python runtime_checkable: What isinstance Actually Verifies"
"Python runtime_checkable lets you use isinstance() on a typing.Protocol at runtime. Here is exactly what it checks (method names only), what it silently ignores (signatures), and the TypeErrors that trip everyone up."
@runtime_checkable marks a typing.Protocol so isinstance() works on it at runtime. The python runtime_checkable check verifies only that the required method names exist — not signatures, return types, or behavior. Skip the decorator and isinstance() raises TypeError instead of checking anything. Minimal working example A Protocol describes a shape; @runtime_checkable lets you test that shape at runtime. No inheritance required — any class with the right method satisfies it: from typing import Protocol, runtime_checkable @runtime_checkable class Closer(Protocol): def close(self) -> None: ... class File: def close(self) -> None: print("file closed") class Socket: def close(self) -> None: print("socket closed") class Broken: pass print(isinstance(File(), Closer)) # True -- has close() print(isinstance(Socket(), Closer)) # True -- has close(), no inheritance needed print(isinstance(Broken(), Closer)) # False -- no close() This is structural typing at runtime: File and Socket are unrelated classes, yet both pass, because the check cares about shape, not lineage. Static checkers like mypy do the deeper verification at type-check time; @runtime_checkable is the runtime half of the story. Variations Data protocols: isinstance works, issubclass doesn't. A protocol with non-method members (plain attributes) still supports isinstance , but issubclass refuses: @runtime_checkable class Named(Protocol): name: str # a data member, not a method class Service: def __init__(self): self.name = "api" print(isinstance(Service(), Named)) # True issubclass(Service, Named) # TypeError: Protocols with non-method members don't support issubclass() If you need class-level checks, keep your protocols method-only. Forgetting the decorator. Without @runtime_checkable , any runtime check is…