Skip to content
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

Fix .filter-kwargs lookup crash during cached runs #828

Merged
merged 2 commits into from
Jan 24, 2022

Conversation

flaeppe
Copy link
Member

@flaeppe flaeppe commented Jan 23, 2022

When copying class methods via copy_method_to_another_class, build arguments from the signature (CallableType) instead of from FuncDef.arguments as FuncDef.arguments are not serialized by mypy. Currently, methods copied on cached rounds have no arguments, due to an AttributeError being raised here(given that method_node is built from cache):

try:
original_arguments = method_node.arguments[1:]
except AttributeError:
original_arguments = []

Related issues

Fixes #827


Note: I've run this commit with cache enabled on the project where I encountered the error seen in #827, without being able to recreate it.

Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

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

Thanks! I have one concern 🙂

@flaeppe flaeppe force-pushed the fix/cached-filter-kwargs branch from 7fc9367 to 8ce8ad4 Compare January 24, 2022 10:02
Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

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

Looks good to me! Thank you!

@sobolevn sobolevn merged commit 515e382 into typeddjango:master Jan 24, 2022
@flaeppe flaeppe deleted the fix/cached-filter-kwargs branch January 24, 2022 11:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Cached runs crashes on typechecking .filter-kwargs with IndexError
2 participants