Re: [Python-Dev] Postponed annotations break inspection of dataclasses

2018-09-27 Thread Eric V. Smith
Yes, it’s https://bugs.python.org/issue34776 -- Eric > On Sep 27, 2018, at 12:05 PM, Ivan Levkivskyi wrote: > > Do we have a b.p.o. issue about this? If no, then I would recommend to open > one, so that we will not loose track of this. > > -- > Ivan > > > >> On Sat, 22 Sep 2018 at 16:32,

Re: [Python-Dev] Postponed annotations break inspection of dataclasses

2018-09-27 Thread Ivan Levkivskyi
Do we have a b.p.o. issue about this? If no, then I would recommend to open one, so that we will not loose track of this. -- Ivan On Sat, 22 Sep 2018 at 16:32, David Hagen wrote: > The new postponed annotations have an unexpected interaction with > dataclasses. Namely, you cannot get the

Re: [Python-Dev] Postponed annotations break inspection of dataclasses

2018-09-24 Thread Raymond Hettinger
> On Sep 22, 2018, at 1:38 PM, Yury Selivanov wrote: > > On Sat, Sep 22, 2018 at 3:11 PM Guido van Rossum wrote: > [..] >> Still, I wonder if there's a tweak possible of the globals and locals used >> when exec()'ing the function definitions in dataclasses.py, so that >> get_type_hints()

Re: [Python-Dev] Postponed annotations break inspection of dataclasses

2018-09-23 Thread David Hagen
On Sat, Sep 22, 2018 at 12:41 PM Guido van Rossum wrote: > Probably a bugs.python.org issue is a better place to dive into the details than python-dev. Issue tracker issue created: https://bugs.python.org/issue34776 ___ Python-Dev mailing list

Re: [Python-Dev] Postponed annotations break inspection of dataclasses

2018-09-23 Thread David Hagen
On Sat, Sep 22, 2018 at 3:11 PM Guido van Rossum wrote: > Still, I wonder if there's a tweak possible of the globals and locals used when exec()'ing the function definitions in dataclasses.py, so that get_type_hints() gets the right globals for this use case. On Sat, Sep 22, 2018 at 4:38 PM Yury

Re: [Python-Dev] Postponed annotations break inspection of dataclasses

2018-09-22 Thread Yury Selivanov
On Sat, Sep 22, 2018 at 3:11 PM Guido van Rossum wrote: [..] > Still, I wonder if there's a tweak possible of the globals and locals used > when exec()'ing the function definitions in dataclasses.py, so that > get_type_hints() gets the right globals for this use case. > > It's really tough to

Re: [Python-Dev] Postponed annotations break inspection of dataclasses

2018-09-22 Thread Guido van Rossum
On Sat, Sep 22, 2018 at 11:29 AM Eric V. Smith wrote: > I think this problem is endemic to get_type_hints(). I've never > understood how you're supposed to use the globals and locals arguments > to it, but this works: > > print(get_type_hints(Bar.__init__, globals())) > > as does: > >

Re: [Python-Dev] Postponed annotations break inspection of dataclasses

2018-09-22 Thread Eric V. Smith
On 9/22/2018 12:41 PM, Guido van Rossum wrote: This is a good catch -- thanks for bringing it up. I'm adding Eric Smith (author of dataclasses) and Ivan Levkivskyi (co-author of typing) as well as Łukasz Langa (author of PEP 563) to the thread to see if they have further insights. I don't

Re: [Python-Dev] Postponed annotations break inspection of dataclasses

2018-09-22 Thread Guido van Rossum
This is a good catch -- thanks for bringing it up. I'm adding Eric Smith (author of dataclasses) and Ivan Levkivskyi (co-author of typing) as well as Łukasz Langa (author of PEP 563) to the thread to see if they have further insights. Personally I don't think it's feasible to change PEP 563 to

[Python-Dev] Postponed annotations break inspection of dataclasses

2018-09-22 Thread David Hagen
The new postponed annotations have an unexpected interaction with dataclasses. Namely, you cannot get the type hints of any of the data classes methods. For example, I have some code that inspects the type parameters of a class's `__init__` method. (The real use case is to provide a default