fitzzftw.patch.future_314_ge.FtwProtocolWrap¶
fromfitzzftw.patch.future_314_ge
import FtwProtocolWrap
- class FtwProtocolWrap[source]¶
Bases:
objectA 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:
The name of the protocol class (ro).
Set of names of all non-method members (ro).
Set of names of all method members (ro).
Dictionary of member names and their stringified type hints (ro).
Set of all member names required by the protocol (ro).
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.
Private Methods:
_get_type_str(v)Normalizes type objects into human-readable strings using PEP 634 matching.
- __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).
- 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.