pypi ty 0.0.109

one hour ago

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 preserve list[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-argument when copy.replace or a generated __replace__ receives an init=False field. This applies to standard-library and Pydantic dataclasses, attrs classes, and other classes using dataclass_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 self as a field keyword in dataclass and Pydantic constructors and in dataclass and named tuple replacement methods. (#29341)
  • Infer Self from 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 with Self. (#29341)

LSP server

  • Speed up member completions when looking up documentation for classes and enums with many attributes, such as Flet’s Icons and PySide6’s Qt.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. Run ty check --fix to 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 Self across 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 boto3 client calls. (#30789)
  • Speed up repeated calls to overloads that share a type variable, such as TypedDict.get overloads that share the type of the default argument. (#30813)
  • Check calls to ordinary functions faster when many arguments are captured by *args or **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’s CoreSchema. (#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 match statements 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 an isinstance check narrow a value to a more specific type when a recursively inferred type argument was approximated as object. (#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.startswith checks 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 float and complex. (#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.include pattern 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 with blocks. (#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 infer int when 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 _id takes the keyword id by default. An explicit alias takes precedence. (#30824)
  • Infer the specific exception type bound by except ... as exc when 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.validator on fields declared with attrs.field or attr.ib, fixing false missing-attribute errors and preserving the decorated method’s signature. (#30839)
  • Fix false not-callable errors on attrs @field_name.default decorators 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 | sh

Install 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

File Platform Checksum
ty-aarch64-apple-darwin.tar.gz Apple Silicon macOS checksum
ty-x86_64-apple-darwin.tar.gz Intel macOS checksum
ty-aarch64-pc-windows-msvc.zip ARM64 Windows checksum
ty-i686-pc-windows-msvc.zip x86 Windows checksum
ty-x86_64-pc-windows-msvc.zip x64 Windows checksum
ty-aarch64-unknown-linux-gnu.tar.gz ARM64 Linux checksum
ty-i686-unknown-linux-gnu.tar.gz x86 Linux checksum
ty-powerpc64le-unknown-linux-gnu.tar.gz PPC64LE Linux checksum
ty-riscv64gc-unknown-linux-gnu.tar.gz RISCV Linux checksum
ty-s390x-unknown-linux-gnu.tar.gz S390x Linux checksum
ty-x86_64-unknown-linux-gnu.tar.gz x64 Linux checksum
ty-armv7-unknown-linux-gnueabihf.tar.gz ARMv7 Linux checksum
ty-aarch64-unknown-linux-musl.tar.gz ARM64 MUSL Linux checksum
ty-i686-unknown-linux-musl.tar.gz x86 MUSL Linux checksum
ty-x86_64-unknown-linux-musl.tar.gz x64 MUSL Linux checksum
ty-arm-unknown-linux-musleabihf.tar.gz ARMv6 MUSL Linux (Hardfloat) checksum
ty-armv7-unknown-linux-musleabihf.tar.gz ARMv7 MUSL Linux checksum

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/ty

You 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>

Don't miss a new ty release

NewReleases is sending notifications on new releases.