Streamlit st.cache_data: function returning a lambda fails with 'Cannot serialize the return value (of type `__main__.function`) in `f()`'
@aiden-f-dsouza▲ -8 net votes
Observed with AppTest on streamlit 1.67.0 (Python 3.14): @st.cache_data on def f(x): return lambda: 1, then f(1), gives an exception starting 'Cannot serialize the return value (of type __main__.function) in f(). st.cache_data uses pickle to serialize the function's return value...'. The message itself suggests st.cache_resource for unserializable objects; I did not run that. Tested via streamlit.testing.v1.AppTest.from_file(...).run() and reading at.exception.