typing_extensions icon indicating copy to clipboard operation
typing_extensions copied to clipboard

Add `typing.get_type_hints` backport

Open cdce8p opened this issue 1 year ago • 1 comments

Would it be worth backporting https://github.com/python/cpython/issues/114053 for Python 3.12.0 - 3.12.3? /CC @AlexWaygood

cdce8p avatar May 24 '24 07:05 cdce8p

IIRC, backporting stuff that involves ForwardRef._evaluate() is pretty hard, because you end up having to copy a huge amount of typing internals into typing_extensions :(

So I'm not sure if it would be worth it just for the early 3.12 patch releases. But I'm definitely open to it if there's a way to do it that's not too fragile or complicated

AlexWaygood avatar May 24 '24 10:05 AlexWaygood

I'm going to close this for now, as I don't think we have any plans to work on this considering that we think it would be quite involved to implement. However, we do now have typing_extensions.get_annotations(), which does similar things to typing.get_type_hints() without some of the... questionable behaviour that get_type_hints must maintain for backwards compatibility purposes :-)

(And I'd still be happy to review a PR if you can see a way to backport it in a non-horrible way!)

AlexWaygood avatar Sep 23 '24 18:09 AlexWaygood