ruff/crates/ruff_linter/resources/test/fixtures/pyflakes
Takayuki Maeda 76a6b7e3e2
[pyflakes] Fix allowed-unused-imports matching for top-level modules (F401) (#20115)
<!--
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`.
2025-08-28 13:02:50 +00:00
..
F401_24
F401_25__all_nonempty
F401_26__all_empty
F401_27__all_mistyped
F401_28__all_multiple
F401_29__all_conditional
F401_33 [pyflakes] Fix infinite loop with unused local import in __init__.py (F401) (#15517) 2025-01-16 10:43:32 -05:00
project/foo
__init__.py
builtins.py
F50x.py
F401_0.py
F401_1.py
F401_2.py
F401_3.py
F401_4.py
F401_5.py
F401_6.py
F401_7.py
F401_8.py
F401_9.py
F401_10.py
F401_11.py
F401_12.py
F401_13.py
F401_14.py
F401_15.py
F401_16.py
F401_17.py
F401_18.py
F401_19.py
F401_20.py
F401_21.py
F401_22.py
F401_23.py
F401_30.py
F401_31.py
F401_32.py [pyflakes] Ignore errors in @no_type_check string annotations (F722, F821) (#15215) 2025-01-03 10:05:45 +01:00
F401_34.py [pyflakes] Visit forward annotations in TypeAliasType as types (F401) (#15829) 2025-01-30 18:06:38 -05:00
F401_35.py [pyflakes] Fix allowed-unused-imports matching for top-level modules (F401) (#20115) 2025-08-28 13:02:50 +00:00
F402.ipynb
F402.py
F403.py
F404_0.py
F404_1.py
F405.py
F406.py
F407.py
F502.py
F503.py
F504.py [pyflakes] Mark F504/F522/F523 autofix as unsafe if there's a call with side effect (#18839) 2025-06-26 08:48:29 +00:00
F521.py
F522.py [pyflakes] Mark F504/F522/F523 autofix as unsafe if there's a call with side effect (#18839) 2025-06-26 08:48:29 +00:00
F523.py [pyflakes] Mark F504/F522/F523 autofix as unsafe if there's a call with side effect (#18839) 2025-06-26 08:48:29 +00:00
F524.py
F525.py
F541.py
F601.py
F602.py
F622.py
F631.py
F632.py
F633.py
F634.py
F701.py
F702.py
F704.py [ty] Don't warn yield not in function when yield is in function (#18008) 2025-05-21 18:16:25 +02:00
F706.py
F707.py
F722.py Parse triple quoted string annotations as if parenthesized (#15387) 2025-01-16 11:38:15 +05:30
F722_1.py [pyflakes] Ignore errors in @no_type_check string annotations (F722, F821) (#15215) 2025-01-03 10:05:45 +01:00
F811_0.py
F811_1.py
F811_2.py
F811_3.py
F811_4.py
F811_5.py
F811_6.py
F811_7.py
F811_8.py
F811_9.py
F811_10.py
F811_11.py
F811_12.py
F811_13.py
F811_14.py
F811_15.py
F811_16.py
F811_17.py
F811_18.py
F811_19.py
F811_20.py
F811_21.py
F811_22.py
F811_23.py
F811_24.py
F811_25.py
F811_26.py
F811_27.py
F811_28.py
F811_29.pyi
F811_30.py
F811_31.py
F811_32.py Avoid removing too many imports in redefined-while-unused (#15585) 2025-01-19 13:28:08 -05:00
F821_0.py
F821_1.py
F821_2.py
F821_3.py
F821_4.py
F821_5.py
F821_5.pyi
F821_6.py
F821_7.py
F821_8.pyi
F821_9.py
F821_10.py
F821_11.py
F821_11.pyi
F821_12.py
F821_13.py
F821_14.py
F821_15.py
F821_16.py
F821_17.py
F821_18.py
F821_19.py
F821_20.py
F821_21.py
F821_22.ipynb
F821_23.py
F821_24.py
F821_25.py
F821_26.py
F821_26.pyi
F821_27.py
F821_28.py
F821_29.py
F821_30.py Visit PEP 764 inline TypedDicts' keys as non-type-expressions (#15073) 2024-12-30 15:04:55 +05:30
F821_31.py [pyflakes] Ignore errors in @no_type_check string annotations (F722, F821) (#15215) 2025-01-03 10:05:45 +01:00
F821_32.pyi [pyflakes] Treat arguments passed to the default= parameter of TypeVar as type expressions (F821) (#15679) 2025-01-22 23:04:20 +00:00
F822_0.py
F822_0.pyi
F822_1.py
F822_1b.py
F822_2.py
F822_3.py
F823.py
F841_0.py Add a ScopeKind for the __class__ cell (#20048) 2025-08-26 09:49:08 -04:00
F841_1.py
F841_2.py
F841_3.py
F842.py
F901.py
future_annotations.py
multi_statement_lines.py
typing_modules.py