[issue37838] typing.get_type_hints not working with forward-declaration and decorated functions

2019-11-21 Thread Ivan Levkivskyi


Change by Ivan Levkivskyi :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37838] typing.get_type_hints not working with forward-declaration and decorated functions

2019-11-21 Thread miss-islington


miss-islington  added the comment:


New changeset 9458c5c42bbe5fb6ef2393c9ee66f012a2c13ca3 by Miss Islington (bot) 
in branch '3.8':
bpo-37838: get_type_hints for wrapped functions with forward reference 
(GH-17126)
https://github.com/python/cpython/commit/9458c5c42bbe5fb6ef2393c9ee66f012a2c13ca3


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37838] typing.get_type_hints not working with forward-declaration and decorated functions

2019-11-21 Thread miss-islington


miss-islington  added the comment:


New changeset 30e5bd8471d7531d051796c01e8ede01ade883dc by Miss Islington (bot) 
in branch '3.7':
bpo-37838: get_type_hints for wrapped functions with forward reference 
(GH-17126)
https://github.com/python/cpython/commit/30e5bd8471d7531d051796c01e8ede01ade883dc


--
nosy: +miss-islington

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37838] typing.get_type_hints not working with forward-declaration and decorated functions

2019-11-21 Thread miss-islington


Change by miss-islington :


--
pull_requests: +16811
pull_request: https://github.com/python/cpython/pull/17324

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37838] typing.get_type_hints not working with forward-declaration and decorated functions

2019-11-21 Thread miss-islington


Change by miss-islington :


--
pull_requests: +16812
pull_request: https://github.com/python/cpython/pull/17325

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37838] typing.get_type_hints not working with forward-declaration and decorated functions

2019-11-21 Thread Ivan Levkivskyi


Ivan Levkivskyi  added the comment:


New changeset 0aca3a3a1e68b4ca2d334ab5255dfc267719096e by Ivan Levkivskyi 
(benedwards14) in branch 'master':
bpo-37838: get_type_hints for wrapped functions with forward reference 
(GH-17126)
https://github.com/python/cpython/commit/0aca3a3a1e68b4ca2d334ab5255dfc267719096e


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37838] typing.get_type_hints not working with forward-declaration and decorated functions

2019-11-12 Thread Benjamin Edwards


Benjamin Edwards  added the comment:

Have opened a PR, let me know if there is anything that needs fixing

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37838] typing.get_type_hints not working with forward-declaration and decorated functions

2019-11-12 Thread Benjamin Edwards


Change by Benjamin Edwards :


--
keywords: +patch
pull_requests: +16634
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/17126

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37838] typing.get_type_hints not working with forward-declaration and decorated functions

2019-11-11 Thread Ivan Levkivskyi


Ivan Levkivskyi  added the comment:

The PR was linked by mistake (it is for a different issue), so I unlinked it.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37838] typing.get_type_hints not working with forward-declaration and decorated functions

2019-11-11 Thread Ivan Levkivskyi


Change by Ivan Levkivskyi :


--
keywords:  -patch
stage: patch review -> needs patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37838] typing.get_type_hints not working with forward-declaration and decorated functions

2019-11-11 Thread Ivan Levkivskyi


Change by Ivan Levkivskyi :


--
pull_requests:  -16560

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37838] typing.get_type_hints not working with forward-declaration and decorated functions

2019-11-04 Thread Anj-A


Change by Anj-A <2017...@gmail.com>:


--
keywords: +patch
pull_requests: +16560
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/17047

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37838] typing.get_type_hints not working with forward-declaration and decorated functions

2019-10-31 Thread Netzeband


Netzeband  added the comment:

Thanks a lot!

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37838] typing.get_type_hints not working with forward-declaration and decorated functions

2019-10-29 Thread Benjamin Edwards


Benjamin Edwards  added the comment:

Thanks Netzeband,

Will get on this.

Ben

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37838] typing.get_type_hints not working with forward-declaration and decorated functions

2019-10-28 Thread Netzeband

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 tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37838] typing.get_type_hints not working with forward-declaration and decorated functions

2019-10-27 Thread Joannah Nanjekye


Joannah Nanjekye  added the comment:

Actually there is a patch. So please @netbnd please open a PR 
https://github.com/python/cpython

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37838] typing.get_type_hints not working with forward-declaration and decorated functions

2019-10-27 Thread Joannah Nanjekye


Joannah Nanjekye  added the comment:

@benedwards14 Feel free to open a PR. @netbnd said anyone can take on the issue 
since he may take long to revert with a PR.

--
nosy: +nanjekyejoannah

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37838] typing.get_type_hints not working with forward-declaration and decorated functions

2019-10-27 Thread Benjamin Edwards


Benjamin Edwards  added the comment:

Hey Netzeband, are you still working on this, or would it be ok for me to have 
a go? 

If all you needed was help with a PR let me know, i have some experience?

--
nosy: +benedwards14

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37838] typing.get_type_hints not working with forward-declaration and decorated functions

2019-08-14 Thread Ivan Levkivskyi


Change by Ivan Levkivskyi :


--
keywords: +newcomer friendly

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37838] typing.get_type_hints not working with forward-declaration and decorated functions

2019-08-13 Thread Netzeband


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 weeks. If someone wants to 
solve the issue earlier, please don't hesitate. 

I will write it in this issue ticket, as soon as I finished the PR.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37838] typing.get_type_hints not working with forward-declaration and decorated functions

2019-08-13 Thread Guido van Rossum


Guido van Rossum  added the comment:

Maybe we should tag this issue "newcomer friendly"? It seems a pretty open
and shut case.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37838] typing.get_type_hints not working with forward-declaration and decorated functions

2019-08-13 Thread Ivan Levkivskyi


Ivan Levkivskyi  added the comment:

> Using `__wrapped__` if present sounds like a good idea.

Yeah, I like this idea, this will likely cover most use cases (since most 
people actually do use @wraps).

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37838] typing.get_type_hints not working with forward-declaration and decorated functions

2019-08-13 Thread Guido van Rossum


Guido van Rossum  added the comment:

Using `__wrapped__` if present sounds like a good idea. Ivan, what do you think?

Netzeband, have you considered submitting a PR with the necessary changes (and 
tests and docs)?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37838] typing.get_type_hints not working with forward-declaration and decorated functions

2019-08-13 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +gvanrossum, levkivskyi

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37838] typing.get_type_hints not working with forward-declaration and decorated functions

2019-08-13 Thread Netzeband


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 actually using the namespace of the decorator 
instead of the decorated function.

When using a normal class type (no forward declaration) everything works fine 
and also when not using any decorator it works like expected.

As a workaround, one could pass the local namespace to typing.get_type_hints. 
However in normal usecases this function is used for runtime typechecking in a 
deep call hierarchy. So one would normally not have access to the right local 
namespace, only to the function object itself. 

However there is another easy workaround. At least when using the 
functool.wraps method to create a function decorator. The decorated functions 
has a "__wrapped__" attribute, which references the original function. When 
using "typing.get_type_hints(function.__wrapped__)" instead of 
"typing.get_type_hints(function)", it works like expected. So maybe this could 
be built in into the get_type_hints method.

--
components: Library (Lib)
files: typing_check_wrapped.zip
messages: 349542
nosy: netbnd
priority: normal
severity: normal
status: open
title: typing.get_type_hints not working with forward-declaration and decorated 
functions
type: behavior
versions: Python 3.6, Python 3.7
Added file: https://bugs.python.org/file48540/typing_check_wrapped.zip

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com