Skip to content

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

Closed
wants to merge 1 commit into from

Conversation

mkurnikov
Copy link
Contributor

Fixes #7266

Copy link
Member

@ilevkivskyi ilevkivskyi left a 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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
Copy link
Member

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'
Copy link
Member

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.

Copy link
Collaborator

@msullivan msullivan left a 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

@ilevkivskyi
Copy link
Member

@mkurnikov Note a competing PR appeared #7990, will you have time to update your PR soon?

@mkurnikov mkurnikov closed this Nov 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

get_dynamic_class_hook for method calls
3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy