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

New semantic analyzer: fix order=True in dataclass with deferral #6987

Merged
merged 1 commit into from
Jun 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mypy/plugins/dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def transform(self) -> None:
]

existing_method = info.get(method_name)
if existing_method is not None:
if existing_method is not None and not existing_method.plugin_generated:
assert existing_method.node
ctx.api.fail(
'You may not have a custom %s method when order=True' % method_name,
Expand Down
18 changes: 18 additions & 0 deletions test-data/unit/check-dataclasses.test
Original file line number Diff line number Diff line change
Expand Up @@ -624,3 +624,21 @@ class C:
x: int = dataclasses.field(default=1)
y: str = dataclasses.field(metadata={"doc": "foo"}) # E: Attributes without a default cannot follow attributes with one
[builtins fixtures/dict.pyi]

[case testDataclassOrderingDeferred]
# flags: --python-version 3.6 --new-semantic-analyzer
from dataclasses import dataclass

defer: Yes

@dataclass(order=True)
class Application:
name: str
rating: int

a = Application('', 0)
b = Application('', 0)
a < b

class Yes: ...
[builtins fixtures/list.pyi]