On Wed, Aug 5, 2020 at 12:25 AM Dominik Vilsmeier <dominik.vilsmeier@gmx.de> wrote:
On 04.08.20 22:05, Guido van Rossum wrote:
Maybe get-type-hints can be refactored to make writing such a function simpler. IIRC the part that takes a single annotation and evaluates it is a private function.
That's what I considered and indeed it relies on `typing._eval_type`. If this was public then all building blocks would be in place.
In that case I recommend that you create a bpo issue about adding it and submit a PR to resolve the issue. I think the public API should have the same defaults for globalns and localns as get_type_hints(), and it should probably not expose the recursive_guard argument. Since this is a new feature and the 3.9 release is already closed for new features, this can be added in 3.10 -- in earlier releases you'll have to use `_eval_type`. (It does not seem important enough to add it to the typing_extensions module.) -- --Guido van Rossum (python.org/~guido) *Pronouns: he/him **(why is my pronoun here?)* <http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-c...>