Skip to content

Class Generic ParamSpec cannot be used in Callable #12011

Closed
@isra17

Description

@isra17

Bug Report

Mypy doesn't seem to support a Generic class with a ParamSpec argument to use this ParamSpec in an inherited generic class.

eg:

import typing as t

TCallable = t.TypeVar("TCallable", bound=t.Callable[..., t.Any])
P = t.ParamSpec("P")

class X(t.Generic[TCallable]):
  pass  
  
class Y(t.Generic[P], X[t.Callable[P, t.Any]]): # error: The first argument to Callable must be a list of types or "..."
  pass

To Reproduce

https://mypy-play.net/?mypy=master&python=3.10&gist=9edf71a609a6a1fe5764db342beaa710

This code seems to work on Pyright

Expected Behavior

The code above should pass.

Actual Behavior

The code above have an error: error: The first argument to Callable must be a list of types or "...". This error seems to be from some codepath unaware of ParamSpec.

Your Environment

  • Mypy version used: 0.931 and master
  • Python version used: 3.10

Metadata

Metadata

Assignees

No one assigned

    Labels

    affects-typeshedAnything that blocks a typeshed changebugmypy got something wrongtopic-paramspecPEP 612, ParamSpec, Concatenate

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions