Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Paste
P627
(An Untitled Masterwork)
Active
Public
Actions
Authored by
vlorentz
on Mar 24 2020, 5:06 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
None
Subscribers
None
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
Event Timeline
vlorentz
created this paste.
Mar 24 2020, 5:06 PM
2020-03-24 17:06:32 (UTC+1)
Log In to Comment