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

ParamSpec doesn't work in generic type aliases #12736

Closed
CyanoKobalamyne opened this issue May 6, 2022 · 2 comments
Closed

ParamSpec doesn't work in generic type aliases #12736

CyanoKobalamyne opened this issue May 6, 2022 · 2 comments
Labels
bug mypy got something wrong topic-paramspec PEP 612, ParamSpec, Concatenate topic-type-alias TypeAlias and other type alias issues

Comments

@CyanoKobalamyne
Copy link

CyanoKobalamyne commented May 6, 2022

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
@CyanoKobalamyne CyanoKobalamyne added the bug mypy got something wrong label May 6, 2022
@JelleZijlstra JelleZijlstra added topic-paramspec PEP 612, ParamSpec, Concatenate topic-type-alias TypeAlias and other type alias issues labels May 6, 2022
@cdce8p
Copy link
Collaborator

cdce8p commented May 6, 2022

Duplicate of #11855

@CyanoKobalamyne
Copy link
Author

Oops, sorry, for some reason I could not find that issue with the keywords I was searching for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong topic-paramspec PEP 612, ParamSpec, Concatenate topic-type-alias TypeAlias and other type alias issues
Projects
None yet
Development

No branches or pull requests

3 participants