Type annotations

Completed

Why does pycharm get types wrong?

I have a function declaration like this

P = ParamSpec("P")
R = TypeVar("R", bound=PaginatedResponse)


async def get_pages(
    func: Callable[P, Awaitable[R]],
    /,
    *args: P.args,
    **kwargs: P.kwargs,
) -> AsyncGenerator[R, None]:
	...

and its call:

async def main() -> None:
    async for page in get_pages(client.get_clients, 2, 2):
        reveal_type(page)

        break

 

Why does mypy understand that the page is GetClientsResponse, but pycharm specifies Any?

0
1 comment

Hi Zobalarm ,

This issue requires a more in-depth investigation. Could you please create a new ticket on YouTrack and include all relevant details - a minimal project sample that reproduces the problem? This will help us analyze and resolve the issue more efficiently. Thank you!

0

Please sign in to leave a comment.