mypy
mypy copied to clipboard
Optional static typing for Python
Factor `run_pytest` out of mypy/test/meta/test_*.py. Also, prefixing the nested pytest output so it's harder to mix it up with parent pytest's: ``` >> .../mypy/venv/bin/python -m pytest -n 0 -s mypy/test/testcheck.py::TypeCheckSuite::check-meta-909158d4-c9c7-41e6-be50-cf101aaa2b56.test...
Assuming a `issue.py` module: ```bash $ mypy issue.py issue.py:86: error: Invalid self argument "MyContainerStr" to attribute function "bounds" with type "Callable[[MyContainerBase[int]], BoundsInt]" issue.py:86: error: Argument 1 to "check_to_str_bounds" has incompatible...
**Bug Report** A function defined as ``` def assert_not_none(x: Optional[T]) -> T: assert x is not None return x ``` used with an input `Optional[Union[A, B]]` should return a type...
```py 1 # type:ignore[misc] foo: int = "" ``` ``` main.py:1: error: Unused "type: ignore" comment main.py:2:12: error: Incompatible types in assignment (expression has type "str", variable has type "int")...
**Bug Report** When using exhaustive checking either in if/elif/else or with match over TypeVars bound to Union Types `mypy` throws: ``` Argument 1 to "assert_never" has incompatible type "T"; expected...
**Feature** If there is a project configuration file (`pyproject.toml`, `mypy.ini` etc), make the default `.mypy_cache` directory be near the configuration file instead of at the current working directory. **Pitch** Currently,...
**Bug Report** The way mypy does type inference breaks calling a generic function on the right side of `set.__and__`, because it takes an argument of type `AbstractSet[object]`. It seems like...
Resubmitting #11617 cause that was pre-Blackened mypy. Also, that PR probably won't get any eyes anymore. This fixes #9023. I still need to add a test about this, unfortunately.
**Bug Report** (*_: Union[AnyStr]) -> AnyStr doesn't work. (A clear and concise description of what the bug is.) **To Reproduce** [(mypy-play link)](https://mypy-play.net/?mypy=latest&python=3.11&gist=c01fd66d656b490ea0700cb1ec610f4a) ```python from typing import AnyStr, Union, Any from...
Currently the function/method signature hooks must return a `CallableType`. This precludes cases where a union of `CallableType`s would be more appropriate. For example, given ```python @attrs.define class C1: foo: int...