internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: streamlit/streamlit

Issue:
allow click > 8
Hello,

I'm using streamlit into an environment where other packages depend on click > 8.0.
I see that there is a mention that it won't work, however from my testing it does work.
https://github.com/streamlit/streamlit/blob/develop/lib/Pipfile#L45

Can someone pinpoint what APIs they think are incompatible?


Discussion:
Hi @nicolaerosia - 

Do you know which packages require click > 8.0? If so, that will make it easier for us to determine what collisions there might be.

Best,
Randy
I'm using celery
kind ping @randyzwitch 
@randyzwitch ?
Hi @nicolaerosia Thanks for following up. I have your information, and I will take it into account. We strive to keep our dependencies up to date. It seems that Streamlit has an error with click specificallly when using Python modules (`python -m streamlit ...`) so we need to investigate the cause and write up a solution.

I'll see how easy it is and see if I can prioritize it. Certainly would plan for early next year at the earliest given the holidays!

Thanks again for reaching out!

Resolving patch:
diff --git a/lib/streamlit/__main__.py b/lib/streamlit/__main__.py
--- a/lib/streamlit/__main__.py
+++ b/lib/streamlit/__main__.py
@@ -20,4 +20,4 @@
     # whether streamlit is called directly or via `python -m streamlit`.
     sys.argv[0] = "streamlit"
 
-    main()
+    main(prog_name="streamlit")
diff --git a/lib/streamlit/cli.py b/lib/streamlit/cli.py
--- a/lib/streamlit/cli.py
+++ b/lib/streamlit/cli.py
@@ -109,7 +109,7 @@ def help(ctx):
 
     assert len(sys.argv) == 2  # This is always true, but let's assert anyway.
     sys.argv[1] = "--help"
-    main()
+    main(prog_name="streamlit")
 
 
 @main.command("version")


Test patch:
Repository: streamlit/streamlit

Issue:
Caching bug
### Summary

In `cache_utils.py` there's the following code:
```python
try:
    source_code = inspect.getsource(func)
except OSError as e:
    _LOGGER.debug(
        "Failed to retrieve function's source code when building its key; falling back to bytecode. err={0}",
        e,
    )
    source_code = func.__code__
```

If the except code is triggered, the `source_code` variable is of `code` type, which is not hashable (at least in python 3.9), and causes an exception afterwards.

### Steps to reproduce

In my case it only happens when I bundle my app with pyinstaller, otherwise the except code is never triggered.
I'm not sure of another way to reproduce it.
A minimal reproducible case would probably be just calling a function wrapped with `st.singleton` after bundling with pyinstaller.

### Suggested solution

Simply replacing the last line with:
```python
source_code = func.__code__.co_code
```
makes the variable a byte-array representation of the function, which is hashbable.
See: https://docs.python.org/3/library/inspect.html


Discussion:
Thanks for reporting this, @vToMy!

Your suggested fix sounds like what we actually meant to do here given the documentation of the `co_code` attr, so I'll have a fix out for this soon.

Resolving patch:
diff --git a/lib/streamlit/caching/cache_utils.py b/lib/streamlit/caching/cache_utils.py
--- a/lib/streamlit/caching/cache_utils.py
+++ b/lib/streamlit/caching/cache_utils.py
@@ -300,7 +300,7 @@ def _make_function_key(cache_type: CacheType, func: types.FunctionType) -> str:
 
     # Include the function's source code in its hash. If the source code can't
     # be retrieved, fall back to the function's bytecode instead.
-    source_code: Union[str, types.CodeType]
+    source_code: Union[str, bytes]
     try:
         source_code = inspect.getsource(func)
     except OSError as e:
@@ -308,7 +308,7 @@ def _make_function_key(cache_type: CacheType, func: types.FunctionType) -> str:
             "Failed to retrieve function's source code when building its key; falling back to bytecode. err={0}",
             e,
         )
-        source_code = func.__code__
+        source_code = func.__code__.co_code
 
     update_hash(
         source_code,


Test patch:
Repository: streamlit/streamlit

Issue:
Support PNG as the page icon
Right now, if you use `st.set_page_config()` to set a PNG as the page icon, it seems that the function will convert the image to a JPEG (losing its transparent background properties):
https://github.com/streamlit/streamlit/blob/06330bd65d22a8d7c83c0e3fd4935265a83db612/lib/streamlit/commands/page_config.py#L107

So a PNG like this:
<img width="62" alt="favicon" src="https://user-images.githubusercontent.com/41839984/147370470-6597b5e6-6405-42b4-8f0e-f936ff6499df.png">

Will end up in the page icon like this:
<img width="543" alt="image" src="https://user-images.githubusercontent.com/41839984/147370454-563c26ec-357d-4e52-a3fe-b8b4723d983e.png">

It would be nice to have the option to set a PNG as the page icon and maintain its transparency.


Discussion:
I am also facing this, but found a way to fix it. I'll post a PR with the change to support transparency.

Resolving patch:
diff --git a/lib/streamlit/commands/page_config.py b/lib/streamlit/commands/page_config.py
--- a/lib/streamlit/commands/page_config.py
+++ b/lib/streamlit/commands/page_config.py
@@ -104,7 +104,7 @@ def set_page_config(
             width=-1,  # Always use full width for favicons
             clamp=False,
             channels="RGB",
-            output_format="JPEG",
+            output_format="auto",
             image_id="favicon",
             allow_emoji=True,
         )


Test patch:
Repository: streamlit/streamlit

Issue:
Expander state is incorrectly shared by distinct expanders
### Summary

The expanded/collapsed state of two distinct expanders seems to be incorrectly shared. Consider the code snippet and repro steps below.

### Steps to reproduce

```python
import streamlit as st

b0 = st.button("b0")
b1 = st.button("b1")

if b0:
    with st.expander("b0_expander", expanded=False):
        st.write("b0_write")

if b1:
    with st.expander("b1_expander", expanded=False):
        st.write("b1_write")
```


1. click b0 & b1 and observe that both b0_expander & b1_expander are collapsed
2. click b0 & expand b0_expander
3. click b1
4. b1_expander should be collapsed but is expanded.

**Expected behavior:**

`b1` should be collapsed as it is a newly drawn expander distinct from `b0`

**Actual behavior:**

`b1` inherits the expanded state from `b0` on initial render


### Is this a regression?

unsure, but probably not?

### Debug info

- Streamlit version: 1.3.1
- Python version: 3.8.9
- OS version: MacOS 12.1
- Browser version: Chrome v96

### Additional information

This issue was originally reported [in this post](https://discuss.streamlit.io/t/expander-expanded-false-not-working/20786) on the forum. An app demonstrating the bug [can be found here](https://share.streamlit.io/kimehta/octopus-streamlit/main/temp.py)



Discussion:
Likely, the reason is that we determine setup based on location of the widget (first item, second item), since the expanders get replaced, it’s interpreting the same component, but different contents, which creates the problem.
A workaround would be using st.empty() in place when the expander is not visible…to indicate a change in structure.

```python
import streamlit as st

b0 = st.button("b0")
b1 = st.button("b1")

if b0:
    with st.expander("b0_expander", expanded=False):
        st.write("b0_write")
else:
    st.empty()

if b1:
    with st.expander("b1_expander", expanded=False):
        st.write("b1_write")
else:
    st.empty()
```

A trivial solution that may be an improvement is to set a key for the Expander to be equivalent of the Widget ID, this can probably be simple and be the label or label + expanded flags to reflect the arguments, but it’s not a perfect solution. And would need to be investigated if different expanders have the same label (something as simple as "More info" can be common)

Resolving patch:
diff --git a/e2e/scripts/expander_state.py b/e2e/scripts/expander_state.py
new file mode 100644
--- /dev/null
+++ b/e2e/scripts/expander_state.py
@@ -0,0 +1,12 @@
+import streamlit as st
+
+b0 = st.button("b0")
+b1 = st.button("b1")
+
+if b0:
+    with st.expander("b0_expander", expanded=False):
+        st.write("b0_write")
+
+if b1:
+    with st.expander("b1_expander", expanded=False):
+        st.write("b1_write")


Test patch:
Repository: streamlit/streamlit

Issue:
Unnecessary space symbol in markdown in lib/streamlit/hello/demos.py 
### Summary
There are unnecessary space symbols in markdown in lib/streamlit/hello/demos.py 

### Steps to reproduce

Code snippet (https://github.com/streamlit/streamlit/blob/develop/lib/streamlit/hello/demos.py):

```
    st.markdown(
        """
        Streamlit is an open-source app framework built specifically for
        Machine Learning and Data Science projects.
        **👈 Select a demo from the dropdown on the left** to see some examples
        of what Streamlit can do!
        ### Want to learn more?
        - Check out [streamlit.io](https://streamlit.io)
        - Jump into our [documentation](https://docs.streamlit.io)
        - Ask a question in our [community
          forums](https://discuss.streamlit.io)
        ### See more complex demos
        - Use a neural net to [analyze the Udacity Self-driving Car Image
          Dataset] (https://github.com/streamlit/demo-self-driving)
        - Explore a [New York City rideshare dataset]
          (https://github.com/streamlit/demo-uber-nyc-pickups)
    """
    )
```
If applicable, please provide the steps we should take to reproduce the bug:

1. run "streamlit hello"
2. open the front page
3. pay attention to the "See more complex demos" section

**Actual behavior:**
Markdown links are broken. There should not be spaces between `[text]` and `(URL)` parts (see code snippet)
![image](https://user-images.githubusercontent.com/23180059/155370113-e0311ba8-1968-4401-96b8-d527a3172e3b.png)

**Expected behavior:**
Links are correctly shown

### Is this a regression?
maybe, but it reproduces in a previous released version

### Debug info

- Streamlit version: 1.6.0rc
- Python version: 3.9.7
- Using Conda and PipEnv



Discussion:

Resolving patch:
diff --git a/lib/streamlit/hello/demos.py b/lib/streamlit/hello/demos.py
--- a/lib/streamlit/hello/demos.py
+++ b/lib/streamlit/hello/demos.py
@@ -39,9 +39,8 @@ def intro():
         ### See more complex demos
 
         - Use a neural net to [analyze the Udacity Self-driving Car Image
-          Dataset] (https://github.com/streamlit/demo-self-driving)
-        - Explore a [New York City rideshare dataset]
-          (https://github.com/streamlit/demo-uber-nyc-pickups)
+          Dataset](https://github.com/streamlit/demo-self-driving)
+        - Explore a [New York City rideshare dataset](https://github.com/streamlit/demo-uber-nyc-pickups)
     """
     )
 


Test patch:
Repository: streamlit/streamlit

Issue:
List supported languages for syntax highlighting with `st.code`
**Link to doc page in question (if any):** https://docs.streamlit.io/library/api-reference/text/st.code

**Name of the Streamlit feature whose docs need improvement:** `st.code`

**What you think the docs should say:** The docs should provide a list of all supported languages for syntax highlighting.



Discussion:

Resolving patch:
diff --git a/lib/streamlit/elements/markdown.py b/lib/streamlit/elements/markdown.py
--- a/lib/streamlit/elements/markdown.py
+++ b/lib/streamlit/elements/markdown.py
@@ -36,7 +36,7 @@ def markdown(self, body: str, unsafe_allow_html: bool = False) -> "DeltaGenerato
 
             This also supports:
 
-            * Emoji shortcodes, such as `:+1:`  and `:sunglasses:`.
+            * Emoji shortcodes, such as ``:+1:``  and ``:sunglasses:``.
               For a list of all supported codes,
               see https://share.streamlit.io/streamlit/emoji-shortcodes.
 
@@ -55,7 +55,7 @@ def markdown(self, body: str, unsafe_allow_html: bool = False) -> "DeltaGenerato
 
             https://github.com/streamlit/streamlit/issues/152
 
-            *Also note that `unsafe_allow_html` is a temporary measure and may
+            *Also note that ``unsafe_allow_html`` is a temporary measure and may
             be removed from Streamlit at any time.*
 
             If you decide to turn on HTML anyway, we ask you to please tell us
@@ -143,6 +143,10 @@ def code(self, body: str, language: Optional[str] = "python") -> "DeltaGenerator
             The language that the code is written in, for syntax highlighting.
             If omitted, the code will be unstyled.
 
+            For a list of available ``language`` imports, see:
+
+            https://github.com/react-syntax-highlighter/react-syntax-highlighter/blob/master/AVAILABLE_LANGUAGES_PRISM.MD
+
         Example
         -------
         >>> code = '''def hello():


Test patch:
Repository: streamlit/streamlit

Issue:
It should be :
https://github.com/streamlit/streamlit/blob/535f11765817657892506d6904bbbe04908dbdf3/lib/streamlit/elements/alert.py#L145



Discussion:
It should be
st.success('This is a success message!', icon="✅")
Thanks, @dang-mai for finding this!

Should be fixed by https://github.com/streamlit/streamlit/pull/5180

Resolving patch:
diff --git a/lib/streamlit/elements/alert.py b/lib/streamlit/elements/alert.py
--- a/lib/streamlit/elements/alert.py
+++ b/lib/streamlit/elements/alert.py
@@ -142,7 +142,7 @@ def success(
 
         Example
         -------
-        >>> st.success('This is a success message!', icon:"✅")
+        >>> st.success('This is a success message!', icon="✅")
 
         """
         alert_proto = AlertProto()


Test patch:
Repository: streamlit/streamlit

Issue:
protobuf error on clean streamlit install of 1.12.3
### Summary

I installed streamlit, and couldn't use it due to a reported error from protobuf. Protobuf version 3.20.2 was installed automatically along with streamlit.

### Steps to reproduce

Code snippet:

```
pip install streamlit
streamlit run something.py
```

Error
```
streamlit run app.py

Traceback (most recent call last):
  File "/private/tmp/tttt/.direnv/python-3.10.3/bin/streamlit", line 5, in <module>
    from streamlit.web.cli import main
  File "/private/tmp/tttt/.direnv/python-3.10.3/lib/python3.10/site-packages/streamlit/__init__.py", line 48, in <module>
    from streamlit.proto.RootContainer_pb2 import RootContainer
  File "/private/tmp/tttt/.direnv/python-3.10.3/lib/python3.10/site-packages/streamlit/proto/RootContainer_pb2.py", line 6, in <module>
    from google.protobuf import descriptor as _descriptor
  File "/private/tmp/tttt/.direnv/python-3.10.3/lib/python3.10/site-packages/google/protobuf/descriptor.py", line 47, in <module>
    from google.protobuf.pyext import _message
ImportError: dlopen(/private/tmp/tttt/.direnv/python-3.10.3/lib/python3.10/site-packages/google/protobuf/pyext/_message.cpython-310-darwin.so, 0x0002): symbol not found in flat namespace (__ZN6google8protobuf15FieldDescriptor12TypeOnceInitEPKS1_)
```

This was solved by downgrading protobuf 
```
pip install protobuf==3.19.4
```
(Please provide a code snippet! This will help expedite us finding and solving the problem.)

If applicable, please provide the steps we should take to reproduce the bug:

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'

**Expected behavior:**

App opens

**Actual behavior:**

Error message

### Is this a regression?

Yes

### Debug info

- Streamlit version: (get it with `$ streamlit version`) 
```
In [4]: version._get_installed_streamlit_version()
Out[4]: <Version('1.12.3.dev20220919')>
```
- Python version: (get it with `$ python --version`) 3.10.3
- Using Conda? PipEnv? PyEnv? Pex? pyenv
- OS version: OSX
- Browser version: 

### Additional information

Came from https://discuss.streamlit.io/t/streamlit-hello-returns-importerror/30929/3?u=blackary


Discussion:

Resolving patch:
diff --git a/lib/setup.py b/lib/setup.py
--- a/lib/setup.py
+++ b/lib/setup.py
@@ -45,7 +45,8 @@
     "packaging>=14.1",
     "pandas>=0.21.0",
     "pillow>=6.2.0",
-    "protobuf<4,>=3.12",
+    # protobuf 3.20.2 is broken: https://github.com/protocolbuffers/protobuf/issues/10571
+    "protobuf<4,>=3.12,!=3.20.2",
     "pyarrow>=4.0",
     "pydeck>=0.1.dev5",
     "pympler>=0.9",


Test patch:
Repository: streamlit/streamlit

Issue:
Emojis are not valid if they have a variant selector character attached
### Summary

Emojis are not valid if they are prefixed with a variant selector character. This is a hidden character that is used as prefix for the emoji (more information [here](https://stackoverflow.com/questions/38100329/what-does-u-ufe0f-in-an-emoji-mean-is-it-the-same-if-i-delete-it)).

### Steps to reproduce

[![Open in Streamlit Cloud](https://static.streamlit.io/badges/streamlit_badge_black_white.svg)](https://issues.streamlitapp.com/?issue=gh-5564)

Code snippet:

```python
st.error("This is an error", icon="🚨") # Works fine
st.error("This is an error", icon="️🚨") # Throws an error
```

The reason is that the second example is prefix with this hidden unicode character: `%uFE0F`:

```python
st.write(len("🚨"))  # 1
st.write(len("️🚨"))  # 2
```

**Expected behavior:**

Should not raise an exception.

**Actual behavior:**

Raises a `StreamlitAPIException` if used for `st.error`, `st.info`, ...

### Is this a regression?

no


Discussion:
FYI, this can also be a postfix, in addition to a prefix

e.g. `icon="⛔️"` (has an extra character after the emoji) vs `icon="⛔"`
Hey! @LukasMasuch @blackary 
I'd love to look into this.

Resolving patch:
diff --git a/lib/streamlit/string_util.py b/lib/streamlit/string_util.py
--- a/lib/streamlit/string_util.py
+++ b/lib/streamlit/string_util.py
@@ -43,7 +43,7 @@ def clean_text(text: "SupportsStr") -> str:
 
 def is_emoji(text: str) -> bool:
     """Check if input string is a valid emoji."""
-    return text in ALL_EMOJIS
+    return text.replace("\U0000FE0F", "") in ALL_EMOJIS
 
 
 def extract_leading_emoji(text: str) -> Tuple[str, str]:


Test patch:
diff --git a/lib/tests/streamlit/string_util_test.py b/lib/tests/streamlit/string_util_test.py
--- a/lib/tests/streamlit/string_util_test.py
+++ b/lib/tests/streamlit/string_util_test.py
@@ -34,6 +34,9 @@ def test_decode_ascii(self):
             ("😃😃", False),
             ("😃X", False),
             ("X😃", False),
+            ("️🚨", True),
+            ("️⛔️", True),
+            ("️👍🏽", True),
         ]
     )
     def test_is_emoji(self, text: str, expected: bool):
Repository: streamlit/streamlit

Issue:
DuplicateWidgetID error message is misleading when creating two different widgets with the same key
### Checklist

- [X] I have searched the [existing issues](https://github.com/streamlit/streamlit/issues) for similar issues.
- [X] I added a very descriptive title to this issue.
- [X] I have provided sufficient information below to help reproduce this issue.

### Summary

The error message when DuplicateWidgetID is raised suggests that two widgets of the same type with the same key have been created when this is sometimes not the case.

### Reproducible Code Example

```Python
import streamlit as st

st.button("Button", key="x")
st.checkbox("Checkbox", key="x")
```


### Steps To Reproduce

_No response_

### Expected Behavior

1. Allow widgets of different type to have the same ID.

or

2. An improved error message something like:
```
DuplicateWidgetID: There are multiple widgets (st.button, st.checkbox) with key='x'.

To fix this, please make sure that the key argument is unique for each widget you create.
```

### Current Behavior

Error message:
```
DuplicateWidgetID: There are multiple identical st.checkbox widgets with key='x'.

To fix this, please make sure that the key argument is unique for each st.checkbox you create.
```

### Is this a regression?

- [ ] Yes, this used to work in a previous version.

### Debug info

- Streamlit version: 1.14.1
- Python version: 3.8
- Operating System: Ubuntu 22.04
- Browser: Safari
- Virtual environment: None


### Additional Information

_No response_

### Are you willing to submit a PR?

- [ ] Yes, I am willing to submit a PR!


Discussion:
Thanks for reporting this, @jaredvann.

It may be surprisingly tricky (or at least not worth the amount of effort+additional complexity for what's just a marginally better error message) to include the type of the widget with the conflicting key in the error message. It would be trivial, however, to change the error message so that it's no longer misleading.

I'll have a PR out fixing this momentarily.

Resolving patch:
diff --git a/lib/streamlit/runtime/state/widgets.py b/lib/streamlit/runtime/state/widgets.py
--- a/lib/streamlit/runtime/state/widgets.py
+++ b/lib/streamlit/runtime/state/widgets.py
@@ -306,11 +306,10 @@ def _build_duplicate_widget_message(
     if user_key is not None:
         message = textwrap.dedent(
             """
-            There are multiple identical `st.{widget_type}` widgets with
-            `key='{user_key}'`.
+            There are multiple widgets with the same `key='{user_key}'`.
 
-            To fix this, please make sure that the `key` argument is unique for
-            each `st.{widget_type}` you create.
+            To fix this, please make sure that the `key` argument is unique for each
+            widget you create.
             """
         )
     else:


Test patch:
Repository: streamlit/streamlit

Issue:
Regression in v1.18.0 `st.metric`'s `help` tooltip position
### Checklist

- [X] I have searched the [existing issues](https://github.com/streamlit/streamlit/issues) for similar issues.
- [X] I added a very descriptive title to this issue.
- [X] I have provided sufficient information below to help reproduce this issue.

### Summary

[Reported](https://discuss.streamlit.io/t/version-1-18-0/37501/3?u=snehankekre) by @marduk2 on our forum. The `help` tooltip for `st.metric` has changed positions in v1.18.0 and appears under the metric label instead of to its right.

### Reproducible Code Example

```Python
import streamlit as st

st.title("'Help' tooltips in st.metric render in a weird position")

st.metric(
    label="Example metric",
    help="Something doesn't feel right...",
    value=150.59,
    delta="Very high",
)
```


### Steps To Reproduce

1. Run the app

### Expected Behavior

![image](https://user-images.githubusercontent.com/20672874/218045613-aa7e4a97-5f7f-418f-ad64-a795807a7d33.png)


### Current Behavior

![image](https://user-images.githubusercontent.com/20672874/218045435-bc389e06-c5ae-4bd9-bd0b-74b1c4860976.png)


### Is this a regression?

- [X] Yes, this used to work in a previous version.

### Debug info

- Streamlit version: 1.18.0
- Python version: 3.9
- Operating System: macOS
- Browser: Chrome
- Virtual environment: NA


### Additional Information

_No response_

### Are you willing to submit a PR?

- [ ] Yes, I am willing to submit a PR!


Discussion:
This has been deprioritized to p2 and as a result, a fix will be included in the next release! 

Resolving patch:
diff --git a/e2e/scripts/st_metric.py b/e2e/scripts/st_metric.py
--- a/e2e/scripts/st_metric.py
+++ b/e2e/scripts/st_metric.py
@@ -41,3 +41,13 @@
     st.metric("Test 4", -4.56, 1.23, label_visibility="hidden")
 with col3:
     st.metric("Test 5", -4.56, 1.23, label_visibility="collapsed")
+
+col1, col2, col3, col4, col5, col6, col7, col8 = st.columns(8)
+
+with col1:
+    st.metric(
+        label="Example metric",
+        help="Something should feel right",
+        value=150.59,
+        delta="Very high",
+    )


Test patch: