ruff/crates/ruff_python_semantic/src
Charlie Marsh de898c52eb
Avoid falsely marking non-submodules as submodule aliases (#6182)
## Summary

We have some code to ensure that if an aliased import is used, any
submodules should be marked as used too. This comment says it best:

```rust
// If the name of a submodule import is the same as an alias of another import, and the
// alias is used, then the submodule import should be marked as used too.
//
// For example, mark `pyarrow.csv` as used in:
//
// ```python
// import pyarrow as pa
// import pyarrow.csv
// print(pa.csv.read_csv("test.csv"))
// ```
```

However, it looks like when we go to look up `pyarrow` (of `import
pyarrow as pa`), we aren't checking to ensure the resolved binding is
_actually_ an import. This was causing us to attribute `print(rm.ANY)`
to `def requests_mock` here:

```python
import requests_mock as rm

def requests_mock(requests_mock: rm.Mocker):
    print(rm.ANY)
```

Closes https://github.com/astral-sh/ruff/issues/6180.
2023-07-30 22:16:25 +00:00
..
analyze Pull in RustPython parser (#6099) 2023-07-27 09:29:11 +00:00
binding.rs Add semantic analysis of type aliases and parameters (#6109) 2023-07-28 17:06:37 -05:00
context.rs Remove separate `ReferenceContext` enum (#4631) 2023-05-24 15:12:38 +00:00
definition.rs Pull in RustPython parser (#6099) 2023-07-27 09:29:11 +00:00
globals.rs Pull in RustPython parser (#6099) 2023-07-27 09:29:11 +00:00
lib.rs Move `StarImport` to its own module (#5186) 2023-06-20 13:12:46 -04:00
model.rs Avoid falsely marking non-submodules as submodule aliases (#6182) 2023-07-30 22:16:25 +00:00
node.rs Pull in RustPython parser (#6099) 2023-07-27 09:29:11 +00:00
reference.rs Remove parser dependency from ruff-python-ast (#6096) 2023-07-26 17:47:22 +02:00
scope.rs Add semantic analysis of type aliases and parameters (#6109) 2023-07-28 17:06:37 -05:00
star_import.rs Move `StarImport` to its own module (#5186) 2023-06-20 13:12:46 -04:00