You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The mypy check complains 'Value of type "Any | Awaitable[Any]" is not indexable' for the line response = self.notion_client.search and all_pages_info.extend(response["results"]).
example.py:8: error: Value of type "Any | Awaitable[Any]" is not indexable [index]
Found 1 error in 1 file (checked 1 source file)
So basically what's happening here is that we don't implement response type hints, and our current SyncAsync[Any] workaround you can see everywhere in api_endpoints.py makes Mypy unhappy because it's not precise enough to determine if response["results"] should be allowed or not (i.e. if it's indexable, i.e. if it's a dict).
Honestly it's an error I'm quite surprised to not have encountered yet, but it definitely should be fixed. Even without implementing / supporting all the response type hints, we should definitely replace our Any by something a bit more sensible, it's long overdue.
Some work has already been started / discussed in #199, #200 and #243. I'd be happy if we could land something, even if it just adds the overall message enveloppes and not the precise response types.
Activity
ramnes commentedon Dec 18, 2024
Hey, thanks for raising the issue and sorry for the long time to answer.
Your code has many other Mypy errors as is, but it can be replicated with this simplified one:
Results in:
So basically what's happening here is that we don't implement response type hints, and our current
SyncAsync[Any]workaround you can see everywhere inapi_endpoints.pymakes Mypy unhappy because it's not precise enough to determine ifresponse["results"]should be allowed or not (i.e. if it's indexable, i.e. if it's a dict).Honestly it's an error I'm quite surprised to not have encountered yet, but it definitely should be fixed. Even without implementing / supporting all the response type hints, we should definitely replace our
Anyby something a bit more sensible, it's long overdue.Some work has already been started / discussed in #199, #200 and #243. I'd be happy if we could land something, even if it just adds the overall message enveloppes and not the precise response types.
PR welcome!
[-]mypy check complains Value of type "Any | Awaitable[Any]" is not indexable[/-][+]Response envelope type hints[/+]