Skip to content

Decorators not being printed in st.echo() #9252

Description

@SiddhantSadangi

Checklist

  • I have searched the existing issues for similar issues.
  • I added a very descriptive title to this issue.
  • I have provided sufficient information below to help reproduce this issue.

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:
image
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:
image

Reproducible Code Example

No response

Steps To Reproduce

No response

Expected Behavior

No response

Current Behavior

No response

Is this a regression?

  • Yes, this used to work in a previous version.

Debug info

  • Streamlit version: 1.31.1
  • Python version: 3.10.11
  • Operating System: Windows11
  • Browser: Edge

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature:st.echoRelated to `st.echo` elementpriority:P3Medium priority - worth fixing without urgencystatus:confirmedBug has been confirmed by the Streamlit teamtype:bugSomething isn't working as expected

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions