diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F823.py b/crates/ruff/resources/test/fixtures/pyflakes/F823.py index a17d91f0c7..343150143e 100644 --- a/crates/ruff/resources/test/fixtures/pyflakes/F823.py +++ b/crates/ruff/resources/test/fixtures/pyflakes/F823.py @@ -63,3 +63,10 @@ def main(): for sys in range(5): pass + + +import requests_mock as rm + + +def requests_mock(requests_mock: rm.Mocker): + print(rm.ANY) diff --git a/crates/ruff_python_semantic/src/model.rs b/crates/ruff_python_semantic/src/model.rs index 75810ef142..fc66f668de 100644 --- a/crates/ruff_python_semantic/src/model.rs +++ b/crates/ruff_python_semantic/src/model.rs @@ -594,7 +594,12 @@ impl<'a> SemanticModel<'a> { return None; } - self.scopes[scope_id].get(qualified_name) + let binding_id = self.scopes[scope_id].get(qualified_name)?; + if !self.bindings[binding_id].kind.is_submodule_import() { + return None; + } + + Some(binding_id) } /// Resolves the [`Expr`] to a fully-qualified symbol-name, if `value` resolves to an imported