Annotations#
register_annotations#
- tkclasswiz.annotations.register_annotations(cls: type, mapping: dict | None = {}, **annotations)#
Extends original annotations of
cls.This can be useful eg. when the class your are adding is not part of your code and is also not annotated.
Classes that already have additional annotations:
datetime.timedelta
datetime.datetime
datetime.timezone
- Parameters:
Example
from datetime import timedelta, timezone register_annotations( timezone, offset=timedelta, name=str )
get_annotations#
- tkclasswiz.annotations.get_annotations(class_) dict#
Returns class / function annotations including the ones extended with
register_annotations. It does not return the return annotation.Additionally, this function resolves any generic types to their parameterized types, but only for classes, functions don’t support this yet as support for generics on functions was added in Python 3.12.