[ty] Add a note to the diagnostic if a new builtin is used on an old Python version (#18068)
## Summary If the user tries to use a new builtin on an old Python version, tell them what Python version the builtin was added on, what our inferred Python version is for their project, and what configuration settings they can tweak to fix the error. ## Test Plan Snapshots and screenshots: 
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
# Diagnostics for unresolved references
|
||||
|
||||
## New builtin used on old Python version
|
||||
|
||||
<!-- snapshot-diagnostics -->
|
||||
|
||||
```toml
|
||||
[environment]
|
||||
python-version = "3.9"
|
||||
```
|
||||
|
||||
```py
|
||||
aiter # error: [unresolved-reference]
|
||||
```
|
||||
@@ -0,0 +1,32 @@
|
||||
---
|
||||
source: crates/ty_test/src/lib.rs
|
||||
expression: snapshot
|
||||
---
|
||||
---
|
||||
mdtest name: unresolved_reference.md - Diagnostics for unresolved references - New builtin used on old Python version
|
||||
mdtest path: crates/ty_python_semantic/resources/mdtest/diagnostics/unresolved_reference.md
|
||||
---
|
||||
|
||||
# Python source files
|
||||
|
||||
## mdtest_snippet.py
|
||||
|
||||
```
|
||||
1 | aiter # error: [unresolved-reference]
|
||||
```
|
||||
|
||||
# Diagnostics
|
||||
|
||||
```
|
||||
error[unresolved-reference]: Name `aiter` used when not defined
|
||||
--> src/mdtest_snippet.py:1:1
|
||||
|
|
||||
1 | aiter # error: [unresolved-reference]
|
||||
| ^^^^^
|
||||
|
|
||||
info: `aiter` was added as a builtin in Python 3.10
|
||||
info: The inferred target version of your project is Python 3.9
|
||||
info: If using a pyproject.toml file, consider adjusting the `project.requires-python` or `tool.ty.environment.python-version` field
|
||||
info: rule `unresolved-reference` is enabled by default
|
||||
|
||||
```
|
||||
Reference in New Issue
Block a user