This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author barisione
Recipients ARF1, barisione, davetapley, dcecile, drhagen, eric.smith, lopek, methane
Date 2022-04-08.08:18:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
This is particularly annoying if you are using `Annotated` with a dataclass.

For instance:
from __future__ import annotations

import dataclasses
from typing import Annotated, get_type_hints

class C:
    v: Annotated[int, "foo"]

v_type = dataclasses.fields(C)[0].type
print(repr(v_type))  # "Annotated[int, 'foo']"
print(repr(get_type_hints(C)["v"]))  # <class 'int'>
print(repr(eval(v_type)))  # typing.Annotated[int, 'foo']

In the code above it looks like the only way to get the `Annotated` so you get get its args is using `eval`. The problem is that, in non-trivial, examples, `eval` would not be simple to use as you need to consider globals and locals, see
Date User Action Args
2022-04-08 08:18:41barisionesetrecipients: + barisione, eric.smith, methane, drhagen, lopek, ARF1, dcecile, davetapley
2022-04-08 08:18:41barisionesetmessageid: <>
2022-04-08 08:18:41barisionelinkissue39442 messages
2022-04-08 08:18:41barisionecreate