-
-
Notifications
You must be signed in to change notification settings - Fork 18
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
Assign node to applicator before reapply can happen #232
Conversation
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.
A couple of comments about needed comments inline, plus a possible edge case that probably isn't the end of the world, but would be worth clarifying.
if applicator: | ||
applicator.node = self | ||
|
||
self._applicator = applicator | ||
self.style._applicator = applicator |
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.
Since we're thinking about the edge cases: if there's an existing applicator, should we be clearing the node reference on that applicator? I don't think it will make any difference in practice right now, but for symmetry, it couldn't hurt.
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.
Also - given this bit us, it would be worth adding a quick comment explaining why the order is significant.
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 hadn't thought of that, that's a good point.
@@ -371,3 +383,12 @@ def test_apply_before_node_is_ready(): | |||
|
|||
with pytest.warns(RuntimeWarning): | |||
Node(style=style, applicator=applicator) | |||
|
|||
|
|||
def test_applicator_has_node_reference(): |
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.
It took me a moment to work out why this test was different to the last assertion in test_apply_before_node_is_ready
, except that it wasn't actually asserting that the warning was raised. A comment on the fact that AttributeTestStyle asserts that it is re-applied would be helpful.
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.
👍 Looks good - thanks for the fix!
Oops. Working on beeware/toga#2937 led me to notice I'd missed an important part of the necessary order here. The applicator should know what its node is before the applicator is assigned to the style, so it will have the reference when reapplying happens.
PR Checklist: