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

Align/Justify aliases don't work with __contains__ #3127

Open
HalfWhitt opened this issue Jan 25, 2025 · 2 comments
Open

Align/Justify aliases don't work with __contains__ #3127

HalfWhitt opened this issue Jan 25, 2025 · 2 comments
Labels
bug A crash or error in behavior.

Comments

@HalfWhitt
Copy link
Contributor

Describe the bug

The aliases added in #3113 work for getting and setting, including with subscripts, but they raise an error when using in. It's probably a pretty simple fix, but I haven't dug into it yet. I wonder if there might be other edge cases too...

Steps to reproduce

from toga.style.pack import Pack
style = Pack(vertical_align_items="start")
"vertical_align_items" in style

Expected behavior

in should return True or False, indicating whether the property has been set or not.

Screenshots

No response

Environment

  • Toga: main branch

Logs

Traceback (most recent call last):
  File "<python-input-13>", line 1, in <module>
    "vertical_align_items" in style
  File "/Users/charles/toga_dev/toga/travertino/src/travertino/declaration.py", line 408, in __contains__
    getattr(self.__class__, name).is_set_on(self)
    ~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
AttributeError: type object 'Pack' has no attribute 'vertical_align_items'

Additional context

I'm starting to wonder if it might be worth adding a notion of aliases to Travertino itself — it could make this process less ad hoc, and easier to predict. However, I'm not sure if there's a feasible way to make it sufficiently flexible to be useful.

@HalfWhitt HalfWhitt added the bug A crash or error in behavior. label Jan 25, 2025
@freakboy3742
Copy link
Member

Good catch; definitely something we'll need to look into.

As for adding aliases to Travertino... I'm not expecting that we're going to need a lot of them, so I guess it comes down to whether the mechanics of an alias is easier to coordinate in a "meta" layer. For now, I'm inclined to put that idea on the back burner, and if we find find that there's value in the abstraction (which could include fixing this bug in a consistent way), then we can revisit the idea.

@HalfWhitt
Copy link
Contributor Author

The same problem exists for the padding/margin aliases, as well as alignment/align_items.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A crash or error in behavior.
Projects
None yet
Development

No branches or pull requests

2 participants