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
/home/tabbott/foo.py: note: In function "foo":
/home/tabbott/foo.py:10: error: "super" used outside class
/home/tabbott/foo.py: note: At top level:
/home/tabbott/foo.py:13: error: Cannot assign to a method
with the following code monkey-patching a class with inheritance:
class Base(object):
def test(self):
return self.val
class Test(Base):
val = "yay"
def foo(self):
print(super(Test, self).test())
Test.test = foo
x = Test()
x.test()
I think we could fix the super() issue by allowing super inside a non-class method when it's first argument is self (could imagine having an annotation tag along the lines of SelfType that auto-any uses for such a function?); a similar approach might work for the other one too (you can only assign functions with a SelfType tag to class methods?)
The text was updated successfully, but these errors were encountered:
mypy throws:
with the following code monkey-patching a class with inheritance:
Example real code with the issue is here:
https://github.com/zulip/zulip/blob/master/zerver/lib/test_helpers.py#L104
I think we could fix the super() issue by allowing super inside a non-class method when it's first argument is self (could imagine having an annotation tag along the lines of SelfType that auto-any uses for such a function?); a similar approach might work for the other one too (you can only assign functions with a SelfType tag to class methods?)
The text was updated successfully, but these errors were encountered: