Release Notes
Bug fixes
- Fix false-positive diagnostics if a function parameter is annotated with
type[P]
whereP
is a protocol class (#19947) - Fix ANSI colors in terminal output on old Windows terminals (#19984)
- Fix protocol interface inference for protocols in stub files with
ClassVar
members and "subprotocols" that extend other protocols (#19950) - Fix inference of equality comparisons between enum members (#19666)
- Remove incorrect type narrowing for
if type(x) is C[int]
(#19926) - Improve detection of
TypeError
s resulting from protocol classes illegally inheriting from non-protocol classes (#19941). We previously detected this error, but only when the protocol class illegally inherited from a non-generic class or an unspecialized generic class. We now also detect it when the protocol class inherits from a specialized generic class. - Fix incorrectly precise type inference in some situations involving nested scopes (#19908)
- Fix unpacking a type alias with a precise tuple spec (#19981)
NamedTuple
semantics improvements
- Synthesize read-only properties for all declared members on
NamedTuple
classes (#19899) - Allow any instance of a
NamedTuple
class to be passed to a function parameter annotated withtyping.NamedTuple
(#19915) - Detect
NamedTuple
classes where fields without default values illegally follow fields with default values (#19945). This causesTypeError
to be raised at runtime. - Detect illegal multiple inheritance with
NamedTuple
(#19943). This causesTypeError
to be raised at runtime.
Other typing and semantics improvements
- Add support for stubs packages with
partial
in theirpy.typed
files (#19931) - Look for
site-packages
directories in<sys.prefix>/lib64/
as well as<sys.prefix>/lib/
on non-Windows systems (#19978). This change fixes a number ofunresolved-import
false-positive diagnostics reported by Poetry users. - Add diagnostics for invalid
await
expressions (#19711) - Add
else
-branch narrowing forif type(a) is A
whenA
is@final
(#19925) - Improve solving of typevars with defaults, and
typing.Self
(#19786) - Support the
kw_only
parameter fordataclasses.dataclass()
anddataclasses.field()
(#19677) - Sync vendored typeshed stubs (#19923). Typeshed diff.
Server improvements
- Improve goto/hover for definitions (#19976)
Performance improvements
- Short-circuit a server inlay hints request if all settings under
ty.inlayHints
are disabled (#19963) - Speedup server tracing checks (#19965)
- Add caching to logic for inferring whether a class is a
NamedTuple
, a dataclass or aTypedDict
(#19912) - Speedup project file discovery (#19913)
Contributors
- @dcreager
- @MichaReiser
- @sharkdp
- @github-actions
- @mtshiba
- @theammir
- @AlexWaygood
- @thejchap
- @Gankra
- @MatthewMckee4
- @carljm
Install ty 0.0.1-alpha.19
Install prebuilt binaries via shell script
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/astral-sh/ty/releases/download/0.0.1-alpha.19/ty-installer.sh | sh
Install prebuilt binaries via powershell script
powershell -ExecutionPolicy Bypass -c "irm https://github.com/astral-sh/ty/releases/download/0.0.1-alpha.19/ty-installer.ps1 | iex"