KEMBAR78
mypy 1.6.1, ParamSpec: `Cannot infer type argument 1 of "function_name"` · Issue #16301 · python/mypy · GitHub
Skip to content

mypy 1.6.1, ParamSpec: Cannot infer type argument 1 of "function_name" #16301

@orsinium

Description

@orsinium

In pytypest, inference for code using ParamSpec started to fail in mypy 1.6.1.

To Reproduce

from typing import Callable, Generic, ParamSpec
from dataclasses import dataclass

P = ParamSpec('P')

@dataclass
class Case(Generic[P]):
    pass

def case(*args: P.args, **kwargs: P.kwargs) -> Case[P]:
    return Case()

def _test(a: int):
    assert a

def parametrize(func: Callable[P, None], case: Case[P]):
    pass

parametrize(_test, case(1))

Expected Behavior

On mypy==1.5.1, no issues are reported.

Actual Behavior

On mypy==1.6.1, inference fails:

$ python3.10 -m mypy tmp2.py
tmp2.py:19: error: Cannot infer type argument 1 of "parametrize"  [misc]
Found 1 error in 1 file (checked 1 source file)

Your Environment

  • Mypy version used: 1.6.1
  • Mypy command-line flags: none
  • Mypy configuration options from mypy.ini (and other config files): none
  • Python version used: tested with python 3.8 and 3.10.

I also tried using --new-type-inference, it doesn't help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongtopic-paramspecPEP 612, ParamSpec, Concatenate

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions