Closed Kxnr closed 1 year ago
@Kxnr Hi. Thank you for the report. That's a bug. I will fix it in the next update.
Thanks!
Is it possible to specify search_mode in model config? Like this,
class BaseXmlModel(XmlModel):
class Config:
anystr_strip_whitespace = True
underscore_attrs_are_private = True
search_mode='unordered'
@Bolik Hi. No, it is not possible now.
The
search_mode
attribute, set on a base class, isn't inherited by child models. This may apply to additional settings with default values (currently onlyns_attrs
).Minimal Example
Expected Behavior
I expect that
ChildModel.__xml_search_mode__ == CustomBaseModel.__xml_search_mode__ == "unordered"
Observed Behavior
ChildModel.__xml_search_mode__
is set to the default of"strict"
unlessseach_mode
is also passed toChildModel
.I believe this is due to the default value in
__init__subclass__
forsearch_mode
. The checksearch_mode if search_mode is not None
always evaluatesTrue
and will never fall back to theelse
condition here.New to Open Source contributions so, let me know if there's anything else you need. I'm happy to pull together a PR if this diagnosis seems right. Thanks!