Files
ruff/crates/ty_python_semantic/resources/mdtest/python_version.md

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: [missing-module-member]

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: [missing-module-member]

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