-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Passing dataclass default_factory
as positional argument causes internal error.
#10248
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
Comments
The definition of
If you want to use |
@syheliel: Of course, but forgetting to do so should not crash Mypy. That's what this issue is about. |
@jonathanslenders: I tried the following codes and doesn't cause the crash. It seems that when using decorator
result:
|
I was investigating this issue and I just noticed that this crash is also "fixed" by the latest PR #11137, but the error message looks a bit odd now. Here is an example as a unit test:
This is an obvious type error anyway, so maybe mypy devs don't have to really care about this kind of issue though. |
Thanks for pointing this out! It's still useful to make the error as clear as possible. cc @sobolevn in case you're interested in tweaking this code a bit more. |
Yes, sure. Any suggestions for a better message? 🤔 |
|
) Fixes #10248 The crash due to dataclasses.field was fixed in the recent PR #11137, but the error message was wrong when positional arguments are used. I update the error message based on #10248 (comment) (Thanks @JelleZijlstra!)
Crash Report
The detaclasses
field
is missing adefault_factory
keyword argument. I'm passing it as a positional argument.Traceback
To Reproduce
Your Environment
mypy.ini
(and other config files): /The text was updated successfully, but these errors were encountered: