[ty] Improve diagnostics if the user attempts to import a stdlib module that does not exist on their configured Python version (#18403)
This commit is contained in:
@@ -176,3 +176,32 @@ emitted for the `import from` statement:
|
||||
# error: [unresolved-import]
|
||||
from does_not_exist import foo, bar, baz
|
||||
```
|
||||
|
||||
## Attempting to import a stdlib module that's not yet been added
|
||||
|
||||
<!-- snapshot-diagnostics -->
|
||||
|
||||
```toml
|
||||
[environment]
|
||||
python-version = "3.10"
|
||||
```
|
||||
|
||||
```py
|
||||
import tomllib # error: [unresolved-import]
|
||||
from string.templatelib import Template # error: [unresolved-import]
|
||||
from importlib.resources import abc # error: [unresolved-import]
|
||||
```
|
||||
|
||||
## Attempting to import a stdlib module that was previously removed
|
||||
|
||||
<!-- snapshot-diagnostics -->
|
||||
|
||||
```toml
|
||||
[environment]
|
||||
python-version = "3.13"
|
||||
```
|
||||
|
||||
```py
|
||||
import aifc # error: [unresolved-import]
|
||||
from distutils import sysconfig # error: [unresolved-import]
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user