lukasmasuch/streamlit-pydantic

ignore_empty_values doesn't work for list types

aantn opened this issue · 0 comments

aantn commented

Describe the bug:
When setting ignore_empty_values=True, I would expect empty lists to not be returned by pydantic_input. Yet they are.

Possible Fix:
Update _is_value_ignored in ui_renderer.py to check type(value) == list as follows:

return (
            self._ignore_empty_values
            and (
                type(value) == int or type(value) == float or isinstance(value, str) or type(value) == list
            )  # only for int, float or str
            and not value
            and self._get_value(property_key) is None
        )

I've tested this and it works.