Skip to content

Add test case for fixed dataclass-in-function crash #12793

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

Merged
merged 1 commit into from
May 16, 2022
Merged
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
14 changes: 14 additions & 0 deletions test-data/unit/check-dataclasses.test
Original file line number Diff line number Diff line change
Expand Up @@ -1553,6 +1553,20 @@ A(a=func).a()
A(a=func).a = func # E: Property "a" defined in "A" is read-only
[builtins fixtures/dataclasses.pyi]

[case testDataclassInFunctionDoesNotCrash]
# flags: --python-version 3.7
from dataclasses import dataclass

def foo():
@dataclass
class Foo:
foo: int
# This used to crash (see #8703)
# The return type of __call__ here needs to be something undefined
# In order to trigger the crash that existed prior to #12762
def __call__(self) -> asdf: ... # E: Name "asdf" is not defined
[builtins fixtures/dataclasses.pyi]

[case testDataclassesMultipleInheritanceWithNonDataclass]
# flags: --python-version 3.10
from dataclasses import dataclass
Expand Down