typespecs.spec module#

typespecs.spec.ITSELF = <ITSELF>#

Sentinel object specifying metadata-stripped annotation itself.

class typespecs.spec.ItselfType[source]#

Bases: object

Sentinel object specifying metadata-stripped annotation itself.

class typespecs.spec.Spec[source]#

Bases: dict[str, Any]

Type specification.

This class is essentially a dictionary and should be used to distinguish type specification from other type annotations.

replace(old_value: Any, new_value: Any, /) Self[source]#

Replace occurrences of old value with new value.

Parameters:
  • old_value – The value to be replaced.

  • new_value – The value to replace with.

Returns:

Replaced type specification.

typespecs.spec.is_spec(obj: Any, /) TypeGuard[Spec][source]#

Check if given object is a type specification.

Parameters:

obj – Object to inspect.

Returns:

True if the object is a type specification. False otherwise.