mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-16 01:25:11 +00:00
[ty] dataclasses: Allow using dataclasses.dataclass as a function. (#18440)
## Summary Part of https://github.com/astral-sh/ty/issues/111 Using `dataclass` as a function, instead of as a decorator did not work as expected prior to this. Fix that by modifying the dataclass overload's return type. ## Test Plan New mdtests, fixing the existing TODO.
This commit is contained in:
parent
2c3b3d3230
commit
71d8a5da2a
2 changed files with 31 additions and 3 deletions
|
@ -797,7 +797,20 @@ C(1) < C(2) # ok
|
|||
|
||||
### Using `dataclass` as a function
|
||||
|
||||
To do
|
||||
```py
|
||||
from dataclasses import dataclass
|
||||
|
||||
class B:
|
||||
x: int
|
||||
|
||||
# error: [missing-argument]
|
||||
dataclass(B)()
|
||||
|
||||
# error: [invalid-argument-type]
|
||||
dataclass(B)("a")
|
||||
|
||||
reveal_type(dataclass(B)(3).x) # revealed: int
|
||||
```
|
||||
|
||||
## Internals
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue