8000 [dataclass_transform] support default parameters by wesleywright · Pull Request #14580 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

[dataclass_transform] support default parameters #14580

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
Changes from 1 commit
Commits
File filter

Filter by extension

8000 Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add final boolean test case
  • Loading branch information
wesleywright committed Feb 7, 2023
commit ad359775c64211e7cb78e2b91599fad5f0ce7ed0
6 changes: 5 additions & 1 deletion test-data/unit/check-dataclass-transform.test
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,20 @@ class B: ...

[case testDataclassTransformDefaultParamsMustBeLiterals]
# flags: --python-version 3.11
from typing import dataclass_transform, Type
from typing import dataclass_transform, Type, Final

BOOLEAN_CONSTANT = True
FINAL_BOOLEAN: Final = True

@dataclass_transform(eq_default=BOOLEAN_CONSTANT) # E: eq_default argument must be True or False
def foo(cls: Type) -> Type:
return cls
@dataclass_transform(eq_default=(not True)) # E: eq_default argument must be True or False
def bar(cls: Type) -> Type:
return cls
@dataclass_transform(eq_default=FINAL_BOOLEAN) # E: eq_default argument must be True or False
def baz(cls: Type) -> Type:
return cls

[typing fixtures/typing-full.pyi]
[builtins fixtures/dataclasses.pyi]
Expand Down
0