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

Using unpack to keep parameters when creating httpx subclass leads to crash #17208

Open
CarliJoy opened this issue May 2, 2024 · 0 comments
Open
Labels

Comments

@CarliJoy
Copy link

CarliJoy commented May 2, 2024

Crash Report

Just use a TypedDict when creating a subclass leads to a crash

Traceback

Traceback (most recent call last):
  File "mypy/checker.py", line 591, in accept
  File "mypy/nodes.py", line 787, in accept
  File "mypy/checker.py", line 1000, in visit_func_def
  File "mypy/checker.py", line 1011, in _visit_func_def
  File "mypy/checker.py", line 1901, in check_method_override
  File "mypy/checker.py", line 1936, in check_method_or_accessor_override_for_base
  File "mypy/checker.py", line 2045, in check_method_override_for_base_with_name
  File "mypy/checker.py", line 2219, in check_override
IndexError: list index out of range

To Reproduce

from typing import Any, TypedDict, Unpack

import httpx
from httpx._client import UseClientDefault
from httpx._types import (
    AuthTypes,
    CookieTypes,
    HeaderTypes,
    QueryParamTypes,
    RequestContent,
    RequestData,
    RequestExtensions,
    RequestFiles,
    TimeoutTypes,
    URLTypes,
)


class RequestExtraArgs(TypedDict, total=False):
    params: QueryParamTypes | None
    headers: HeaderTypes | None
    cookies: CookieTypes | None
    follow_redirects: bool | UseClientDefault
    timeout: TimeoutTypes | UseClientDefault
    extensions: RequestExtensions | None


class SyncClient(httpx.Client):
    def request(
        self,
        method: str,
        url: URLTypes,
        *,
        content: RequestContent | None = None,
        data: RequestData | None = None,
        files: RequestFiles | None = None,
        json: Any | None = None,
        auth: AuthTypes | None = None,
        **extra_args: Unpack[RequestExtraArgs],
    ) -> httpx.Response:
        """
        Build and send a request.

        See: ``httpx.Client.request()``.
        """
        response = super().request(method, url, **extra_args)
        return response

Your Environment

  • Mypy version used: master
  • Mypy command-line flags: none
  • Mypy configuration options from mypy.ini (and other config files): none
  • Python version used: 3.11
  • Operating system and version: linux
@CarliJoy CarliJoy added the crash label May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant