github astral-sh/ty 1.1.0

44 minutes ago

Release Notes

Released on 2026-12-03.

Bug fixes

  • Report invalid-assignment for unsupported item or slice assignments even after a check such as out is not None narrows an object. (#30011)
  • Check assignments to a Django model instance’s pk using the underlying field’s write type, including Django expressions where the field accepts them. On the model class, pk has type property, so accessing a primary-key value attribute such as Book.pk.hex reports missing-attribute. (#31269)
  • Infer the stored ID type for a Django relation’s <field>_id when to_field names another relation. If the field is also the primary key, pk gets the same ID type. (#31268)
  • Preserve the NewType when a protocol uses a method whose return annotation is Self. For example, ExitStack.enter_context now returns the wrapped context manager’s NewType when its __enter__ returns Self. (#31211)
  • Preserve attribute types when a NewType wraps a class, including enum values, attributes supplied by a metaclass, and assignment types from dataclass field converters. Protocol checks use those types too. (#31234)
  • Infer enum members’ name and value attributes using Python’s override rules, including cases where an inherited enum.property supplies the value or a bare annotation leaves the generated property in place. (#31234)
  • Recognize that a NewType based on object can hold unhashable values, including through nested NewTypes. The negative branch of an isinstance(value, Hashable) check remains reachable, and unions with Hashable retain both alternatives. (#31232)
  • Report cyclic-class-definition for every class that participates in overlapping inheritance cycles, regardless of the order of its base classes. (#31298)
  • Report invalid-type-form when an IPython escape command such as !pwd appears where a type is expected in a notebook, preventing a crash. (#31238)
  • Fix false slot conflicts and missing-attribute errors when a lambda in a class-body loop uses := to bind a local variable with the same name as a slot. (#31150)
  • Highlight references only in the requested notebook cell so references in other cells don’t highlight unrelated code. (#31243)
  • Limit notebook document outlines to symbols defined in the requested cell. (#31243)
  • Fade the correct code in each notebook cell when an unreachable region spans multiple cells. (#31248)

LSP server

  • Offer completions for generated attributes and methods on Django model classes and instances, including inherited members such as foreign-key IDs, choice display methods, and date navigation methods. (#31272)
  • Distinguish escape sequences in semantic highlighting for strings, bytes, and the literal parts of f-strings and t-strings. Backslashes in raw strings retain ordinary string highlighting. (#31239)
  • Fix Expand Selection in notebooks so it includes intermediate expressions and stops at the current cell’s contents. (#31241)
  • Restore code folding for import blocks that end at a notebook cell boundary. (#31241)
  • Reduce the work needed for semantic highlighting, reference highlighting, code folding, and document outlines by reusing source text and line positions within each request. (#30669)

CLI

  • Show file counts as ty check --fix and ty check --add-ignore apply edits and recheck the project, with a separate indicator while writing changes. (#31147)
  • Make completed and remaining work easier to distinguish in progress bars when checking files or syncing script dependencies. (#31200)

Diagnostic improvements

  • Add autofixes for mismatched-*-name diagnostics that make the supplied name match the assignment target. ty check --fix applies fixes marked safe. Fixes for enums, named tuples, and sentinels are always marked unsafe. (#30628)

Performance improvements

  • Reduce work when opening or closing unchanged files with diagnosticMode set to openFilesOnly by reusing prior analysis. ty continues to report diagnostics only for open files. (#31252)
  • Reduce memory use when looking up a method on a large union of unrelated subclasses that inherit the same method. (#31288)
  • Resolve calls with multiple matching overloads faster when ty can rule out later overloads without building unions of the parameter types. (#31250)
  • Specialize nested generic types such as dict[str, list[T]] faster by skipping ParamSpec work for types without callable signatures. (#31195)
  • Specialize generic types faster by reusing declared variance, such as the invariance of list’s type parameter. (#31173)
  • Analyze try blocks faster by skipping repeated work to determine what values can reach an except handler when assignments and narrowing conditions are unchanged. (#31260)

Memory usage improvements

  • Reduce peak memory while analyzing files with many independent scopes, such as stubs with hundreds of methods. (#31171)
  • Use less memory to track which assignments and declarations can reach a given point in the code, especially when there is only one possible definition. (#31168)
  • Use less memory when simplifying unions by storing each pair of types once when checking redundancy in both directions. (#31182)
  • Reuse unchanged parameter lists when specializing callable types, as when Callable[[int], T] becomes Callable[[int], str]. (#31161)

Core type checking

  • Resolve imports across legacy namespace packages that set __path__ at module scope using from pkgutil import extend_path, including aliases for extend_path or pkgutil. (#31274)
  • Infer the tuple length and element types returned by struct.unpack_from from a known format string. For example, struct.unpack_from("<I?", buf) returns tuple[int, bool]. (#31230)
  • Infer more precise TypedDict.get results for unions of known literal keys when the fields have identical declared types and are either all required or all optional. For optional fields, ty also uses the shared field type to infer defaults such as {}. (#30897)
  • Resolve inherited method signatures correctly when checking mutually importing files in parallel and a protocol method’s return type refers back to the protocol through Self. (#29818)

Other changes

  • Explain how to install third-party stubs when migrating from Pyright, with uv add --dev types-PyYAML as an example, and how ty automatically uses stub packages already installed for mypy. (#5207)

Contributors

Install ty 1.1.0

Install prebuilt binaries via shell script

curl --proto '=https' --tlsv1.2 -LsSf https://releases.astral.sh/github/ty/releases/download/1.1.0/ty-installer.sh | sh

Install prebuilt binaries via powershell script

powershell -ExecutionPolicy Bypass -c "irm https://releases.astral.sh/github/ty/releases/download/1.1.0/ty-installer.ps1 | iex"

Download ty 1.1.0

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.