[ty] Use 3.14 as the default version (#20759)

## Summary

Bump the latest supported Python version of ty to 3.14 and updates some
references from 3.13 to 3.14.

This also fixes a bug with `dataclasses.field` on 3.14 (which adds a new
keyword-only parameter to that function, breaking our previously naive
matching on the parameter structure of that function).

## Test Plan

A `ty check` on a file with template strings (without any further
configuration) doesn't raise errors anymore.
This commit is contained in:
David Peter 2025-10-08 11:38:47 +02:00 committed by GitHub
parent abbbe8f3af
commit 1f1542db51
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 117 additions and 50 deletions

View file

@ -544,6 +544,55 @@ class A:
y: int
```
### `kw_only` - Python 3.13
```toml
[environment]
python-version = "3.13"
```
```py
from dataclasses import dataclass, field
@dataclass
class Employee:
e_id: int = field(kw_only=True, default=0)
name: str
Employee("Alice")
Employee(name="Alice")
Employee(name="Alice", e_id=1)
Employee(e_id=1, name="Alice")
Employee("Alice", e_id=1)
Employee("Alice", 1) # error: [too-many-positional-arguments]
```
### `kw_only` - Python 3.14
```toml
[environment]
python-version = "3.14"
```
```py
from dataclasses import dataclass, field
@dataclass
class Employee:
# Python 3.14 introduces a new `doc` parameter for `dataclasses.field`
e_id: int = field(kw_only=True, default=0, doc="Global employee ID")
name: str
Employee("Alice")
Employee(name="Alice")
Employee(name="Alice", e_id=1)
Employee(e_id=1, name="Alice")
Employee("Alice", e_id=1)
Employee("Alice", 1) # error: [too-many-positional-arguments]
```
### `slots`
If a dataclass is defined with `slots=True`, the `__slots__` attribute is generated as a tuple. It