Checklist
Summary
st.echo() does not print a decorator if there is no other line of code before the decorator.
To reproduce, run the below script:
import streamlit as st
def decorator(*args):
pass
with st.echo():
@decorator
def function():
pass
The output will be as shown below:

Note that @decorator is not printed.
Now, add anything above the decorator in the context of st.echo():
import streamlit as st
def decorator(*args):
pass
with st.echo():
"lorem ipsum"
@decorator
def function():
pass
The decorator is now printed:

Reproducible Code Example
No response
Steps To Reproduce
No response
Expected Behavior
No response
Current Behavior
No response
Is this a regression?
Debug info
- Streamlit version: 1.31.1
- Python version: 3.10.11
- Operating System: Windows11
- Browser: Edge
Additional Information
No response
Checklist
Summary
st.echo()does not print a decorator if there is no other line of code before the decorator.To reproduce, run the below script:
The output will be as shown below:

Note that
@decoratoris not printed.Now, add anything above the decorator in the context of
st.echo():The decorator is now printed:

Reproducible Code Example
No response
Steps To Reproduce
No response
Expected Behavior
No response
Current Behavior
No response
Is this a regression?
Debug info
Additional Information
No response