I have this code:
class C(object):
def __new__(cls, foo=None):
obj = object.__new__(cls)
obj.foo = foo
return obj
x = C(foo=12)
print(x.foo)
y = C(12)
This elicits an error complaining about the foo keyword to C, another about the foo attribute, and then one about the positional argument:
mypy_new.py:7: error: Unexpected keyword argument "foo" for "C"
mypy_new.py:8: error: "C" has no attribute "foo"
mypy_new.py:9: error: Too many arguments for "C"
This may be related to #794 -- feel free to close as a dupe if fixing that would automatically fix this. (There seem to be two separate issues here -- it doesn't turn the __new__ signature into the class signature, and it doesn't believe attributes set by __new__ become attributes of the object.)
I have this code:
This elicits an error complaining about the
fookeyword to C, another about thefooattribute, and then one about the positional argument:This may be related to #794 -- feel free to close as a dupe if fixing that would automatically fix this. (There seem to be two separate issues here -- it doesn't turn the
__new__signature into the class signature, and it doesn't believe attributes set by__new__become attributes of the object.)