Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions crates/ruff_linter/resources/test/fixtures/pyflakes/F811_33.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Regression test for https://github.com/astral-sh/ruff/issues/19632
# When @overload is imported from a custom module listed in typing-modules,
# Ruff should recognize it as typing.overload and not emit false F811
# diagnostics for each overloaded function definition.
#
# Requires: typing-modules = ["std"]
from std import overload


@overload
def func(a: str, b: int) -> int: ...


@overload
def func(a: int, b: str) -> int: ...


def func(a: int | str, b: int | str) -> int:
return 0
13 changes: 13 additions & 0 deletions crates/ruff_linter/src/rules/pyflakes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,19 @@ mod tests {
Ok(())
}

#[test]
fn f811_typing_modules_overload() -> Result<()> {
let diagnostics = test_path(
Path::new("pyflakes/F811_33.py"),
&LinterSettings {
typing_modules: vec!["std".to_string()],
..LinterSettings::for_rule(Rule::RedefinedWhileUnused)
},
)?;
assert_diagnostics!(diagnostics);
Ok(())
}

#[test]
fn extend_generics() -> Result<()> {
let snapshot = "extend_immutable_calls".to_string();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
source: crates/ruff_linter/src/rules/pyflakes/mod.rs
---

2 changes: 1 addition & 1 deletion crates/ruff_python_semantic/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ impl<'a> SemanticModel<'a> {
}

if self.typing_modules.iter().any(|module| {
let module = QualifiedName::from_dotted_name(module);
let module = QualifiedName::user_defined(module);
qualified_name == &module.append_member(target)
}) {
return true;
Expand Down
Loading