Repository navigation
Immutable
release. Only release title and notes can be modified.
Release Notes
Released on 2026-12-05.
Bug fixes
- Fix a crash and a hang when hovering inside a function whose decorator returns a callable that refers back to the function, including before ty has checked the file. (#31517)
- Fix a stack overflow when comparing recursive generic protocols whose inherited generic method takes a union of those protocols. (#29919)
- Fix a crash when hovering over
.valuebefore ty has checked an enum whose member values depend on themselves. (#31514) - Preserve the outer type when recursive inference keeps producing deeper types or wider unions. This lets ty report
missing-attributemore consistently across different file-checking orders. (#30240) - Narrow tagged unions through nested type aliases to avoid false
missing-attributeerrors. This works with equality, identity, and truthiness checks on tag attributes, as well as withmatchvalue patterns. (#31210) - Keep the new type when an assignment expression rebinds a variable after its tag was read in the same comparison. (#31210)
- Infer
ParamSpecfrom the whole union so callbacks keep their parameter lists even when another union member is non-callable. This catchesinvalid-argument-typeerrors on calls that previously accepted any arguments and preserves shared parameter lists when narrowing withTypeIs. (#31209) - Resolve top-level
auto()calls in tuple-valued members of class-based and functional enums when targeting Python 3.11 or later. Constructor checks use the generated values, matching Python’s behavior since 3.11.1 and avoiding falseinvalid-assignmenterrors. (#31417) - Preserve the
NewTypeforSelfin__call__parameter and return types when checking aNewTypeinstance against a callback protocol orCallable. (#31231) - Find valid specializations more reliably when checking whether generic types can overlap. ty can find an early valid solution even when checking every candidate would exceed its search budget. (#31296)
LSP server
- Return code folding ranges faster for files with very long lines, such as multiline function signatures with a large dictionary default on a single line. (#31525)
- Speed up repeated Go to Implementation searches for different classes by reusing information from files already searched. (#30712)
- Compute inlay hints faster when they refer to types that may need importing by checking only names relevant to the import. (#30694)
Performance improvements
- Speed up initial project checks and editor diagnostics for large new or edited files by inferring types in independent scopes within a file in parallel. (#31329)
- Speed up semantic highlighting on very long lines in editors that use UTF-16 or UTF-32 positions. (#31506)
- Avoid exponential slowdowns when narrowing a large union in
matchcases that follow aMapping()ordict()pattern. (#31279) - Speed up concatenation of large unions of string or bytes literals, and some operations on integer literals, by stopping once the result type and any diagnostics are determined. (#31448)
- Speed up
inandnot inchecks against lists, sets, and tuples with known elements when the value being tested can be one of many literals. (#31447) - Build large unions of class objects, modules,
TypedDicts, or bound methods faster, especially when inferring types from large class registries. (#31259) - Extend large unions faster by reusing the work of simplifying their shared members. This helps when a union grows at each step of a chain of dictionary merges. (#29304)
- Speed up narrowing across long sequences of checks that each rule out another possibility, such as successive
isinstancechecks against different subclasses. (#30769) - Check
TypedDictconstructor calls such asRow(row, x=1)faster when the input already has the targetTypedDicttype and keyword arguments override selected fields. (#31456) - Narrow types faster across long chains of
andororconditions, including when a surroundingtryblock needs to track what can reach an exception handler. (#31463) - Check whether a candidate type satisfies multiple upper bounds faster, especially when the bounds involve large unions or the first bound rules out the candidate. (#31367, #31402)
- Infer the variance of type parameters faster when multiple variants refer back to the same recursive union. (#31365)
- Infer type arguments faster when candidate solutions share bounds by reusing information about which type variables those bounds contain and constrain. (#31400, #31401)
- Spend less time preserving source order when building unions and intersections from generic constraints. (#31404, #31406)
- Generate diagnostics for failed generic inference faster when none of the type variables has a fixed set of allowed types. (#31405)
- Specialize generics with one type argument, such as
list[T], faster by avoiding temporary allocations. (#31206) - Reduce the cost of type comparisons when the same type variable appears on both sides. (#31403)
- Parse installed packages and bundled stubs faster by skipping a buffer resize for tokens that will be discarded. (#31441)
Memory usage improvements
- Use less memory when narrowing values through long chains of literal comparisons, including when the value is unannotated. (#31418, #31458)
- Use less memory when checking large
ifandmatchstatements whose branches exit early, such as dispatch code with areturnin each branch. (#31445) - Use less memory when comparing large enums with strings. If ty cannot establish that different member names refer to the same value, it leaves the string type unchanged in the unequal branch. (#31290)
- Use less memory when loading installed packages and bundled stubs by retaining parser tokens only when needed. (#31175)
- Use less memory when repeated
isinstancechecks narrow a value to an intersection of several types that need no type-variable orNewTypeexpansion. (#31471) - Use less memory when loading stubs by creating parameter definitions only for functions whose parameters ty needs to inspect. (#31185)
- Use less stack space when inferring deeply nested expressions, allowing ty to check longer chains of method calls and binary operations. (#31426, #31427)
- Use less stack space when tracing local assignments back to environment checks such as
sys.version_infocomparisons. This lets ty follow longer chains with the opt-inredundant-condition-strictrule enabled. (#31254)
Core type checking
- Infer the remaining allowed type when an inferred constraint rules out the other declared choices for a type variable. For example, if
Tis constrained tointorstrand inference rules outint, ty infersstr. (#31286)
Contributors
Install ty 1.2.0
Install prebuilt binaries via shell script
curl --proto '=https' --tlsv1.2 -LsSf https://releases.astral.sh/github/ty/releases/download/1.2.0/ty-installer.sh | shInstall prebuilt binaries via powershell script
powershell -ExecutionPolicy Bypass -c "irm https://releases.astral.sh/github/ty/releases/download/1.2.0/ty-installer.ps1 | iex"Download ty 1.2.0
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>