Skip to content

ParamSpec doesn't work in generic type aliases #12736

Closed
@CyanoKobalamyne

Description

@CyanoKobalamyne

Bug Report

Generic type aliases where one of the free "type variables" is a ParamSpec don't work.

To Reproduce

  1. test.py:
    from typing import Callable, TypeVar
    
    from typing_extensions import ParamSpec
    
    
    P = ParamSpec("P")
    R = TypeVar("R")
    
    FunctionType = Callable[P, R]
    
    
    def a_decorator(func: FunctionType[[int], str]) -> None:
        ...
    
  2. mypy test.py

Expected Behavior

This should not raise any errors. A similar example. where both type variables are actual TypeVars, works:

from typing import Dict, TypeVar


K = TypeVar("K")
V = TypeVar("V")

DictType = Dict[K, V]


def a_function(d: DictType[int, str]) -> None:
    ...

Actual Behavior

Output:

test.py:9: error: The first argument to Callable must be a list of types or "..."
test.py:12: error: Bracketed expression "[...]" is not valid as a type
test.py:12: note: Did you mean "List[...]"?
test.py:12: error: Bad number of arguments for type alias, expected: 0, given: 2

Your Environment

  • Mypy version used: 0.950
  • Mypy command-line flags: none
  • Mypy configuration options from mypy.ini (and other config files): none
  • Python version used: 3.7.11
  • Operating system and version: macOS 12.3.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongtopic-paramspecPEP 612, ParamSpec, Concatenatetopic-type-aliasTypeAlias and other type alias issues

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions