UP035: No violations when importing an entire module and using deprecated/moved class/method
- Dominant language
- Rust
- Stars
- 49.6k
- Forks
- 2.4k
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 458
Description
When explicitly importing deprecated/moved classes/methods UP035 works as expected. Example snippet that will raise a UP035:
```python
from typing import Mapping
# Import from `collections.abc` instead: `Mapping`Ruff[UP035](https://beta.ruff.rs/docs/rules/deprecated-import)
```
However, when importing the entire module from where the deprecated/moved submodule originally was, no error is raised. Example snippet:
```python
import typing
x: typing.Mapping[str, int] = {}
# No error is raised
```
I would think the expected behaviour would be to raise an UP035 violation on the line where the deprecated/moved class is defined, in the above case line 2.
Settings:
Ruff 0.0.290
Ruff-VSCode v2023.38.0 with `fromEnvironment` as import-strategy
Enabled UP in pyproject.toml
Contributor guide
Research direction
Reproduce the two Python snippets with UP035 enabled, comparing explicit imports with whole-module imports. Start at Ruff's UP035 rule entry point and its existing tests; done means the typing.Mapping use in the module-import case is reported on the annotation line, without regressing explicit-import diagnostics.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100