forked from streamlit/streamlit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
memo and singleton decorator annotations (streamlit#4045)
Adds type annotations to `@st.experimental_memo` and `@st.experimental_singleton`. This means that running mypy on a Streamlit app should catch incorrect usage of a cached function, e.g. ```python import streamlit as st @st.experimental_memo def foo(value: int) -> None: st.write(value * 2) foo("bar") # this is now a mypy error, whereas before it was not ``` This changes the signatures for memo + singleton _ever so slightly_, in that it makes all "decorator arguments" into keyword-only args. It was previously legal to pass them positionally. I think this is ok because (1) we're still experimental and (2) in practice it's unlikely people were passing these parameters positionally anyway.
- Loading branch information
Showing
2 changed files
with
53 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters