mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-20 23:31:48 +00:00
[ty] Do not assume that field
s have a default value (#20914)
## Summary fixes https://github.com/astral-sh/ty/issues/1366 ## Test Plan Added regression test
This commit is contained in:
parent
c9dfb51f49
commit
0cc663efcd
5 changed files with 29 additions and 19 deletions
|
@ -497,6 +497,8 @@ class A:
|
|||
a: str = field(kw_only=False)
|
||||
b: int = 0
|
||||
|
||||
reveal_type(A.__init__) # revealed: (self: A, a: str, *, b: int = Literal[0]) -> None
|
||||
|
||||
A("hi")
|
||||
```
|
||||
|
||||
|
|
|
@ -108,7 +108,7 @@ class A:
|
|||
name: str = field(init=False)
|
||||
|
||||
# field(init=False) should be ignored for dataclass_transform without explicit field_specifiers
|
||||
reveal_type(A.__init__) # revealed: (self: A, name: str = Unknown) -> None
|
||||
reveal_type(A.__init__) # revealed: (self: A, name: str) -> None
|
||||
|
||||
@dataclass
|
||||
class B:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue