Files
ruff/crates/ty_python_semantic/resources/mdtest/python_version.md
T
Alex Waygood 0471c14d1f [ty] Rename unresolved-import to import-not-found (#29960)
## Summary

ty currently reports `unresolved-import` for both a missing module and a
missing member in a `from` import. But the word "unresolved" is heavily
overloaded in Python, and has been reported by users as being confusing
(see https://github.com/astral-sh/ty/issues/2471). This PR renames the
rule to `import-not-found`, which describes the lookup failure in either
case.

Configuration, command-line flags, and ignore comments accept either
spelling. If several flags set this rule’s severity using different
spellings, the last flag wins. Existing baseline entries still match,
and rewriting a baseline uses the new name. Links to the old rule
heading still work.
2026-11-03 19:53:26 +00:00

1.3 KiB

Setting the target Python version

This file just makes sure that we can configure the target Python version and recognize version-specific features.

Python version 3.11

[environment]
python-version = "3.11"

Valid in 3.11:

import tomllib  # no error

Not valid in 3.11, only in 3.12 and later:

from collections.abc import Buffer  # error: [import-not-found]

Python version 3.12

[environment]
python-version = "3.12"

Valid in 3.12:

from collections.abc import Buffer  # no error

Not valid in 3.12, only in 3.13 and later:

from copy import replace  # error: [import-not-found]

Python version 3.13

[environment]
python-version = "3.13"

Valid in 3.13:

from copy import replace  # no error

Not valid in 3.13, only in 3.14 and later:

from compression import zstd  # error: [import-not-found]

Python version 3.14

[environment]
python-version = "3.14"

Valid in 3.14:

from compression import zstd  # no error

Not valid in 3.14, only in 3.15 and later:

import decimal, time

time.ctime(decimal.Decimal("1.5"))  # error: [invalid-argument-type]

Python version 3.15

[environment]
python-version = "3.15"

Valid in 3.15:

import decimal, time

time.ctime(decimal.Decimal("1.5"))  # no error