You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 for map_to_volume. It's an instance attribute, not a class attribute, so it is not subject to method processing. Python seems to agree, no self argument is passed.
The message about int not being callable seems spurious: f.map_to_volume is not an int.
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.
The text was updated successfully, but these errors were encountered:
Bug Report
Run this code:
through mypy 0.920 on Python 3.10 and get the following output:
Expected Behavior
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.int
not being callable seems spurious:f.map_to_volume
is not anint
.Your Environment
mypy.ini
(and other config files): (none)x-ref: inducer/modepy#45, which tries to remove a
type: ignore
that was necessitated by #9975.The text was updated successfully, but these errors were encountered: