Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A flag to treat third-party Any as object/Untyped #148

Open
DetachHead opened this issue Jan 12, 2022 · 2 comments
Open

A flag to treat third-party Any as object/Untyped #148

DetachHead opened this issue Jan 12, 2022 · 2 comments
Labels
feature feedback looking for community feedback p-1 high topic-any

Comments

@DetachHead
Copy link
Collaborator

DetachHead commented Jan 12, 2022

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?

@KotlinIsland KotlinIsland changed the title flag to treat Any as object (or Never if used in contravariant position) flag to treat Any as object Jan 13, 2022
@KotlinIsland KotlinIsland changed the title flag to treat Any as object A flag to treat third-party Any as object Mar 5, 2022
@KotlinIsland KotlinIsland added the p-2 normal label Mar 5, 2022
@KotlinIsland KotlinIsland added the p-1 high label Mar 25, 2022
@KotlinIsland
Copy link
Owner

Any expression errors are so common, this would help a lot.

@KotlinIsland KotlinIsland added topic-any and removed p-2 normal labels Apr 13, 2022
@KotlinIsland
Copy link
Owner

@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

@KotlinIsland KotlinIsland changed the title A flag to treat third-party Any as object A flag to treat third-party Any as object/Untyped Apr 13, 2022
@KotlinIsland KotlinIsland added the feedback looking for community feedback label Apr 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature feedback looking for community feedback p-1 high topic-any
Projects
None yet
Development

No branches or pull requests

2 participants