Skip to content
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

Fix spurious errors in inherited dataclasses in incremental mode #7596

Merged
merged 4 commits into from Oct 2, 2019

Conversation

@msullivan
Copy link
Collaborator

msullivan commented Oct 1, 2019

The dataclasses plugin incorrectly expected json to preserve
the ordering of its dictionaries, which led to spurious errors
about "Attributes without a default cannot follow attributes with one".

Worse, the errors are reported in the wrong file: they use the line
number of the attribute but the file of the dataclass being checked!

Fix the spurious error by serializing attributes in a list, since we
care about the order.

Reporting this error for attributes in parent classes is actually
useful, since multiple inheritance can cause this error. Report the
error at the class definition site causing the problem instead.
(The error message here could certainly be improved, but right
now I just want to fix the "wrong file" bugs, which are I think
the worst kind of bugs after crashes.)

The dataclasses plugin incorrectly expected json to preserve
the ordering of its dictionaries, which led to spurious errors
about "Attributes without a default cannot follow attributes with one".

Worse, the errors are reported in the wrong file: they use the line
number of the attribute but the file of the dataclass being checked!

Fix the spurious error by serializing attributes in a list, since we
care about the order.

Reporting this error for attributes in parent classes is actually
useful, since multiple inheritance can cause this error. Report the
error at the class definition site causing the problem instead.
(The error message here could certainly be improved, but right
now I just want to fix the "wrong file" bugs, which are I think
the worst kind of bugs after crashes.)
@msullivan msullivan requested review from Michael0x2a and ilevkivskyi Oct 1, 2019
Copy link
Collaborator

ilevkivskyi left a comment

LGTM, thanks for the quick fix!

msullivan added 3 commits Oct 2, 2019
@msullivan msullivan merged commit 8b86349 into master Oct 2, 2019
0 of 2 checks passed
0 of 2 checks passed
continuous-integration/appveyor/pr Waiting for AppVeyor build to complete
Details
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
@msullivan msullivan deleted the dataclass-mess branch Oct 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.