mypy
mypy copied to clipboard
Optional static typing for Python
**Bug Report** If I run: ``` # Run the type checking with "mypy --strict foo.py" class Add(tuple[int,int]): pass class Const(int): pass Expr = Add | Const def my_eval(e : Expr)...
**Bug Report** A `TypeGuard` declared and used near the top of a function is sometimes rendered ineffective (i.e., there is no change to the type of the first argument to...
Fixes #17036 The added note makes it easier for new mypy users to understand where the errors are coming from and suggests a potentially simple fix.
**Bug Report** According to [this](https://typing.readthedocs.io/en/latest/spec/generics.html#introduction:~:text=note%3A%20those%20types%20cannot%20be%20parameterized%20by%20type%20variables), using TypeVars to constraint other TypeVars is not possible. However, MyPy doesn't report any errors in such cases. **To Reproduce** https://mypy-play.net/?mypy=latest&python=3.11&gist=e4febb3ef7aeaa11ea0aaabd4a068739 **Expected Behavior** Some error...
**Bug Report** The following causes an `INTERNAL ERROR`. The issue seems to be related to the usage of match-case. https://mypy-play.net/?mypy=master&python=3.12&flags=show-traceback&gist=7ccec270743b3e26d66d211839e82e64 **To Reproduce** ```python from typing import Self, Protocol, overload from...
**Bug Report** Considering the following piece of code: ```python NestedLines = tuple def print_lines(ls: NestedLines, indent: int = 0) -> None: for line in ls: match line: case NestedLines(): print_lines(line,...
**Crash Report** Under some specific conditions, `mypy` crashes when creating type aliases for unions with self-referential variants. Specifically, both of these work fine: ```python X: ty.TypeAlias = ty.Union[ ty.Set["X"], ty.Sequence["X"],...
Fixes #16933 @finite-state-machine When I first read your issue, I thought only a special case was left unconsidered. However, I then realized that Mypy's narrowing of generic classes often tends...
Allows sequence pattern matching of tuple types with union members to use an unmatched pattern to narrow the possible type of union member to the type that was not matched...
**Bug Report** Extending the example for #3434 I want to define an enum Flag, combine some of the members, and then also reference those members as a TypeAlias in a...