basedmypy
basedmypy copied to clipboard
Based Python static type checker with baseline, sane default settings and based typing features
Like `TypedDict` but based. - Support any `Mapping` including a covariant version of `dict` - Usable as a type parameter on functions unrelated to maps - Support any key type...
```py def f(x: object) -> TypeGuard[int]: ... a: object result = f(a) reveal_type(a) # object assert result reveal_type(a) # int ``` ```py def f(x: object) -> TypeGuard[int]: ... def run(fn:...
```py foo: bool = True if foo is True: # error ... ``` ```py x: bool | None if x == True: # redundant ... if x == False: #...
An option to unionize the duck types. ```py a: float reveal_type(a) # float | int ``` I think a configuration option like `duck_types` with values of `unionize`, `plain`(#167) and `standard`...
https://kotlinisland.github.io/basedmypy/command_line.html#cmdoption-mypy-extra-checks > This flag enables additional checks that are technically correct but may be impractical in real code. In particular, it prohibits partial overlap in `TypedDict` updates, and makes arguments...
```py class MyPlugin(Plugin): default_error_code = ErrorCode("my-code", "", "") @hook_function(mypackage.mymodule.mydef) def _(self, ctx: FunctionContext): if isinstance(ctx.arg_types[0][0], NoneType): self.fail("epic fail") ``` We can wrap up hook functions with a nice decorator, have...
### Describe the problem, ie expected/actual result (if it's not blatantly obvious) ``` TypeError: Foo.foo() takes 0 positional arguments but 1 was given ``` ### Gist to reproduce ```python from...
```py class A: def __str__(self): ... # don't expect error class B(A): def __str__(self): ... # expect error ```