On this page
  1. typing.get_protocol_members
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

typing.get_protocol_members

Prev: typing.get_overloads | Up: typing | Next: typing.get_type_hints
Rel: typing.AbstractSet, typing.Annotated, typing.Any, typing.assert_never
Ref: docs.python.org — typing.get_protocol_members
Tags: #public #python3 #stdlib #typing


Import

import typing
from typing import get_protocol_members

Signature & Overview

typing.get_protocol_members(tp: type, /) -> frozenset[str]

Return the set of members defined in a Protocol.

Usage

from typing import Protocol, get_protocol_members

class SizedLike(Protocol):
    def __len__(self) -> int: ...

assert get_protocol_members(SizedLike) == frozenset({"__len__"})

Gotchas

REPL Inspect

from typing import get_protocol_members
help(get_protocol_members)

Linked from

Related notes