mypy
mypy copied to clipboard
Optional static typing for Python
Reproducer: ```py from typing import Collection from functools import reduce def _pull_out_loop_nest( loop_nests: list[frozenset[str]], inames_to_pull_out: frozenset[str] ) -> None: emptyset: frozenset[str] = frozenset() # OK reduce(frozenset.union, loop_nests[:-1], emptyset) # Error...
Reproducer: ```py from typing import Collection from functools import reduce def _pull_out_loop_nest( loop_nests: list[frozenset[str]], inames_to_pull_out: frozenset[str] ) -> None: # OK emptyset: frozenset[str] = frozenset() assert inames_to_pull_out
```py from typing import Callable, Concatenate, ParamSpec P = ParamSpec("P") def decorator(fn: Callable[Concatenate[str, P], None]) -> None: fn("value") # runtime TypeError: foo() missing 1 required positional argument: 's2' @decorator def...
**Feature** When a type error results from type information being lost because an object (context manager) is used with `with` (with-as block), mypy should emit a hint alluding to this....
**Feature** Add a new `--output=github` option to format errors as Workflow commands, similar to `--output=json` added in https://github.com/python/mypy/pull/11396. **Pitch** For example, for this output in JSON format ```console $ mypy...
```py # mypy: enable-incomplete-feature=NewGenericSyntax from dataclasses import dataclass @dataclass(frozen=True) class Foo[T]: value: T foo = Foo[int](value=1) bar: Foo[object] = foo # error: Incompatible types in assignment (expression has type "Foo[int]",...
**Bug Report** When trying to use pattern matching statements that contain list-type matches mypy emits bogus "unreachable" errors. **To Reproduce** The following code ```python from typing import Any def list_len(l:...
**Bug Report** We're having a bit of trouble over in https://github.com/python/typeshed/pull/11074. It seems like it's impossible to import `importlib.readers` inside `stdlib/importlib/machinery.pyi` and also use `typing_extensions.TypeAlias` to explicitly demarcate type aliases...
**Bug Report** The `cobetura.xml` file generated does not contain the `lines-covered` and `lines-valid` attributes. According to https://stackoverflow.com/a/71116722/595220, the spec is at https://github.com/cobertura/web/blob/master/htdocs/xml/coverage-04.dtd which has ```console ``` I haven't checked ll...
This describes an issue where a generic decorator that returns a generic sub-type of a "callable" (using `__call__` and `ParamSpec`) cannot be applied to a generic function. In the example...