[issue45524] Cross-module dataclass inheritance breaks get_type_hints

2022-01-22 Thread Alex Waygood
Change by Alex Waygood : -- nosy: +Jelle Zijlstra ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue45524] Cross-module dataclass inheritance breaks get_type_hints

2021-11-29 Thread Eric V. Smith
Change by Eric V. Smith : -- assignee: -> eric.smith ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue45524] Cross-module dataclass inheritance breaks get_type_hints

2021-10-24 Thread Nikita Sobolev
Nikita Sobolev added the comment: In my opinion, it is never a bad thing to create a new issue :) сб, 23 окт. 2021 г. в 22:46, Sergei Lebedev : > > Sergei Lebedev added the comment: > > Is it worth filing a separate issue for locals()? > > In my experience local classes are less common than

[issue45524] Cross-module dataclass inheritance breaks get_type_hints

2021-10-23 Thread Sergei Lebedev
Sergei Lebedev added the comment: Is it worth filing a separate issue for locals()? In my experience local classes are less common than cross-module inheritance, so I suspect that the chances of someone accidentally hitting lack of locals() forwarding are quite low. However, given how

[issue45524] Cross-module dataclass inheritance breaks get_type_hints

2021-10-22 Thread Nikita Sobolev
Nikita Sobolev added the comment: I completelly agree that the exable above is out of scope. Because it requires `locals()` to be modified. While this issue is focused on `globals()`. -- ___ Python tracker

[issue45524] Cross-module dataclass inheritance breaks get_type_hints

2021-10-22 Thread Alex Waygood
Alex Waygood added the comment: @Sergei, I believe that's a much larger issue, and one that's quite difficult to solve. It's one of the principal reasons why `from __future__ import annotations` behaviour wasn't made the default in Python 3.10, as was originally the plan. (This behaviour

[issue45524] Cross-module dataclass inheritance breaks get_type_hints

2021-10-22 Thread Sergei Lebedev
Sergei Lebedev added the comment: Is it worth also addressing the case where a @dataclass/typing.TypeDict class is defined within a function? ``` from __future__ import annotations import

[issue45524] Cross-module dataclass inheritance breaks get_type_hints

2021-10-22 Thread Alex Waygood
Change by Alex Waygood : -- nosy: +gvanrossum, kj ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue45524] Cross-module dataclass inheritance breaks get_type_hints

2021-10-22 Thread Nikita Sobolev
Change by Nikita Sobolev : -- keywords: +patch pull_requests: +27433 stage: -> patch review pull_request: https://github.com/python/cpython/pull/29158 ___ Python tracker ___

[issue45524] Cross-module dataclass inheritance breaks get_type_hints

2021-10-22 Thread Alex Waygood
Alex Waygood added the comment: If you try running my test script with the `from __future__ import annotations` line at the top commented out, however, the error is the same. (`from __future__ import annotations` is obviously still there in the module that's being imported by the test

[issue45524] Cross-module dataclass inheritance breaks get_type_hints

2021-10-22 Thread Alex Waygood
Alex Waygood added the comment: @Nikita, I had a go at writing some more rigorous tests regarding this issue. I found the same thing you did -- the issue seems: * Isolated to dataclasses specifically (doesn't occur with TypedDicts, standard classes or NamedTuples) * Isolated to the __init__

[issue45524] Cross-module dataclass inheritance breaks get_type_hints

2021-10-22 Thread Nikita Sobolev
Nikita Sobolev added the comment: I had some time to debug this. It happens because we treat classes and functions differently. The difference between `get_type_hints(B)` and `get_type_hints(B.__init__)` is that we use different `global` contexts there: - For `B` we use `__mro__` entries

[issue45524] Cross-module dataclass inheritance breaks get_type_hints

2021-10-19 Thread Aidan Clark
Aidan Clark added the comment: Ah yes, I completely apologize about that typo, the __init__ is definitely needed (serves me right for trying to clean up a repo before posting it). One other comment to make, perhaps obvious; manually passing a namespace to get_type_hints' `globalns` which

[issue45524] Cross-module dataclass inheritance breaks get_type_hints

2021-10-19 Thread Alex Waygood
Change by Alex Waygood : -- versions: +Python 3.10, Python 3.11 -Python 3.6 ___ Python tracker ___ ___ Python-bugs-list mailing

[issue45524] Cross-module dataclass inheritance breaks get_type_hints

2021-10-19 Thread Alex Waygood
Alex Waygood added the comment: Thanks @Sergei. With that alteration, I have reproduced this on Python 3.9, 3.10 and 3.11. -- ___ Python tracker ___

[issue45524] Cross-module dataclass inheritance breaks get_type_hints

2021-10-19 Thread Karthikeyan Singaravelan
Change by Karthikeyan Singaravelan : -- nosy: +eric.smith ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue45524] Cross-module dataclass inheritance breaks get_type_hints

2021-10-19 Thread Sergei Lebedev
Sergei Lebedev added the comment: I think the example has a minor typo. The crash is reproducible on 3.9 if the last line in bar.py is typing.get_type_hints(B.__init__) instead of typing.get_type_hints(B) -- ___ Python tracker

[issue45524] Cross-module dataclass inheritance breaks get_type_hints

2021-10-19 Thread Alex Waygood
Alex Waygood added the comment: I can't reproduce this on Python 3.8.3, 3.9.6, 3.10.0 or 3.11.0a1+. Which versions of Python have you tried this on? (I'm able to reproduce the `typing.TypedDict` bug on Python 3.8, since the fix was only backported to 3.9, but not this.) -- nosy:

[issue45524] Cross-module dataclass inheritance breaks get_type_hints

2021-10-19 Thread Aidan Clark
New submission from Aidan Clark : [I believe this is fundamentally a dataclass version of https://bugs.python.org/issue41249] When using `from __future__ import annotations`, calling get_type_hints on the constructor of a dataclass B which inherits from a dataclass A defined in another