Closed
Description
Bug Report
Run this code:
from typing import Callable
from dataclasses import dataclass
@dataclass(frozen=True)
class Face:
map_to_volume: Callable[[int], int]
f = Face(map_to_volume=lambda x: x)
f.map_to_volume(5)
through mypy 0.920 on Python 3.10 and get the following output:
$ mypy mypy-bug.py
mypy-bug.py:12: error: Invalid self argument "Face" to attribute function "map_to_volume" with type "Callable[[int], int]"
mypy-bug.py:12: error: "int" not callable
Found 2 errors in 1 file (checked 1 source file)
Expected Behavior
- I'm surprised to see mypy complain about a
self
argument formap_to_volume
. It's an instance attribute, not a class attribute, so it is not subject to method processing. Python seems to agree, noself
argument is passed. - The message about
int
not being callable seems spurious:f.map_to_volume
is not anint
.
Your Environment
- Mypy version used: 0.920
- Mypy command-line flags: (none, see above)
- Mypy configuration options from
mypy.ini
(and other config files): (none) - Python version used: 3.10
- Operating system and version: Linux, Debian testing/unstable
x-ref: inducer/modepy#45, which tries to remove a type: ignore
that was necessitated by #9975.
Metadata
Metadata
Assignees
Labels
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
hauntsaninja commentedon Dec 17, 2021
Thanks, duplicate of #5485
See also #11571 and #10548