New submission from Netzeband :
When evaluating the type-hints of an inner-class (a class defined inside a
function scope), the forward declaration does not work correctly. In this case
the typing.get_type_hints does not get the right namespace, thus the
class-string specified is not found
New submission from Netzeband :
When decorating a function and using a forward declaration as type hint, the
typing.get_type_hints function does not work anymore, since it cannot find the
forward declared name in the namespace. After debugging I think, the
typing.get_type_hints function is
Netzeband added the comment:
Thanks for your feedback. I can create a pull-request. However, I did it never
before for the Python-Lib, so I first have to setup the correct environment for
that and ensure, that I can run all test-cases.
Since I'm on vacation soon, it could take several
Netzeband added the comment:
Thanks for your response. I was also thinking much about it and was not able to
find a nice idea how to get this working.
The problem is, that we loose the local-namespace information as soon as we
leave the context of the function, where the class was defined
Netzeband added the comment:
I tried my idea with the small example code above. However it does not work
like expected:
(see zipped example project, attached to this comment)
At the moment where the function decorator is applied to the method of the
inner class, the local namespace
Netzeband added the comment:
I think I found a better workaround (by accident).
I was debugging another issue with get_type_hints for the case that this
function is used inside the __new__ method of a metaclass and with methods of
the class to define. Here the same issue happens: Forward
Netzeband added the comment:
Thanks for your explanations.
It sounds, that there is no way to fix this issue officially. Only the
meta-class workaround is left, which is - as you highlight - really just a
workaround.
I anyway always wonder, why functions, which are methods, do not hold a
Netzeband added the comment:
Hello,
I'm very sorry, I was not able to find the time to finish the patch in the
quality I wanted to have. So @benedwards14 please feel free to provide a pull
request.
Best regards,
André
--
___
Python tr
Netzeband added the comment:
Thanks a lot!
--
___
Python tracker
<https://bugs.python.org/issue37838>
___
___
Python-bugs-list mailing list
Unsubscribe: