fix baseinvocation call to __attribute__ to work with py3.9

This commit is contained in:
Lincoln Stein
2023-08-31 23:11:54 -04:00
parent a74e2108bb
commit 2cb57ef301
9 changed files with 66 additions and 55 deletions

View File

@ -615,7 +615,15 @@ def invocation_output(
config=cls.__config__,
)
cls.__fields__.update({"type": output_type_field})
cls.__annotations__.update({"type": output_type_annotation})
# to support 3.9, 3.10 and 3.11, as described in https://docs.python.org/3/howto/annotations.html
annotations = (
cls.__dict__.get("__annotations__", None)
if isinstance(cls, type)
else getattr(cls, "__annotations__", None)
)
if annotations:
annotations.update({"type": output_type_annotation})
return cls