mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-28 10:50:26 +00:00
<!--
Thank you for contributing to Ruff/ty! To help us out with reviewing,
please consider the following:
- Does this pull request include a summary of the change? (See below.)
- Does this pull request include a descriptive title? (Please prefix
with `[ty]` for ty pull
requests.)
- Does this pull request include references to any relevant issues?
-->
## Summary
<!-- What's the purpose of the change? What does it do, and why? -->
Fixes #19664
Fix allowed unused imports matching for top-level modules.
I've simply replaced `from_dotted_name` with `user_defined`. Since
QualifiedName for imports is created in
crates/ruff_python_semantic/src/imports.rs, I guess it's acceptable to
use `user_defined` here. Please tell me if there is better way.
0c5089ed9e/crates/ruff_python_semantic/src/imports.rs (L62)
## Test Plan
<!-- How was it tested? -->
I've added a snapshot test
`f401_allowed_unused_imports_top_level_module`.
16 lines
283 B
Python
16 lines
283 B
Python
"""
|
|
Test: allowed-unused-imports-top-level-module
|
|
"""
|
|
|
|
# No errors
|
|
|
|
def f():
|
|
import hvplot
|
|
def f():
|
|
import hvplot.pandas
|
|
def f():
|
|
import hvplot.pandas.plots
|
|
def f():
|
|
from hvplot.pandas import scatter_matrix
|
|
def f():
|
|
from hvplot.pandas.plots import scatter_matrix
|