-
-
Notifications
You must be signed in to change notification settings - Fork 377
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
fix: allow non-Mapping Iterable parameters #3632
fix: allow non-Mapping Iterable parameters #3632
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3632 +/- ##
=======================================
Coverage 98.29% 98.29%
=======================================
Files 330 330
Lines 15122 15135 +13
Branches 2401 2404 +3
=======================================
+ Hits 14864 14877 +13
Misses 117 117
Partials 141 141 ☔ View full report in Codecov by Sentry. |
Documentation preview will be available shortly at https://litestar-org.github.io/litestar-docs-preview/3632 |
While we're at it, It's also smelly - it tests against a whole bunch of types, while Also, I suspect the problem is with python type system lacking a type suitable for sequential processing Perhaps we could introduce a new type, lets call it |
Can someone either accept it or drop it, before the changes go completely outdated? Thanks! |
Co-authored-by: Janek Nouvertné <[email protected]>
8d5043f
to
58da671
Compare
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.
Alright, I've taken another look at this and I think the change as such is good. The implementation can be simplified though to the following:
- Add an
is_iterable
property toFieldDefinition
- Set
is_sequence=field_definition.is_sequence and not field_definition.is_mapping
The rest can be removed.
Also, this should include a test case that reproduces the actual bug it's fixing.
Makes sense
I'd rather copy and adjust an existing test, not to break existing patterns, but I couldn't find anything similar. |
You could basically just copy the example you gave in #3631, and create a parametrized test case that shows it works as expected with a bunch of iterable types that should be supported. |
I wrote a nice matrix parametrized tests with Iterable, Sequece, List x str, int and it fails for Iterable I think the list of supported types could be clearer and link to https://jcristharif.com/msgspec/supported-types.html |
Well that was kind of my point :) IMO it's easier (and more correct) to just use a list to begin with. Maybe your original problem can be addressed in a different way? Iiuc it's about setting defaults for mutable types. Maybe supporting a |
Description
Allow
Iterable
s other thanstr
orMapping
s to be used asSequence
parametersCloses
Closes #3631