mypy
mypy copied to clipboard
Optional static typing for Python
**Feature** When the implementation adds new arguments (or the stubs forget some of the arguments), stubtest creates many errors if the new/forgotten argument isn't the last argument. ```py $ cat...
The test looks like this: ``` from typing import Mapping class MappingSubclass(Mapping[str, str]): pass def f(**kwargs: 'A') -> None: pass d = None # type: MappingSubclass f(**d) class A: pass...
**To Reproduce** ```py from typing import Literal def fun(**kwargs) -> None: ... class A: def __init__(self): self.a: Literal["a"] = "a" def test(self) -> None: return fun(**{self.a: "a"}) # error: Keywords...
**Bug Report** ```py from typing import Any def func(d: dict[int, Any]) -> None: x: int | None x = d.get(1) reveal_type(x) # typing is lost -> Union[Any, None] ``` `d.get`...
When `type[type]` is used inside `reveal_type()` i get `Value of type "Type[type]" is not indexable` error: ```py reveal_type(type[type]) # Value of type "Type[type]" is not indexable # Revealed type is...
Given that `PYTHONPATH` contains `.../pythonX.Y/site-packages` And a package that contains some private 3rd party stubs under `.../pythonX.Y/site-packages/foo/some_stubs` When setting `MYPYPATH` to `.../pythonX.Y/site-packages/foo/some_stubs` Then `mypy` gives the error `.../pythonX.Y/site-packages is in...
I went for the smallest possible diff in this feature. There are couple of other options I did not want to go with: - `class LiteralStringType` and using it in...
Checking optional attributes in a class does not persist in a nested if: (test.py) ```python #!/usr/bin/env python3 import typing class Example: def __init__(self): self.a: typing.Optional[int] def check_class(foo: Example, bar: Example):...
It would be nice to display the class that defines the attribute when we assign an incompatible value to an attribute: ``` class A: a = 1 class B(A): a...
Consider this example: ```py x: int = 1 class X(x.__class__): # Name "x.__class__" is not defined # Class cannot subclass "__class__" (has type "Any") pass ``` `Name "x.__class__" is not...