Page MenuHomeSoftware Heritage
Paste P627

(An Untitled Masterwork)
ActivePublic

Authored by vlorentz on Mar 24 2020, 5:06 PM.
from typing import Callable
class Foo:
f: Callable[[int], None]
def __init__(self, f: Callable[[int], None]):
self.f = f
# /tmp/foo.py:7: error: Cannot assign to a method
# /tmp/foo.py:7: error: Invalid self argument "Foo" to attribute function "f" with type "Callable[[int], None]"
# /tmp/foo.py:7: error: Incompatible types in assignment (expression has type "Callable[[int], None]", variable has type "Callable[[], None]")
def call(self, n: int):
self.f(n)
# /tmp/foo.py:10: error: Invalid self argument "Foo" to attribute function "f" with type "Callable[[int], None]"
# /tmp/foo.py:10: error: Too many arguments