-
-
Notifications
You must be signed in to change notification settings - Fork 276
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
Require build class parent #2557
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1705,7 +1705,8 @@ def test_infer_dict_from_keys() -> None: | |
) | ||
for node in bad_nodes: | ||
with pytest.raises(InferenceError): | ||
next(node.infer()) | ||
if isinstance(next(node.infer()), util.UninferableBase): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this necessary? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For this one, I don't know exactly, but my intuition was the following. Before, when we had However, both responses kind of seem to make sense, so I opted to allow either of the responses ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we be certain that it is either of the two? So, just assert that it is always There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, right now it's always There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, one test fails on |
||
raise InferenceError | ||
|
||
# Test uninferable values | ||
good_nodes = astroid.extract_node( | ||
|
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.
This feels like a crucial change that we don't have a test for. Should we add one?
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.
So, usually classes get added to the body of the parent in the positinit constructor. There is only one exception to my knowledge:
raw_building._add_dunder_class
. It was added solely to support somepyqt
inference and it is creating (and attaching) adhoc classes for the purposes of being later detected by the transform process.That situation is already tested by the three qt tests (which fail without this change). In other situations it's useless, afaics.
Overall, the process described above seems very perverse, the "dunder" class shouldn't be recreated within a function each time. It is its own class that is defined outside. We should rather consult the type annotation in the transform process. However, it is a question for another PR.