Annotations
I finally upgraded Python version on my Debian Trixie to 3.14.
(sidenote: Best number.)
Guess what. __annotations__ on dataclasses are
gone. Generally, annotations recommendations changed (again), which is mildly
infuriating. Now there’s a library to inspect annotations. But it’s not in
inspect module (because inspect.get_annotations() is sooo 3.13), it’s
annotationslib. No. Sorry. Typo. annotationlib. Without “s”.
(sidenote: Psikutas bez “s” na końcu. (Polish joke))
I’ll have to live with this abomination:
def get_annotations(obj) -> dict:
try:
import annotationlib
return annotationlib.get_annotations(obj)
except ImportError:
return obj.__annotations__