-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Invoke get_dynamic_class_hook on method calls #7704
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
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.
Thanks for PR! Generally looks good, I have few comments/suggestions below.
# check if method call | ||
if isinstance(call.callee, MemberExpr): | ||
callee_expr = call.callee.expr | ||
if isinstance(callee_expr, NameExpr) and callee_expr.fullname: |
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.
if isinstance(callee_expr, NameExpr) and callee_expr.fullname: | |
if isinstance(callee_expr, RefExpr) and callee_expr.fullname: |
fname = callee_expr.fullname + '.' + method_name | ||
# else check if function call | ||
elif isinstance(call.callee, RefExpr): | ||
fname = call.callee.fullname |
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.
I believe the order is wrong here: a RefExpr
(including MemberExpr
) with a non-None
full name should always take precedence.
MyManager = Manager.from_queryset(QuerySet) | ||
|
||
reveal_type(MyManager()) # N: Revealed type is '__main__.MyManager' | ||
reveal_type(MyManager().attr) # N: Revealed type is 'builtins.str' |
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.
Please add a check here that MyManager
can be used as an annotation for a function argument.
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.
Marking with "Request changes" for tracking purposes
@mkurnikov Note a competing PR appeared #7990, will you have time to update your PR soon? |
Fixes #7266