ParameterInfo

class app.util.helpers.generics.ParameterInfo[source]

Bases: NamedTuple

Metadata describing a generic type parameter for a class or alias.

Inheritance diagram of ParameterInfo

Inheritance Diagram for ParameterInfo

Methods

get_argument()

Return the raw argument bound to this parameter for the originating class.

get_argument_info()

Return the currently bound argument metadata for this parameter.

narrow(target_cls, param)

Resolve arbitrary parameter identifiers into a concrete ParameterInfo.

Attributes

bound

Return the evaluated bound of the underlying TypeVar or TypeAlias if present.

known

Return True if this parameter was declared on the originating class.

name

Return the parameter name derived from the underlying TypeVar.

owner

The originating generic class or alias where the parameter was declared.

owner_origin

Return the typing origin for the originating class or alias.

position

Zero-based position of the parameter within the generic declaration.

raw_value

The declared TypeVar for the parameter, if known.

value

Return the evaluated value currently bound to the parameter.

static __new__(_cls, position: int, raw_value: TypeVar | TypeAliasType | None, owner: type | GenericAlias)

Create new instance of ParameterInfo(position, raw_value, owner)

Parameters:
property bound: BoundType

Return the evaluated bound of the underlying TypeVar or TypeAlias if present.

get_argument() ArgType[source]

Return the raw argument bound to this parameter for the originating class.

Return type:

ArgType

get_argument_info() ArgumentInfo[source]

Return the currently bound argument metadata for this parameter.

Return type:

ArgumentInfo

property known: bool

Return True if this parameter was declared on the originating class.

property name: str

Return the parameter name derived from the underlying TypeVar.

classmethod narrow(target_cls: ConcreteArgType, param: ParamType) ParameterInfo[source]

Resolve arbitrary parameter identifiers into a concrete ParameterInfo.

Raises:

GenericsError – If param is not declared on target_cls.

Parameters:
  • target_cls (ConcreteArgType)

  • param (ParamType)

Return type:

ParameterInfo

owner: type | GenericAlias

The originating generic class or alias where the parameter was declared.

property owner_origin: type

Return the typing origin for the originating class or alias.

position: int

Zero-based position of the parameter within the generic declaration.

raw_value: TypeVar | TypeAliasType | None

The declared TypeVar for the parameter, if known.

property value: ArgType

Return the evaluated value currently bound to the parameter.