Skip to content

ParamSpec P.args not Iterable; P.kwags does not have "Items" #12660

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

Closed
rbroderi opened this issue Apr 23, 2022 · 1 comment
Closed

ParamSpec P.args not Iterable; P.kwags does not have "Items" #12660

rbroderi opened this issue Apr 23, 2022 · 1 comment
Labels
bug mypy got something wrong topic-paramspec PEP 612, ParamSpec, Concatenate

Comments

@rbroderi
Copy link

rbroderi commented Apr 23, 2022

P = ParamSpec("P")
R = TypeVar("R")
  def dec_test(func: Callable[P, R]) -> Callable[P, R]:
      @wraps(func)
      def inner(*args: P.args, **kwargs: P.kwargs) -> R:
          for a in args:
              print(a)
          for arg_k, arg_v in kwargs.items():
              print(f"{arg_k},{arg_v}"
          return func(*args, **kwargs)
  
      return inner

Expected Behavior
P.args should be iterable
P.kwargs should have items()

Actual Behavior
"P.args" has no attribute "iter" (not iterable)
"P.kwargs" has no attribute "items"
Your Environment

  • Mypy version used: 0.931
  • Python version used: 3.10.4
  • Operating system and version: Windows 10
@rbroderi rbroderi added the bug mypy got something wrong label Apr 23, 2022
@JelleZijlstra JelleZijlstra added the topic-paramspec PEP 612, ParamSpec, Concatenate label Apr 23, 2022
@rbroderi rbroderi changed the title ParamSpec P.args not Iterable ParamSpec P.args not Iterable; P.kwags does not have "Items" Apr 23, 2022
@AlexWaygood
Copy link
Member

Duplicate of #12386

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
Projects
None yet
Development

No branches or pull requests

3 participants