Release Notes
Released on 2026-11-23.
Bug fixes
- Preserve type variables from the surrounding scope when inferring generic calls. For example, forwarding a
list[T]through a generic helper can now preservelist[T]as the result type. (#30423) - Use the receiver’s type to select overloads when a method is called through an alias. For example, an alias of a Redis method can now infer an awaitable return type for an asynchronous client. (#29341)
- Report
unknown-argumentwhencopy.replaceor a generated__replace__receives aninit=Falsefield. This applies to standard-library and Pydantic dataclasses, attrs classes, and other classes usingdataclass_transform. (#30850) - Preserve literals when union simplification discards the member that would have made them redundant. This also fixes a crash when checking some unions of recursive protocols. (#30774)
- Accept
selfas a field keyword in dataclass and Pydantic constructors and in dataclass and named tuple replacement methods. (#29341) - Infer
Selffrom the receiver and field arguments in generated dataclass and named tuple methods, so an inherited method can accept a base-class value for a field annotated withSelf. (#29341)
LSP server
- Speed up member completions when looking up documentation for classes and enums with many attributes, such as Flet’s
Iconsand PySide6’sQt.Key. (#30707)
Diagnostic improvements
- Rename the diagnostic for unknown rules in ignore comments to
unknown-rule-in-ignore-comment. The old name,ignore-comment-unknown-rule, remains a compatibility alias in configuration and ignore comments. Runty check --fixto update ignore comments automatically. (#30827)
Performance improvements
Calls and overloads
- Check nested calls such as NumPy’s
dot(dot(a, b), c)faster when several outer overloads give the inner call the same expected return type. (#30785) - Reuse successful inference for ordinary type variables and
Selfacross generic calls with matching parameter and argument types, when there’s no expected return type or unpacked variadic parameter. (#30815) - Speed up overload resolution by reusing comparisons of parameter and return types when several overloads match. (#30781)
- Check whether matching overloads cover all possible arguments faster when consecutive overloads infer the same argument types, as can happen with
boto3client calls. (#30789) - Speed up repeated calls to overloads that share a type variable, such as
TypedDict.getoverloads that share the type of the default argument. (#30813) - Check calls to ordinary functions faster when many arguments are captured by
*argsor**kwargs. (#30734) - Speed up call inference by avoiding unnecessary copies of inferred argument types, including on the first pass of generic inference. (#30826)
Generics and recursive types
- Speed up type compatibility checks that must hold for every specialization of a type variable, including assignability and equivalence checks. (#30748)
- Solve generic type constraints faster by reusing results for pairs of constraints that yield no new information. (#30788)
- Speed up inference for recursive types whose generic arguments share nested unions. (#30735)
- Limit alias expansion and cycle checks to aliases and recursive types. (#30828)
Classes and TypedDicts
- Check assignments to instance attributes faster when repeated assignments give the attribute a wide union type, as in tokenizer state machines. (#30775)
- Speed up repeated comparisons between
TypedDicts and unions, including recursive unions such as Pydantic’sCoreSchema. (#30555) - Determine whether a class is abstract faster when its methods use decorators that preserve the method’s type. (#30802)
- Check enums with built-in tuple values faster when using the bundled standard-library stubs. (#30777)
- Check attribute assignments and deletions faster when the class and its bases are unfrozen. (#30820)
- Speed up checks for inherited dataclass ordering by looking up decorators only on base classes with ordering enabled. (#30810)
Unions, narrowing, and literals
- Speed up large
matchstatements that rule out many literal values, such as integer opcode dispatch. (#30736, #30767) - Reuse the result of simplifying wide unions when narrowing types or merging assignments across branches. (#30705)
- Speed up narrowing when a name or attribute has a single possible type. With
analysis.strict-generic-narrowing = true, this also lets anisinstancecheck narrow a value to a more specific type when a recursively inferred type argument was approximated asobject. (#30829) - Simplify unions of fixed-length tuples faster when their first elements have disjoint literal types. (#30793)
- Simplify unions faster when their members come from different unresolved inference cycles. (#30791)
- Speed up
str.startswithchecks on values with many possible literal strings, such as enum member names. (#30811) - Reduce the cost of narrowing names, attributes, and subscripts, including when the relevant conditions are in the current scope. (#30773, #30816)
- Simplify unions faster when they collapse to a single type. (#30817)
Collections and iteration
- Infer collection literals faster when several elements widen to the same type, such as a list of floats. Reuse the numeric unions ty infers for
floatandcomplex. (#30796, #30695) - Infer long tuple literals faster when many elements widen to the same built-in type. (#30677)
- Reuse the inferred element type when iterating over the same synchronous iterable type again. (#30814)
File discovery, imports, and control flow
- Speed up control flow analysis in large dispatch functions by reusing narrowing and reachability results along shared paths. (#30787, #30784)
- Discover files faster with the default
src.includepattern or when all exclude patterns apply only to directories. (#30772, #30794) - Check which code is reachable faster in large scopes, including those where wildcard imports bring many names into scope. (#30771, #30778)
- Speed up control flow analysis when branches leave the same definitions in scope, including in deeply nested
withblocks. (#30803) - Resolve references to imported submodules faster after dotted imports such as
import a.b.c. (#30722)
Core type checking
- Infer
enum.auto()values from preceding members in both class-based and functional enums. For sequential integer values, ty counts from the last value through Python 3.10 and from the highest value for Python 3.11 and later targets. It can inferintwhen the exact value depends on runtime data or control flow. (#30548) - Use the underscore-stripped name of an attrs field in constructors and
copy.replace. For example, a field accessed as_idtakes the keywordidby default. An explicitaliastakes precedence. (#30824) - Infer the specific exception type bound by
except ... as excwhen the handler uses a type alias for a tuple of exception classes or a union of an exception class and a tuple. (#30758) - Recognize
@field_name.validatoron fields declared withattrs.fieldorattr.ib, fixing false missing-attribute errors and preserving the decorated method’s signature. (#30839) - Fix false
not-callableerrors on attrs@field_name.defaultdecorators for fields that ty treats as required constructor arguments. (#30839) - Infer the enum type when conditional member declarations make an alias’s canonical member uncertain. (#30548)
Contributors
Install ty 0.0.109
Install prebuilt binaries via shell script
curl --proto '=https' --tlsv1.2 -LsSf https://releases.astral.sh/github/ty/releases/download/0.0.109/ty-installer.sh | shInstall prebuilt binaries via powershell script
powershell -ExecutionPolicy Bypass -c "irm https://releases.astral.sh/github/ty/releases/download/0.0.109/ty-installer.ps1 | iex"Download ty 0.0.109
Verifying GitHub Artifact Attestations
The artifacts in this release have attestations generated with GitHub Artifact Attestations. These can be verified by using the GitHub CLI:
gh attestation verify <file-path of downloaded artifact> --repo astral-sh/tyYou can also download the attestation from GitHub and verify against that directly:
gh attestation verify <file-path of downloaded artifact> --bundle <file-path of downloaded attestation>