Skip to content
This repository was archived by the owner on Jan 25, 2025. It is now read-only.

Reordered attribute priming in Node.__init__#239

Merged
freakboy3742 merged 2 commits into
beeware:mainfrom
HalfWhitt:parent-order
Dec 2, 2024
Merged

Reordered attribute priming in Node.__init__#239
freakboy3742 merged 2 commits into
beeware:mainfrom
HalfWhitt:parent-order

Conversation

@HalfWhitt
Copy link
Copy Markdown
Member

@HalfWhitt HalfWhitt commented Dec 2, 2024

One more minor thing... while testing beeware/toga#2942 against multiple versions of Travertino, I'd mistakenly been ignoring some RuntimeWarnings on main, not just on 0.3.0.

Toga doesn't normally provide an applicator to Node.__init__, but ExampleNode in the tests does. When that happens, styles are applied, meaning the logic for setting hiddenness checks the node's parent, and that attribute wasn't being primed until afterward.

(An alternative would be to alter the property to return getattr(self, "_parent", None), which I've avoided here for consistency with explicit priming. But it could be an option down the line for node attributes, if complexities in Pack and/or other layout engines cause any conflicting needs for the order in which they're available.)

There's no reason root needs to be primed earlier as well, but conceptually I wanted to keep the "up" direction grouped together. Makes a nice "above - here - below" order now.

PR Checklist:

  • All new features have been tested
  • All new features have been documented
  • I have read the CONTRIBUTING.md file
  • I will abide by the code of conduct

Copy link
Copy Markdown
Member

@freakboy3742 freakboy3742 left a comment

Choose a reason for hiding this comment

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

Makes sense - 👍

@freakboy3742 freakboy3742 merged commit ca28d56 into beeware:main Dec 2, 2024
@HalfWhitt HalfWhitt deleted the parent-order branch December 17, 2024 03:36
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants