-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crash involving dataclasses, generics, forward references #12685
Comments
I briefly tried to make an MWE, but was unsuccessful. |
Looks like this is a regression between 0.942 and 0.950 |
This bisects to #12656 |
Okay, took another look at this and got a small repro:
|
You can also repro it with just one class, which is probably still tickling the same bug: import dataclasses
import typing
T = typing.TypeVar('T', bound='Foo')
@dataclasses.dataclass
class Foo(typing.Generic[T]):
data: int If you remove either of the following elements, the problem won't be reproducible:
The bound need not be The traceback is also slightly different:
|
Thanks. I think that's actually a different issue (and one that is not a regression), see #12527 |
The root cause seems to be that we can't safely run the dataclass transform in the main pass of the semantic analysis, since various references can still be unbound, and we can encounter placeholder types, etc. I'm going to attempt to move the whole transform to a later pass where all references are bound. |
The dataclass plugin could crash if it encountered a placeholder. Fix the issue by running the plugin after the main semantic analysis pass, when all placeholders have been resolved. Also add a new hook called get_class_decorator_hook_2 that is used by the dataclass plugin. We may want to do a similar change to the attrs plugin, but let's change one thing at a time. Fix #12685.
Running master MyPy 0.960 on the latest efax 1.6.3 gives
The text was updated successfully, but these errors were encountered: