[issue42904] get_type_hints does not provide localns for classes

2021-04-29 Thread Ken Jin
Ken Jin added the comment: Hmm I think you're right - the normal behavior in Python is for local variables to shadow global variables, and as a user I expect the same for eval in inspect.get_annotation. -- ___ Python tracker

[issue42904] get_type_hints does not provide localns for classes

2021-04-29 Thread Larry Hastings
Larry Hastings added the comment: Thank you for your in-depth and thoughtful reply! I think that APIs should behave in a predictable way. So, for my use case, I tell the user that I'm passing "globals" and "locals" into eval()--and I think I'd have to have a *very* compelling reason to

[issue42904] get_type_hints does not provide localns for classes

2021-04-29 Thread Ken Jin
Ken Jin added the comment: @larry > Is this "surprising, but required" behavior due specifically to this being a > backwards-incompatible change? Yes. That's the main factor. I've since learnt that there's sadly more to it though :( (see below). > Does that mean I don't have the problem

[issue42904] get_type_hints does not provide localns for classes

2021-04-29 Thread Larry Hastings
Larry Hastings added the comment: kj: I just added support for default locals to inspect.get_annotation(), and I basically copied-and-pasted your dict(vars(base)) approach. Is this "surprising, but required" behavior due specifically to this being a backwards-incompatible change?

[issue42904] get_type_hints does not provide localns for classes

2021-04-26 Thread Guido van Rossum
Guido van Rossum added the comment: New changeset 1b1f9852bda85c01ef124858f293e9c13e04ffce by Ken Jin in branch 'master': bpo-42904: Change search order of typing.get_type_hints eval (#25632) https://github.com/python/cpython/commit/1b1f9852bda85c01ef124858f293e9c13e04ffce --

[issue42904] get_type_hints does not provide localns for classes

2021-04-26 Thread Ken Jin
Change by Ken Jin : -- pull_requests: +24327 pull_request: https://github.com/python/cpython/pull/25632 ___ Python tracker ___ ___

[issue42904] get_type_hints does not provide localns for classes

2021-04-13 Thread Ken Jin
Ken Jin added the comment: Yup I can! BTW, I agree with keeping the change in 3.10 only. I suspect it _may_ be backwards-incompatible in small edge cases (re: the long comment on the PR about suspicions with local and global scope). -- resolution: -> fixed stage: patch review ->

[issue42904] get_type_hints does not provide localns for classes

2021-04-12 Thread Guido van Rossum
Guido van Rossum added the comment: Hi Ken Jin, you can close this issue now with your new permissions, right? -- ___ Python tracker ___

[issue42904] get_type_hints does not provide localns for classes

2021-04-12 Thread Guido van Rossum
Guido van Rossum added the comment: New changeset 852150ddfe68bc2696fc880175aeb855a0c16ae6 by Ken Jin in branch 'master': bpo-42904: Fix get_type_hints for class local namespaces (GH-24201) https://github.com/python/cpython/commit/852150ddfe68bc2696fc880175aeb855a0c16ae6 --

[issue42904] get_type_hints does not provide localns for classes

2021-01-12 Thread Ken Jin
Change by Ken Jin : -- keywords: +patch pull_requests: +23026 stage: -> patch review pull_request: https://github.com/python/cpython/pull/24201 ___ Python tracker ___

[issue42904] get_type_hints does not provide localns for classes

2021-01-12 Thread Ken Jin
Ken Jin added the comment: > Fidget-Spinner, are you interested in taking this? Sure thing! Please give me some time to look at it - I don't really use the runtime type validation stuff from typing (I usually defer that to 3rd party libraries), so I need to familiarize myself first.

[issue42904] get_type_hints does not provide localns for classes

2021-01-11 Thread Guido van Rossum
Guido van Rossum added the comment: It's apparently a bug in all versions that support `from __future__ import annotations` (and only when that is used). Though perhaps we should only fix in in 3.10. -- ___ Python tracker

[issue42904] get_type_hints does not provide localns for classes

2021-01-11 Thread Guido van Rossum
Guido van Rossum added the comment: Fidget-Spinner, are you interested in taking this? -- ___ Python tracker ___ ___

[issue42904] get_type_hints does not provide localns for classes

2021-01-11 Thread Paul Bryan
Change by Paul Bryan : -- nosy: +larry ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue42904] get_type_hints does not provide localns for classes

2021-01-11 Thread Paul Bryan
New submission from Paul Bryan : According to PEP 563: > The get_type_hints() function automatically resolves the correct value of > globalns for functions and classes. It also automatically provides the > correct localns for classes. This statement about providing correct localns for