basedmypy
basedmypy copied to clipboard
A flag to treat third-party `Any` as `object`/`Untyped`
The flag will default to false and will be mandatory for all targets.
Eg: thirdparty.pyi
def foo(a: list[Any]) -> Any: ...
my.py
from thirdparty import foo
reveal_type(foo) # def (a: list[object]) -> object
a: int = foo([1]) # error: expression has type "object" variable has type "int"
I don't see any value in converting it to Untyped or showing an error that a parameter is typed as Any, how would you be able to do anything to fix it?
Any expression errors are so common, this would help a lot.
@DetachHead After thinking about these kind of issues a bit I think this might not be the best resolution, but if you can provide some examples where this is based that would help me out a bit.
What about something more like:
third_party.foo(1) # call to function with `Any`
third_party.bar = 1 # assignment to attribute with `Any`
some_list = third_party.get_list() # error, return type contains any
some_list = cast(list[int], third_party.get_list()) # that's okay
some_list: list[int] = third_party.get_list() # that's okay