Bot releases are visible (Hide)
Published by github-actions[bot] 5 months ago
Bug Fixes:
match
statement uses an empty (zero-element) sequence pattern and the subject expression type is a tuple that potentially (but does not always) have a zero length.match
statement includes a class pattern with a runtime-checkable protocol class.TypeIs
type guard that resulted in incorrect type narrowing in the negative (else) case.*args: P.args
parameter was used in the expression len(args) >= x
.Literal
with multiple arguments is used in a value expression. It should be treated as a UnionType
special form in this case.Enhancements:
Behavior Changes:
...
in compliance with latest typing spec.__init_subclass__
checks for classes that have ABCMeta
as a metaclass. Previously, these were exempted from __init_subclass__
because ABCMeta
has a custom __new__
method, but we know that this metaclass calls through to type.__new__
which calls __init_subclass__
.Published by github-actions[bot] 6 months ago
Bug Fixes:
item
and keys
attributes for named tuple classes.__new__
or __init__
method.yield
statement is used within a lambda following a function.__extra_items__
(PEP 728) with a TypedDict
imported from typing_extensions
.Callable()
is used as a class pattern and the subject type is Any
or Unknown
.Final
variable within a class body.type[Foo]
where Foo
is a type alias.Behavior Changes:
__new__
method contains parameters based on field names and the __init__
method contains a general *args: Any, **kwargs: Any
parameter signature. Previously, this was swapped, but the new way is more faithful to the runtime.TypeIs
to use the same logic as isinstance
type narrowing logic for consistency.Published by github-actions[bot] 6 months ago
Enhancements:
@deprecation
messages for decorators that wrap a function in a callable object. The deprecated message is now propagated through the ParamSpec and the __call__
method.Behavior Changes:
self
annotation in __init__
. It was previously reported under reportGeneralTypeIssues
, but it's now moved to reportInvalidTypeVarUse
. This was done to help typeshed maintainers migrate away from this pattern.try
or with
block. Previously, such errors were exempt, but this is inconsistent with other type checks in pyright which eschew the practice of using exception handling for normal code flow.Bug Fixes:
__call__
methods in a metaclass. This change aligns pyright's behavior to the typing spec.kwargs
when used in a type guard of the form if "a" in kwargs
.self
parameter types.Published by github-actions[bot] 6 months ago
Enhancements:
len(x) == L
type guard pattern (where x is a tuple) to support <
, <=
, >
and >=
comparisons as well.in
and not in
operators that target TypedDicts to also support constrained TypeVars that use TypedDicts as value constraints.Behavior Changes:
self
parameter in __init__
method when evaluating constructor call so pyright conforms to the latest typing spec.type[T]
where T
is a TypeVar with no explicit upper bound (and therefore has an implicit upper bound of object
). According to the newly-clarified typing spec, this should enforce the constructor signature of object
.__call__
method with a __new__
method. The new behavior is now compliant with the typing spec.__new__
method of the class returns a value that indicates the __init__
method should be ignored.self
in the __init__
method.__new__
method.Bug Fixes:
@property
decorator to a method that has already had a decorator applied to it.reportAbstractUsage
error when an abstract class is captured through a type[T]
.NoReturn
return type to a Callable[..., T]
.Published by github-actions[bot] 6 months ago
Bug Fixes:
TypeIs
, which is documented to have an invariant type parameter.match
statement includes a *
element and the subject includes a tuple with an element with indeterminate length.Enhancements:
Literal
type annotation that includes a string with a named unicode escape sequence. These are not supported.Published by github-actions[bot] 7 months ago
Bug Fixes:
__new__
on a dataclass, namedtuple, or TypedDict. These classes all require synthesized __new__
methods.__new__
or __init__
method cannot be bound without a type violation.enum.Flag
.K in TD
type guard pattern (where TD
is a TypedDict and K
is a literal key). Narrowing was skipped if the RHS operand was not a simple identifier.Enhancements:
match
statement when subject consists of a tuple expression and patterns exhaustively match the tuple.None
.get
method for closed TypedDict
classes (as defined in PEP 728).Behavior Changes:
Final
variables (that are not explicitly marked ClassVar
) within dataclass class bodies. This is consistent with the runtime and this proposed change to the typing spec.Published by github-actions[bot] 7 months ago
Bug Fixes:
type
statement uses a type parameter and encloses the RHS in quotes.reportImplicitOverride
diagnostic if the class derives from an Unknown or Any class.Behavior Changes:
Enhancements:
Published by github-actions[bot] 7 months ago
Bug Fixes:
MutableSet
or MutableSequence
.*args
parameter.__new__
method in a metaclass uses PEP 692 (unpacked TypeDict) to annotate its **kwargs
parameter.Enhancements:
except
and except*
statements to catch some previously-undetected invalid cases.Published by github-actions[bot] 7 months ago
Bug Fixes:
complex()
or float()
class pattern.typing.TypeAlias
annotation.ClassVar
without an explicit type.Enhancements:
type
function when it is passed a class. Pyright previously evaluated this as Any
, but now it returns the class' metaclass.reportUnhashable
diagnostic rule.Published by github-actions[bot] 8 months ago
Breaking Changes:
Enhancements:
Bug Fixes:
match
statement is used in a loop and the subject expression is potentially narrowed as a result of the match
statement.Annotated
passed as second argument to NewType
call.__new__
method of a constructor if it is overloaded.__package__
. It should be str | None
rather than str
.isinstance
type guard logic. It was not properly handling tuples that included unions.str
method docstrings are showed when called on LiteralString
.Published by github-actions[bot] 8 months ago
Enhancements:
@deprecated
decorator.enum.nonmember
in cases where the attribute has a declared type.InitVar
outside of a dataclass.Behavior Changes:
and
and or
operators.Bug Fixes:
TypedDict
or Protocol
as an upper bound when using PEP 695 syntax.__init__.py
file uses the form from .a import a
.await
expression is passed as an argument to an overloaded function.Published by github-actions[bot] 8 months ago
Bug Fixes:
Enum
subclass overrides __new__
or __init__
and then a subclass of that class assigns tuple values when defining enum membersenum.nonmember
value is assigned to a class-scoped variable with a type annotation in an Enum class.reportUnknownArgumentType
error when assigning an empty list or dict expression to an index expression subscripted with a slice.update
on a TypedDict with zero defined entries.reportUnnecessaryCast
check if the second argument is a special form.Behavior Changes:
__or__
. In the case where the metaclass derives from Any or Unknown, pyright now assumes that it doesn't override __or__
.--watch
mode. Previously, it reported diagnostic deltas when it detected a change, but it is more useful if it reports all remaining diagnostics even for files that it didn't reanalyze due to a file change.Enhancements:
Published by github-actions[bot] 9 months ago
Bug Fixes:
None
type is included in an unpacked argument within a function call.isinstance
type narrowing logic that leads to incorrect narrowed type when the filter type (the second argument) and the test type (the first argument) are both type variables.Behavior Changes:
super()
method call when self
is annotated as a protocol class. This pattern is used for annotating mix-ins. In this case, pyright should not generate an error if the protocol's method isn't implemented.Enhancements:
TypedDict
or NamedTuple
as second argument to isinstance
call, which isn't allowed.Published by github-actions[bot] 9 months ago
Bug Fixes:
reportImplicitStringConcatenation
in schema file.UnionType
, not type[UnionType]
.tuple[Any, ...]
.typing.Any
is passed to a function that accepts a type[T]
. Any
is a special form and should not be compatible with type
.tuple
constructor with bidirectional type inference and the value passed to the constructor is an Iterable[Any]
.Behavior Changes:
tuple[()]
into a specialized Sequence
. It used to translate it to Sequence[Any]
, but the typing spec now clarifies that it should be Sequence[Never]
.tuple
with multiple unpacked embedded tuples. Type spec now clarifies this is OK as long as there are not multiple unbounded embedded tuples.__name__
and a few other instance variables defined in the type
class so they are treated specially when accessed from a class instance.Enhancements:
Final
in a value expression.Annotated
or a type alias defined with Annotated
as the second argument to an isinstance
or issubclass
call. This produces an exception at runtime.Published by github-actions[bot] 9 months ago
Breaking Changes:
Many pyright users have requested finer-grained control over diagnostics — especially for diagnostics that were previously lumped under the catch-all rule reportGeneralTypeIssues
. I was hesitant to do this because it is a breaking change and could be disruptive for some pyright users. However, the time has come to make this change.
The list of new diagnostic rules includes:
Refer to the configuration documentation for more details about each of these.
This is a breaking change for code bases that were previously overriding the diagnostic severity for reportGeneralTypeIssues
in the config file, in file-level pyright comments or in # type: ignore
or # pyright: ignore
comments. You will need to update your configuration settings and comments to use the new diagnostic rule names.
Bug Fixes:
await
operator within the left-most for
. This shouldn't result in an AsyncGenerator
despite what the Python documentation indicates.isinstance
type narrowing logic when type
is filtered using a metaclass instance.extraPaths
value.Callable
is missing a second type argument. It should use reportMissingTypeArgument
.tuple[*tuple[str], ...]
.Behavior Changes:
tuple[Any, ...]
so it is treated as though it's bidirectionally type compatible with all tuples regardless of length. This change is made in response to a clarification in the typing spec. It brings pyright in alignment with mypy's behavior in this regard.Enhancements:
Enum
or use EnumMeta
)._value_
type in an Enum class. Also added enforcement for custom __new__
and __init__
method signatures.Annotated
and other special forms when they are used in runtime value expressions rather than annotations.Published by github-actions[bot] 9 months ago
This is a quick-turn release to fix a regression that affected 1.1.346.
Bug Fixes:
Enhancements:
enum.member
and enum.nonmember
.pyright.disableTaggedHints
to disable the use of diagnostics hints with tags. Some language server clients do not display these tagged hints in the intended manner and instead treat them as regular diagnostics.Published by github-actions[bot] 9 months ago
Bug Fixes:
except
statement.issubclass
check.await
keyword was used in a for
iterator expression.Annotated
type annotation.NewType
was no longer allowed as an argument for another NewType
.*tuple[Unknown, ...]
in this case.str()
class pattern and a LiteralString
subject.self
or cls
parameter is explicitly annotated with a type that includes the type parameter.Behavior Changes:
@abstractmethod
. Previously, it assumed all such methods were potentially implemented.Enhancements:
+
unary operator in Literal
int
type annotations. The typing spec was recently amended to allow this.Published by github-actions[bot] 10 months ago
Bug Fixes:
Annotated
type expression.@final
.TypeVarTuple
constructor call that includes value constraints.@final
in an overloaded function. Added missing check for override of an overloaded method marked @final
.ClassVar
in the protocol but not in the concrete class (or vice versa).Enhancements:
Concatentate
special form is used in an illegal context.NamedTuple
call.issubclass
call. PEP 544 indicates that this isn't allowed.issubclass
or isinstance
check.Behavior Changes:
Union[*Ts]
and Union[*tuple[...]]
. This functionality was included in an early draft of PEP 646 but was dropped in the final spec. The functionality can still be used in pyright if useExperimentalFeatures
is set to true, but it will likely be removed entirely in the future.Published by github-actions[bot] 10 months ago
Bug Fixes:
type
statement to define a type alias.TypeAliasType
constructor.__await__
method return type was Unknown.TypeAliasType
constructor is called with an expression that refers to a traditional TypeVar.Behavior Changes:
__post_init__
method.Enhancements:
type
statement or a call to TypeAliasType
is a valid type expression.NewType
calls.with
statement when __enter__
or __aenter__
is present but cannot be bound.Published by github-actions[bot] 10 months ago
Bug Fixes:
Self
is used within a class definition statement. PEP 637 explicitly rejects this usage of Self
.Self
is used within a metaclass. PEP 637 explicitly rejects this usage of Self
.Enhancements:
TypedDict
class definition when using the normal class syntax.TypedDict
alternative syntax form that assigns the resulting class to a variable whose name doesn't match the name specified in the TypedDict
call.isinstance
or issubclass
call. These generate a runtime exception.