Skip to content

get_class_decorator_hook_2: fix fullname #16063

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ikonst
Copy link
Contributor

@ikonst ikonst commented Sep 7, 2023

Fixes #16062.

Comment on lines 1828 to +1830
if isinstance(expr, CallExpr):
return self.get_fullname_for_hook(expr.callee)
elif isinstance(expr, IndexExpr):
expr = expr.callee
if isinstance(expr, IndexExpr):
Copy link
Contributor Author

@ikonst ikonst Sep 7, 2023

Choose a reason for hiding this comment

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

The culprit - see testClassDecoratorHook2_incorrect for repro.

Basically, if we have

@my_decorator()()
 ^^^^^^^^^^^^^^^^

then I feel we ought to use the whole callable, and not recurse in, but maybe I'm missing some use case?

@ikonst
Copy link
Contributor Author

ikonst commented Sep 7, 2023

cc @JukkaL re get_class_decorator_hook_2

@ikonst ikonst force-pushed the fix-get_class_decorator_hook_2 branch from 501b2dd to 6bcf3f2 Compare September 7, 2023 05:11
@github-actions

This comment has been minimized.

@AlexWaygood
Copy link
Member

AlexWaygood commented Sep 7, 2023

The syntax errors you're getting on Python 3.8 are likely because PEP 614 was first implemented in Python 3.9

@github-actions
Copy link
Contributor

github-actions bot commented Sep 7, 2023

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

def my_decorator(t: Any) -> Any:
raise

@my_decorator()()
Copy link
Member

Choose a reason for hiding this comment

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

What will happen for @my_decorator(1)()?

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.

AssertionError: trying to find dataclass transform spec
4 participants