10000 When specifying a TypeVar to be a Callable, or union of Callables, ParamSpec cannot be used to indicate parameter types · Issue #14777 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content
When specifying a TypeVar to be a Callable, or union of Callables, ParamSpec cannot be used to indicate parameter types #14777
Closed as not planned
@AndrewGibb

Description

@AndrewGibb

Bug Report

The declarations of F, G and H all result in the following error:
The first argument to Callable must be a list of types, parameter specification, or "..." [valid-type]
Despite the first argument to the callable being a parameter specification.

from typing import Callable, ParamSpec, TypeVar, Coroutine, Any, Union

P = ParamSpec('P')
F = TypeVar('F', bound=Callable[P, Any])
G = TypeVar('G', bound=Callable[P, Coroutine[Any, Any, Any]])
H = TypeVar('H', bound=Union[Callable[P, Any], Callable[P, Coroutine[Any, Any, Any]]])

To Reproduce
https://mypy-play.net/?mypy=latest&python=3.11&gist=191e47b4afd74e307a3042dfedac77d4

Expected Behavior

Either these should pass type checking, or the error message should be updated to indicate what the problem actually is.

Your Environment

  • Mypy version used: 1.0.0
  • Python version used: 3.11

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0