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 getattr
inference with empty annotation assignments
#1834
Conversation
Pull Request Test Coverage Report for Build 3260984270
💛 - Coveralls |
name: str, | ||
context: InferenceContext | None = None, | ||
class_context: bool = True, | ||
) -> list[NodeNG]: |
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.
Are you sure about this? I belive locals
is actually SuccesfulInferenceResult
but typed incorrectly currently...
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 belive
locals
is actuallySuccesfulInferenceResult
but typed incorrectly currently...
Don't think so. AFAICT locals
is only modified via set_local
which takes a NodeNG
argument. Thus the typing should be correct. We can always come back to it if we discover that it's wrong later.
https://github.com/PyCQA/astroid/blob/a29ee0f3fbbe3aa580280c979d3f01b0146dd00f/astroid/nodes/scoped_nodes/mixin.py#L91-L103
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.
See comment in other issue. This is not always the case and I think the typing should be updated here.
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.
Elegant refactor and upgrade of the typing at the same time 👌
Description
Don't exit with
AttributeInferenceError
for annotation assignments if parent class contains valid assignment.Type of Changes
Related Issue
Refs pylint-dev/pylint#7631