-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Support decorated constructors #6645
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I'm sorry, I don't think I can review this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good!
How much damage does it cause for internal codebases?
mypy/checkmember.py
Outdated
|
||
def type_object_type_from_function(init_or_new: FuncBase, | ||
This includes nomral functions, overloaded functions, and decorators |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo - "nomral"
mypy/checkmember.py
Outdated
else: | ||
assert isinstance(method.type, FunctionLike) # is_valid_constructor() ensures this | ||
t = method.type | ||
signature = bind_self(t) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any particular reason for moving this bind_self
out of type_object_type_from_function
? I don't have any objection, I'm just wondering if there is a technical reason I'm missing or you just like it more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No particular reason. I think I started refactoring by pulling function_type()
out of there, and pulled whole line out of there. But looking again at it I think it makes sense to keep bind and map together, so I will put it back.
Not so much actually, around 60 errors S+C. |
Fixes #1706
Fixes #5398
Previously, decorated constructors either resulted in silent
Any
types for class objects (in case of a decorated__init__()
) or incorrect signatures (in case of a decorated__new__()
).This PR adds support for decorated constructors, implementation is straightforward.
This PR supersedes #5798.