mypy
mypy copied to clipboard
Optional static typing for Python
**Feature** Imagine this file with implementation: ```python class A: def do_some(self) -> None: print('A') class B(A): def do_some(self) -> None: print('B') ``` Auto-stub creators will create a stub like: ```python...
### Description ```py def foo(a: int) -> int: ... (foo(""), foo(""),) ( foo(""), foo(""), ) ``` ``` main.py:3:6: error: Argument 1 to "foo" has incompatible type "str"; expected "int" [arg-type]...
Since #5699, mypy now rejects the following program (minimized from a few failures at dropbox): ``` from typing import TypeVar, Callable, Tuple T = TypeVar('T') def f(x: Callable[..., T]) ->...
## 🐛 Bug Report This is similar to #6462 and #9335 but with the star-star syntax. There are cases where mypy could prove the following program type-safe, but currently this...
**Bug Report** **To Reproduce** ```python3 def first() -> None: tag_name: str | dict[str, str] if isinstance(tag_name, dict): tag_name = tag_name.get("foo", "bar") reveal_type(tag_name) def second() -> None: tag_name: str | dict[str,...
There is an idea to allow modules be accepted where a protocol is expected. This pattern is sometimes used for configs and option management, for example: ```python # file default_config.py...
```py from typing import overload @overload def foo(a: int, /): ... @overload def foo(a: str): ... def foo(a): ... foo(a=1) # main.py:10: error: No overload variant of "foo" matches argument...
### Description Discover paths to editable packages by looking at direct_url.json files -- installed by pip when the -e/--editable flag is used -- and add to the package search paths....
```py from typing import TypeAlias Values: TypeAlias = dict[str, int] a = Values(foo="") # no error ``` [playground](https://mypy-play.net/?mypy=master&python=3.10&flags=show-error-codes%2Callow-redefinition%2Cstrict%2Ccheck-untyped-defs%2Cdisallow-any-decorated%2Cdisallow-any-expr%2Cdisallow-any-explicit%2Cdisallow-any-generics%2Cdisallow-any-unimported%2Cdisallow-incomplete-defs%2Cdisallow-subclassing-any%2Cdisallow-untyped-calls%2Cdisallow-untyped-decorators%2Cdisallow-untyped-defs%2Cno-implicit-optional%2Cno-implicit-reexport%2Cstrict-equality%2Cwarn-incomplete-stub%2Cwarn-redundant-casts%2Cwarn-return-any%2Cwarn-unreachable%2Cwarn-unused-configs%2Cwarn-unused-ignores&gist=fd24a0eecec6a636f274f4182b51c640)
This sample produces two error messages, the second is completely valid, but the first makes no sense. ```py from typing import overload @overload def foo(a: list[int]): ... @overload def foo(a:...