[ty] Add hint about resolved Python version when a user attempts to import a member added on a newer version (#21615)
## Summary Fixes https://github.com/astral-sh/ty/issues/1620. #20909 added hints if you do something like this and your Python version is set to 3.10 or lower: ```py import typing typing.LiteralString ``` And we also have hints if you try to do something like this and your Python version is set too low: ```py from stdlib_module import new_submodule ``` But we don't currently have any subdiagnostic hint if you do something like _this_ and your Python version is set too low: ```py from typing import LiteralString ``` This PR adds that hint! ## Test Plan snapshots --------- Co-authored-by: Aria Desires <aria.desires@gmail.com>
This commit is contained in:
@@ -32,7 +32,8 @@ error[unresolved-attribute]: Module `datetime` has no member `UTC`
|
||||
5 | # error: [unresolved-attribute]
|
||||
6 | reveal_type(datetime.fakenotreal) # revealed: Unknown
|
||||
|
|
||||
info: Python 3.10 was assumed when accessing `UTC` because it was specified on the command line
|
||||
info: The member may be available on other Python versions or platforms
|
||||
info: Python 3.10 was assumed when resolving the `UTC` attribute because it was specified on the command line
|
||||
info: rule `unresolved-attribute` is enabled by default
|
||||
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user