Skip to content

PEP-612 Concatenate not recognized properly #11833

Description

@wrobell

Please consider example from PEP-612

from typing import Concatenate, Callable, TypeVar, ParamSpec

R = TypeVar('R')
P = ParamSpec('P')

class Request:
    pass

def with_request(f: Callable[Concatenate[Request, P], R]) -> Callable[P, R]:
  def inner(*args: P.args, **kwargs: P.kwargs) -> R:
    return f(Request(), *args, **kwargs)
  return inner

then

$ mypy t6.py
t6.py:9: error: The first argument to Callable must be a list of types or "..."
Found 1 error in 1 file (checked 1 source file)

I would expect Concatenate to be accepted as the first argument of Callable.

Mypy 0.930, Python 3.10.1

Activity

  1. wrobell commented on Dec 23, 2021

    @wrobell
    Author

    Without recognizing Concatenate, one has to use args as a tuple (i.e. access first argument with args[0]), which is disallowed by PEP-612 and Mypy (see also #11826).

  2. srittau commented on Dec 23, 2021

    @srittau
    Contributor

    Part of #8645

  3. added and removed
    bugmypy got something wrong
    on Mar 30, 2022
  4. added a commit that references this issue on Apr 7, 2022
    07d8878
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions