mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 05:45:24 +00:00
[ty] Fix duplicate diagnostics for unresolved module when an import from
statement imports multiple members (#17886)
This commit is contained in:
parent
457ec4dddd
commit
2f9992b6ef
17 changed files with 95 additions and 60 deletions
|
@ -121,7 +121,7 @@ class C: ...
|
|||
<!-- snapshot-diagnostics -->
|
||||
|
||||
```py
|
||||
import zqzqzqzqzqzqzq # error: [unresolved-import] "Cannot resolve import `zqzqzqzqzqzqzq`"
|
||||
import zqzqzqzqzqzqzq # error: [unresolved-import] "Cannot resolve imported module `zqzqzqzqzqzqzq`"
|
||||
```
|
||||
|
||||
## Unresolvable submodule imports
|
||||
|
@ -130,10 +130,10 @@ import zqzqzqzqzqzqzq # error: [unresolved-import] "Cannot resolve import `zqzq
|
|||
|
||||
```py
|
||||
# Topmost component resolvable, submodule not resolvable:
|
||||
import a.foo # error: [unresolved-import] "Cannot resolve import `a.foo`"
|
||||
import a.foo # error: [unresolved-import] "Cannot resolve imported module `a.foo`"
|
||||
|
||||
# Topmost component unresolvable:
|
||||
import b.foo # error: [unresolved-import] "Cannot resolve import `b.foo`"
|
||||
import b.foo # error: [unresolved-import] "Cannot resolve imported module `b.foo`"
|
||||
```
|
||||
|
||||
`a/__init__.py`:
|
||||
|
@ -164,3 +164,15 @@ from AveryLongPathAveryLongPathAveryLongPathAveryLongPathAveryLongPathAveryLongP
|
|||
|
||||
reveal_type(Foo()) # revealed: Foo
|
||||
```
|
||||
|
||||
## Multiple objects imported from an unresolved module
|
||||
|
||||
<!-- snapshot-diagnostics -->
|
||||
|
||||
If multiple members are imported from a module that cannot be resolved, only a single diagnostic is
|
||||
emitted for the `import from` statement:
|
||||
|
||||
```py
|
||||
# error: [unresolved-import]
|
||||
from does_not_exist import foo, bar, baz
|
||||
```
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue