I was able to reproduce this behavior and it clearly seems like a bug. It used to work as intended (without the warning) in version 1.20.0, indicating this issue is a regression.
st.code is a static element, not an input widget. So it should technically work even without experimental_allow_widgets=True.
Would you mind submitting a bug report in the Streamlit GitHub repository? Our team will triage your report and work on a fix.
Thank you for helping make Streamlit better!
Happy Streamlit-ing! Snehan
PS: If it seems like a lot of work, please let me know if you’d like me to submit a bug report on your behalf.