[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:
Abhijeet Prasad Bodas 2025-05-07 19:21:13 +05:30 committed by GitHub
parent fab862c8cd
commit 3dedd70a92
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 57 additions and 27 deletions

View file

@ -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