mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-29 05:15:12 +00:00
[ty] Detect overloads decorated with @dataclass_transform
(#17835)
## Summary Fixes #17541 Before this change, in the case of overloaded functions, `@dataclass_transform` was detected only when applied to the implementation, not the overloads. However, the spec also allows this decorator to be applied to any of the overloads as well. With this PR, we start handling `@dataclass_transform`s applied to overloads. ## Test Plan Fixed existing TODOs in the test suite.
This commit is contained in:
parent
fab862c8cd
commit
3dedd70a92
3 changed files with 57 additions and 27 deletions
|
@ -281,13 +281,11 @@ class D1:
|
|||
class D2:
|
||||
x: str
|
||||
|
||||
# TODO: these should not be errors
|
||||
D1("a") # error: [too-many-positional-arguments]
|
||||
D2("a") # error: [too-many-positional-arguments]
|
||||
D1("a")
|
||||
D2("a")
|
||||
|
||||
# TODO: these should be invalid-argument-type errors
|
||||
D1(1.2) # error: [too-many-positional-arguments]
|
||||
D2(1.2) # error: [too-many-positional-arguments]
|
||||
D1(1.2) # error: [invalid-argument-type]
|
||||
D2(1.2) # error: [invalid-argument-type]
|
||||
```
|
||||
|
||||
[`typing.dataclass_transform`]: https://docs.python.org/3/library/typing.html#typing.dataclass_transform
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue