[issue29966] typing.get_type_hints doesn't really work for classes with ForwardRefs

2017-09-15 Thread Ivan Levkivskyi
Ivan Levkivskyi added the comment: This is now fixed (to a reasonable extent) by https://github.com/python/cpython/commit/f350a268a7071ce7d7a5bb86a9b1229782d4963b on master, and backported to 3.6. -- resolution: -> fixed stage: -> resolved status: open -> closed

[issue29966] typing.get_type_hints doesn't really work for classes with ForwardRefs

2017-04-11 Thread Simon Percivall
Simon Percivall added the comment: It think it's important to document this caveat in `get_type_hints`, that there is virtually _no_ way to use it safely with a class, and that there will always be a high risk of getting an exception unless using this function in a highly controlled setting.

[issue29966] typing.get_type_hints doesn't really work for classes with ForwardRefs

2017-04-04 Thread Ivan Levkivskyi
Ivan Levkivskyi added the comment: You could try: glob = globals.copy() glob.update(a.__dict__) glob.update(b.__dict__) You can do this automatically following MyClass.__mro__ and then collecting relevant __module__ attributes on bases. However, there is little chance this will be fixed in

[issue29966] typing.get_type_hints doesn't really work for classes with ForwardRefs

2017-04-03 Thread Jim Fasarakis-Hilliard
Changes by Jim Fasarakis-Hilliard : -- components: +Library (Lib) type: -> behavior ___ Python tracker ___

[issue29966] typing.get_type_hints doesn't really work for classes with ForwardRefs

2017-04-03 Thread Simon Percivall
New submission from Simon Percivall: For classes with ForwardRef annotations, typing.get_type_hints is unusable. As example, we have two files: a.py: class Base: a: 'A' class A: pass b.py: from a import Base class MyClass(Base): b: 'B' class B: pass >>> from typing import