[New-bugs-announce] [issue29966] typing.get_type_hints doesn't really work for classes with ForwardRefs

Simon Percivall report at bugs.python.org
Mon Apr 3 06:21:14 EDT 2017


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 get_type_hints
>>> from b import MyClass
>>> get_type_hints(MyClass) #  NameError


What should globals/locals be here?

----------
messages: 291058
nosy: simon.percivall
priority: normal
severity: normal
status: open
title: typing.get_type_hints doesn't really work for classes with ForwardRefs
versions: Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29966>
_______________________________________


More information about the New-bugs-announce mailing list