# pydoc > typing.Protocol

---
type: CommandReference
command: typing.Protocol
mode: pydoc
section: ''
source: pydoc3
---

## Quick Reference

- `class Proto(Protocol): ...` — define a protocol class
- `class C: def meth(self) -> int: ...` — implement protocol via structural subtyping
- `@typing.runtime_checkable` — make protocol checkable at runtime (attribute presence only)
- `class GenProto(Protocol[T]): ...` — define a generic protocol

## Name

Base class for protocol classes, enabling structural subtyping (static duck-typing) as described in PEP 544.

## Synopsis

python
from typing import Protocol, runtime_checkable, TypeVar

class Proto(Protocol):
    def meth(self) -> int: ...

@runtime_checkable
class CheckableProto(Protocol):
    attr: int

T = TypeVar('T')
class GenProto(Protocol[T]):
    def meth(self) -> T: ...
## Options

- `__init_subclass__(*args, **kwargs)` — called when a class is subclassed; default implementation does nothing
- `__abstractmethods__` — frozenset of abstract method names (empty by default)
- `__parameters__` — tuple of type parameters (empty for non‑generic protocols)

## Examples

python
from typing import Protocol

class Proto(Protocol):
    def meth(self) -> int: ...

class C:
    def meth(self) -> int:
        return 0

def func(x: Proto) -> int:
    return x.meth()

func(C())  # static type check passes

# Generic protocol
from typing import TypeVar
T = TypeVar('T')
class GenProto(Protocol[T]):
    def meth(self) -> T: ...
## See Also

- [PEP 544](https://peps.python.org/pep-0544/) — structural subtyping for static typing
- `typing.runtime_checkable` decorator
- `typing.Generic` — base class for generic types