Commit e462c03
Fix F811 false positive for overloaded functions from typing-modules (#23357)
## Summary
Fixes #19632.
When `@overload` is imported from a custom module listed in
`typing-modules` (e.g., `from std import overload`), Ruff fails to
recognize it as the `typing.overload` decorator and emits false F811
diagnostics for each overloaded function definition.
The root cause is in `SemanticModel::match_typing_qualified_name`:
`QualifiedName::from_dotted_name` splits on dots, so a single-segment
module like `std` still works, but the internal representation stores it
differently from what `QualifiedName::user_defined` produces. Use
`user_defined` instead to match the internal representation
consistently.
## Test plan
- Reproduction case: `ruff check --select F811 --config ruff.toml
temp.py` no longer emits false positives for `@overload` from custom
typing-modules
- `cargo test -p ruff_linter -- pyflakes` — all 462 tests pass
---------
Co-authored-by: Brent Westbrook <brentrwestbrook@gmail.com>1 parent f8d1dd2 commit e462c03
4 files changed
Lines changed: 37 additions & 1 deletion
File tree
- crates
- ruff_linter
- resources/test/fixtures/pyflakes
- src/rules/pyflakes
- snapshots
- ruff_python_semantic/src
Lines changed: 19 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
708 | 708 | | |
709 | 709 | | |
710 | 710 | | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
711 | 724 | | |
712 | 725 | | |
713 | 726 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
209 | 209 | | |
210 | 210 | | |
211 | 211 | | |
212 | | - | |
| 212 | + | |
213 | 213 | | |
214 | 214 | | |
215 | 215 | | |
| |||
0 commit comments