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

SanicASGITestClient has wrong type hints #79

Open
pdmtt opened this issue Dec 5, 2024 · 0 comments
Open

SanicASGITestClient has wrong type hints #79

pdmtt opened this issue Dec 5, 2024 · 0 comments

Comments

@pdmtt
Copy link

pdmtt commented Dec 5, 2024

Hello there!

SanicASGITestClient inherits from httpx.AsyncClient and override its request method, changing its return type.

class SanicASGITestClient(httpx.AsyncClient):
    async def request(  # type: ignore
        self, method, url, gather_request=True, *args, **kwargs
    ) -> typing.Tuple[
        typing.Optional[Request], typing.Optional[TestingResponse]
    ]:
      ...
class AsyncClient(BaseClient):
    async def request(
        self,
        method: str,
        url: URL | str,
        *,
        content: RequestContent | None = None,
        data: RequestData | None = None,
        files: RequestFiles | None = None,
        json: typing.Any | None = None,
        params: QueryParamTypes | None = None,
        headers: HeaderTypes | None = None,
        cookies: CookieTypes | None = None,
        auth: AuthTypes | UseClientDefault | None = USE_CLIENT_DEFAULT,
        follow_redirects: bool | UseClientDefault = USE_CLIENT_DEFAULT,
        timeout: TimeoutTypes | UseClientDefault = USE_CLIENT_DEFAULT,
        extensions: RequestExtensions | None = None,
    ) -> Response:
      ...

httpx.AsyncClient's HTTP verbs methods return from the request method and this behaviour isn't overrided by SanicASGITestClient.

That makes Pycharm believe SanicASGITestClient.get's return type is httpx.Response, but it actually is typing.Optional[Request], typing.Optional[TestingResponse].

I believe this might happen to other IDEs as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant