-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Closed
Copy link
Labels
bugmypy got something wrongmypy got something wronggood-second-issuetopic-runtime-semanticsmypy doesn't model runtime semantics correctlymypy doesn't model runtime semantics correctly
Description
Bug Report
Given the following code:
from __future__ import annotations
from collections.abc import Iterable
from typing import Any
class MyThing:
def keys(self) -> Iterable[str]:
return ['foo']
def __getitem__(self, __key: str) -> Any:
return 'bar'
def foo(**args: Any) -> None:
print(args)
foo(**MyThing())
mypy
generates an error at line 19: Argument after ** must be a mapping, not "MyThing"
Expected Behavior
No error should be generated since it works at runtime. This has been discussed over in the Python Type School, and pyright
has been updated to support this.
Your Environment
- Mypy version used: 1.1.1
- Mypy command-line flags: n/a
- Mypy configuration options from
mypy.ini
(and other config files): n/a - Python version used: 3.10.10
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wronggood-second-issuetopic-runtime-semanticsmypy doesn't model runtime semantics correctlymypy doesn't model runtime semantics correctly