fitzzftw.patch.current_312_313.FtwProtocolWrap

class FtwProtocolWrap[source]

Bases: object

A metadata wrapper for Python Protocol classes.

This class introspects a given Protocol to extract its structural definition, including type hints, mandatory attributes, and method signatures. It serves as a bridge for documentation or validation tools that need to inspect protocol requirements without interacting with the original class directly.

Attributes:

_name (str): The name of the wrapped protocol. _annotations (dict): Mapping of attribute/method names to their type hint strings. _attributes (set): All members defined as part of the protocol. _non_callable (set): Protocol members that are data attributes. _callable (set): Protocol members that are methods. _signatures (dict): Mapping of method names to their stringified inspect.Signature.

Public Data Attributes:

name

The name of the protocol class (ro).

non_callable

Set of names of all non-method members (ro).

callable

Set of names of all method members (ro).

annotations

Dictionary of member names and their stringified type hints (ro).

attributes

Set of all member names required by the protocol (ro).

signatures

Dictionary mapping method names to their full call signatures (ro).

Public Methods:

__init__([protocol])

Initializes the wrapper.

set_new_protocol(protocol)

Introspects the given protocol and populates all metadata fields.


__init__(protocol=None)[source]

Initializes the wrapper. If a protocol is provided, it is processed immediately.

Parameters:

protocol – The Protocol class to inspect.

property annotations: dict[str, Any]

Dictionary of member names and their stringified type hints (ro).

property attributes: set[str]

Set of all member names required by the protocol (ro).

property callable: set[str]

Set of names of all method members (ro).

property name: str

The name of the protocol class (ro).

property non_callable: set[str]

Set of names of all non-method members (ro).

set_new_protocol(protocol)[source]

Introspects the given protocol and populates all metadata fields.

This method extracts: 1. Type hints for all members. 2. Required protocol attributes via ‘__protocol_attrs__’. 3. Separation of callable (methods) and non-callable (data) members. 4. Signatures for all callable members.

Parameters:

protocol – The Protocol class to wrap.

property signatures: dict[str, str]

Dictionary mapping method names to their full call signatures (ro).