ABCInfo

class app.util.helpers.abc_info.ABCInfo[source]

Bases: NamedTuple

Detailed information about a collection ABC or concrete collection type.

Inheritance diagram of ABCInfo

Inheritance Diagram for ABCInfo

Methods

create(abc)

Construct ABCInfo directly from an ABC instance.

matches(abc)

Return whether the info is compatible with the supplied ABC(s).

Attributes

abc

Return the primary ABC associated with this info entry.

abcs

Return all ABCs satisfied by source.

container

Return True if the collection satisfies collections.abc.Container.

generator

Return True if the collection satisfies collections.abc.Generator.

has_key

Return True when the collection describes explicit key types.

has_value

Return True when the collection exposes a derived value type.

hashable

Return True if the collection satisfies collections.abc.Hashable.

iterable

Return True if the collection satisfies collections.abc.Iterable.

iterator

Return True if the collection satisfies collections.abc.Iterator.

key_concrete

Return True when the key type is a concrete type and not a type variable or forward reference.

key_origin

Return the origin type for the declared key if one exists.

key_type

Concrete or generic alias describing the key type if applicable.

lookup

Lookup metadata describing the ABC hierarchy and possible bases.

mapping

Return True for mapping-like collections.

mutable

Return True when the collection advertises mutable semantics.

sequence

Return True for sequence-like collections.

set

Return True for set-like collections.

source

Source runtime type or generic alias inspected for ABC details.

source_origin

Return the non-aliased origin for source.

specialized

Return True when the collection is specialised with value types.

str_or_bytes

Return True if the collection is either str or bytes.

value_concrete

Return True when the value type is a concrete type and not a type variable or forward reference.

value_origin

Return the origin type for the declared value if one exists.

value_type

Concrete or generic alias describing the value type if applicable.

static __new__(_cls, source: type | GenericAlias, lookup: ABCLookupInfo, key_type: type | GenericAlias | ForwardRef | None, value_type: type | GenericAlias | ForwardRef | None)

Create new instance of ABCInfo(source, lookup, key_type, value_type)

Parameters:
  • source (type | GenericAlias)

  • lookup (ABCLookupInfo)

  • key_type (type | GenericAlias | ForwardRef | None)

  • value_type (type | GenericAlias | ForwardRef | None)

property abc: type[ABCType]

Return the primary ABC associated with this info entry.

property abcs: tuple[type[ABCType], ...]

Return all ABCs satisfied by source.

property container: bool

Return True if the collection satisfies collections.abc.Container.

classmethod create(abc: ABCType) ABCInfo[source]

Construct ABCInfo directly from an ABC instance.

Parameters:

abc (ABCType)

Return type:

ABCInfo

property generator: bool

Return True if the collection satisfies collections.abc.Generator.

property has_key: bool

Return True when the collection describes explicit key types.

property has_value: bool

Return True when the collection exposes a derived value type.

property hashable: bool

Return True if the collection satisfies collections.abc.Hashable.

property iterable: bool

Return True if the collection satisfies collections.abc.Iterable.

property iterator: bool

Return True if the collection satisfies collections.abc.Iterator.

property key_concrete: bool

Return True when the key type is a concrete type and not a type variable or forward reference.

property key_origin: type | None

Return the origin type for the declared key if one exists.

key_type: type | GenericAlias | ForwardRef | None

Concrete or generic alias describing the key type if applicable.

lookup: ABCLookupInfo

Lookup metadata describing the ABC hierarchy and possible bases.

property mapping: bool

Return True for mapping-like collections.

matches(abc: type[ABCType] | tuple[ABCType, ...]) bool[source]

Return whether the info is compatible with the supplied ABC(s).

Parameters:

abc (type[ABCType] | tuple[ABCType, ...])

Return type:

bool

property mutable: bool

Return True when the collection advertises mutable semantics.

property sequence: bool

Return True for sequence-like collections.

property set: bool

Return True for set-like collections.

source: type | GenericAlias

Source runtime type or generic alias inspected for ABC details.

property source_origin: type

Return the non-aliased origin for source.

property specialized: bool

Return True when the collection is specialised with value types.

property str_or_bytes: bool

Return True if the collection is either str or bytes.

property value_concrete: bool

Return True when the value type is a concrete type and not a type variable or forward reference.

property value_origin: type | None

Return the origin type for the declared value if one exists.

value_type: type | GenericAlias | ForwardRef | None

Concrete or generic alias describing the value type if applicable.