-
Notifications
You must be signed in to change notification settings - Fork 52
Nested containers #704
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
base: main
Are you sure you want to change the base?
Nested containers #704
Conversation
updates: - [github.com/crate-ci/typos: v1.29.9 → v1.30.0](crate-ci/typos@v1.29.9...v1.30.0) - [github.com/astral-sh/ruff-pre-commit: v0.9.7 → v0.9.9](astral-sh/ruff-pre-commit@v0.9.7...v0.9.9)
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #704 +/- ##
==========================================
- Coverage 89.28% 89.15% -0.14%
==========================================
Files 40 40
Lines 4816 4831 +15
==========================================
+ Hits 4300 4307 +7
- Misses 516 524 +8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
hey @ndxmrb
so sorry for the long delay. couple concerns about typing and error catching. we don't need to belabor them too much, if you can fix great, otherwise let me know.
def create_widget(self, value: T | _Undefined = Undefined) -> BaseValueWidget[T]: | ||
def create_widget( | ||
self, value: T | _Undefined = Undefined | ||
) -> BaseValueWidget[T] | NestedValueWidgets: |
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 would prefer to avoid functions that return unions if at all possible. Isn't a NestedValueWidget
ultimately also just a ValueWidget
? Doesn't it have teh same interface? Is there anything in the PR here that actually requires a new type? Can we revert these NestedValueWidget changes without mypy breaking?
cls, kwargs = get_widget_class( | ||
value=value, annotation=self.type, options=opts | ||
) | ||
except ValueError: |
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 think this except ValueError
is something I did elsewhere at one point (right?) but I don't really like it since it's rather indirect. Unless we're certain that ValueError and TypeErrors are only ever raised for the specific cases that we are catching here, I'd prefer to do some look-before-you-leap pattern instead. (At the very least, I'd like to ensure that self.type
is a valid dataclass-like object before calling build_widget on it).
Hi @tlambert03,
restarting my work from #669 after the
ValuedContainer
changes.Still, some things are missing:
ValueWidget
s andContainerWidget
s. Does this belong totest_pydantic()
intest_ui_field.py
?Tried my best with the types again, hope it's okay that way.
Thanks for having a look!