Message416963
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
@dataclasses.dataclass
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 https://peps.python.org/pep-0563/#resolving-type-hints-at-runtime. |
|
Date |
User |
Action |
Args |
2022-04-08 08:18:41 | barisione | set | recipients:
+ barisione, eric.smith, methane, drhagen, lopek, ARF1, dcecile, davetapley |
2022-04-08 08:18:41 | barisione | set | messageid: <1649405921.15.0.229757256039.issue39442@roundup.psfhosted.org> |
2022-04-08 08:18:41 | barisione | link | issue39442 messages |
2022-04-08 08:18:41 | barisione | create | |
|