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

Issue:
DASH_DEBUG variable has no effect
https://dash.plotly.com/reference

Definition of external environment variable `export DASH_DEBUG=True` does not trigger debugging mode. It appears that it must be set within:

```
f __name__=='__main__':
    app.run_server(host='localhost', debug=True)
```

I have the latest dash. You can try to reproduce the issue by removing `debug=True` from code of your favorite app and defining `DASH_DEBUG` via `export`. 


Discussion:

Resolving patch:
diff --git a/dash/dash.py b/dash/dash.py
--- a/dash/dash.py
+++ b/dash/dash.py
@@ -1896,7 +1896,7 @@ def run(
         host=os.getenv("HOST", "127.0.0.1"),
         port=os.getenv("PORT", "8050"),
         proxy=os.getenv("DASH_PROXY", None),
-        debug=False,
+        debug=None,
         dev_tools_ui=None,
         dev_tools_props_check=None,
         dev_tools_serve_dev_bundles=None,
@@ -1987,6 +1987,9 @@ def run(
 
         :return:
         """
+        if debug is None:
+            debug = get_combined_config("debug", None, False)
+
         debug = self.enable_dev_tools(
             debug,
             dev_tools_ui,


Test patch:
diff --git a/tests/unit/test_configs.py b/tests/unit/test_configs.py
--- a/tests/unit/test_configs.py
+++ b/tests/unit/test_configs.py
@@ -437,3 +437,48 @@ def test_app_invalid_delayed_config():
     app = Dash(server=False)
     with pytest.raises(AttributeError):
         app.init_app(app=Flask("test"), name="too late 2 update")
+
+
+@pytest.mark.parametrize(
+    "debug_env, debug, expected",
+    [
+        (None, None, False),
+        (None, True, True),
+        (None, False, False),
+        ('True', None, True),
+        ('True', True, True),
+        ('True', False, False),
+        ('False', None, False),
+        ('False', True, True),
+        ('False', False, False),
+    ],
+)
+def test_debug_mode_run(empty_environ, debug_env, debug, expected):
+    if debug_env:
+        os.environ['DASH_DEBUG'] = debug_env
+    app = Dash()
+    with pytest.raises(AssertionError):
+        app.run(debug=debug, port=-1)
+    assert app._dev_tools.ui == expected
+
+
+@pytest.mark.parametrize(
+    "debug_env, debug, expected",
+    [
+        (None, None, True),
+        (None, True, True),
+        (None, False, False),
+        ('True', None, True),
+        ('True', True, True),
+        ('True', False, False),
+        ('False', None, False),
+        ('False', True, True),
+        ('False', False, False),
+    ],
+)
+def test_debug_mode_enable_dev_tools(empty_environ, debug_env, debug, expected):
+    if debug_env:
+        os.environ['DASH_DEBUG'] = debug_env
+    app = Dash()
+    app.enable_dev_tools(debug=debug)
+    assert app._dev_tools.ui == expected
Repository: plotly/dash

Issue:
[BUG] @app.long_callback has interval set to None
I recently upgraded our dash code (from 2.5.1 to 2.8.0). 

I noticed that our long callbacks using the original `@app.long_callback` decorator is polling our backend many times a second, instead of only once a second.

If I switch over to the new `background=True`, then the 1 second polling is restored. 

I think this is a undesired client regression.

**Describe your context**
Please provide us your environment, so we can easily reproduce the issue.

-  replace the result of `pip list | grep dash` below
```
dash                      2.8.0
dash-core-components      2.0.0
dash-html-components      2.0.0
dash-table                5.0.0
```

**Describe the bug**

My frontend application is polling the backend excessively using `@app.long_callback` when the `interval` value is unset.

**Expected behavior**

When a long callback is created using `@app.long_callback`, the default interval of 1 second should be used.


Discussion:

Resolving patch:
diff --git a/dash/dash.py b/dash/dash.py
--- a/dash/dash.py
+++ b/dash/dash.py
@@ -1162,7 +1162,7 @@ def long_callback(
         self,
         *_args,
         manager=None,
-        interval=None,
+        interval=1000,
         running=None,
         cancel=None,
         progress=None,


Test patch:
Repository: plotly/dash

Issue:
[BUG] Exception when property of patched_fig is viewed
I know that it is currently not supported to view properties of `patch_fig=Patch()` but when e.g. iterating over trace names like so:
```
 for trace in patched_fig['data']:
        print(trace['name'])
```
no exception or error message is thrown but an endless stream of 

```
...
<dash._patch.Patch object at 0x7f3b89a89b80>
<dash._patch.Patch object at 0x7f3b8305c0a0>
<dash._patch.Patch object at 0x7f3b89a89b80>
<dash._patch.Patch object at 0x7f3b8305c0a0>
<dash._patch.Patch object at 0x7f3b89a89b80>
<dash._patch.Patch object at 0x7f3b8305c0a0>
...
```
This is not exactly intended right?

I got there by trying to delete a trace of patched_fig by its name which otherwise appears not be possible (or is it?)



Discussion:
Right, you can’t read from the prop this way, only write. We do have an open issue somewhere to support the kind of query-targeted updates you’re suggesting but it hasn’t been worked on yet. 

I suppose we could override `__repr__` for `Patch` objects to describe that you can’t read from them, would that help?
This create an infinite loop, should implement `__iter__` to raise an error.
> Right, you can’t read from the prop this way, only write. We do have an open issue somewhere to support the kind of query-targeted updates you’re suggesting but it hasn’t been worked on yet.
> 
> I suppose we could override `__repr__` for `Patch` objects to describe that you can’t read from them, would that help?

Yes that would help.
Which open issue do you mean? :)

Resolving patch:
diff --git a/dash/_patch.py b/dash/_patch.py
--- a/dash/_patch.py
+++ b/dash/_patch.py
@@ -99,6 +99,12 @@ def __ior__(self, other):
         self.update(E=other)
         return _noop
 
+    def __iter__(self):
+        raise TypeError("Patch objects are write-only, you cannot iterate them.")
+
+    def __repr__(self):
+        return f"<write-only dash.Patch object at {self._location}>"
+
     def append(self, item):
         """Add the item to the end of a list"""
         self._operations.append(_operation("Append", self._location, value=item))


Test patch:
diff --git a/tests/unit/test_patch.py b/tests/unit/test_patch.py
--- a/tests/unit/test_patch.py
+++ b/tests/unit/test_patch.py
@@ -255,3 +255,11 @@ def test_pat020_patch_pickle():
     q = pickle.loads(data)
 
     assert patch_to_dict(p) == patch_to_dict(q)
+
+
+def test_pat021_patch_iter():
+    p = Patch()
+
+    with pytest.raises(TypeError):
+        for _ in p["invalid"]:
+            print("invalid iteration")
Repository: plotly/dash

Issue:
[BUG] Flask 2.2.3 dependency has HIGH security vulnerability (fixed in 2.2.5)
Issue #2538 pinned the upper bound of the Flask dependency to 2.2.3. However Flask 2.2.3 is affected by a HIGH security vulnerability that is fixed in Flask 2.2.5. See https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2023-30861

Debian 11, Python 3.11 (from Python official 3.11 Docker image)
```
# pip install dash
Collecting dash
  Downloading dash-2.10.1-py3-none-any.whl (10.3 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 10.3/10.3 MB 14.1 MB/s eta 0:00:00
Collecting Flask<=2.2.3,>=1.0.4 (from dash)
  Downloading Flask-2.2.3-py3-none-any.whl (101 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 101.8/101.8 kB 17.0 MB/s eta 0:00:00
```

```
dash                     2.10.1
dash-core-components     2.0.0
dash-html-components     2.0.0
dash-table               5.0.0
```

**Describe the bug**

Dash installs a vulnerable version of Flask and dependency scans flag the vulnerability.

**Expected behavior**

No known and fixed security vulnerabilities added. Perhaps Pin to 2.2.* instead of specific 2.2.3 version where future pins will find new security issues.




Discussion:

Resolving patch:
diff --git a/dash/version.py b/dash/version.py
--- a/dash/version.py
+++ b/dash/version.py
@@ -1 +1 @@
-__version__ = "2.10.1"
+__version__ = "2.10.2"


Test patch:
Repository: plotly/dash

Issue:
[BUG] Server fails to setup when using background callbacks without cancel argument
**Describe your context**
Please provide us your environment, so we can easily reproduce the issue.

-  replace the result of `pip list | grep dash` below
```
dash                                     2.12.0
dash-bootstrap-components                1.4.2
dash-bootstrap-templates                 1.0.8
dash-core-components                     2.0.0
dash-html-components                     2.0.0
dash-table                               5.0.0
```
-  if frontend related, tell us your Browser, Version and OS

    - OS: [e.g. iOS]
    - Browser [e.g. chrome, safari]
    - Version [e.g. 22]

**Describe the bug**

Server fails to setup when using background callbacks without cancel argument.
[This condition](https://github.com/plotly/dash/blob/909e39cad3041ded960432d29fa493e34cd90dab/dash/_callback.py#L169) is not triggered, causing a KeyError [here](https://github.com/plotly/dash/blob/909e39cad3041ded960432d29fa493e34cd90dab/dash/dash.py#L1324).

**Expected behavior**

Server setups properly. Adding None as default to the offending pop seemed to fix the issue in my quick test.



Discussion:

Resolving patch:
diff --git a/dash/dash.py b/dash/dash.py
--- a/dash/dash.py
+++ b/dash/dash.py
@@ -1321,8 +1321,8 @@ def _setup_server(self):
             long = callback.get("long")
             if not long:
                 continue
-            cancel = long.pop("cancel_inputs")
-            if cancel:
+            if "cancel_inputs" in long:
+                cancel = long.pop("cancel_inputs")
                 for c in cancel:
                     cancels[c] = long.get("manager")
 
diff --git a/dash/version.py b/dash/version.py
--- a/dash/version.py
+++ b/dash/version.py
@@ -1 +1 @@
-__version__ = "2.12.0"
+__version__ = "2.12.1"


Test patch:
diff --git a/tests/integration/long_callback/app_page_cancel.py b/tests/integration/long_callback/app_page_cancel.py
--- a/tests/integration/long_callback/app_page_cancel.py
+++ b/tests/integration/long_callback/app_page_cancel.py
@@ -34,6 +34,8 @@
             html.Button("cancel1", id="cancel1"),
             html.Div("idle", id="progress1"),
             html.Div("initial", id="output1"),
+            html.Div("no-cancel-btn", id="no-cancel-btn"),
+            html.Div("no-cancel", id="no-cancel-output"),
         ]
     ),
 )
@@ -51,6 +53,16 @@
 )
 
 
+@app.callback(
+    Output("no-cancel-output", "children"),
+    Input("no-cancel-btn", "n_clicks"),
+    background=True,
+    prevent_initial_call=True,
+)
+def on_click_no_cancel(_):
+    return "Not Canceled"
+
+
 @app.callback(
     Output("output1", "children"),
     Input("start1", "n_clicks"),
Repository: plotly/dash

Issue:
upon dash import: DeprecationWarning: pkg_resources is deprecated as an API
I am getting many deprecation warnings from Setuptools everytime dash is imported:
venv\lib\site-packages\dash\dash.py:22: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html

My dash environment
```
dash                        2.12.1
dash-bootstrap-components   1.4.2
dash-core-components        2.0.0
dash-html-components        2.0.0
dash-table                  5.0.0
```

On line 22 from dash.py:
```python
from pkg_resources import get_distribution, parse_version
```

From [setuptools](https://setuptools.pypa.io/en/latest/pkg_resources.html#package-discovery-and-resource-access-using-pkg-resources):

Attention

Use of pkg_resources is deprecated in favor of [importlib.resources](https://docs.python.org/3/library/importlib.resources.html#module-importlib.resources), [importlib.metadata](https://docs.python.org/3/library/importlib.metadata.html#module-importlib.metadata) and their backports ([importlib_resources](https://pypi.org/project/importlib_resources), [importlib_metadata](https://pypi.org/project/importlib_metadata)). Some useful APIs are also provided by [packaging](https://pypi.org/project/packaging) (e.g. requirements and version parsing). Users should refrain from new usage of pkg_resources and should work to port to importlib-based solutions.



Discussion:

Resolving patch:
diff --git a/dash/_utils.py b/dash/_utils.py
--- a/dash/_utils.py
+++ b/dash/_utils.py
@@ -277,3 +277,7 @@ def hooks_to_js_object(hooks: Union[RendererHooks, None]) -> str:
     hook_str = ",".join(f"{key}: {val}" for key, val in hooks.items())
 
     return f"{{{hook_str}}}"
+
+
+def parse_version(version):
+    return tuple(int(s) for s in version.split("."))
diff --git a/dash/dash.py b/dash/dash.py
--- a/dash/dash.py
+++ b/dash/dash.py
@@ -20,7 +20,7 @@
 
 import flask
 
-from pkg_resources import get_distribution, parse_version
+from importlib_metadata import version as _get_distribution_version
 
 from dash import dcc
 from dash import html
@@ -54,6 +54,7 @@
     convert_to_AttributeDict,
     gen_salt,
     hooks_to_js_object,
+    parse_version,
 )
 from . import _callback
 from . import _get_paths
@@ -567,7 +568,7 @@ def init_app(self, app=None, **kwargs):
                 Compress(self.server)
 
                 _flask_compress_version = parse_version(
-                    get_distribution("flask-compress").version
+                    _get_distribution_version("flask_compress")
                 )
 
                 if not hasattr(


Test patch:
Repository: plotly/dash

Issue:
[BUG] No output callbacks with clientside_callback
If a clientside callback has no output, it generate `ID not found in layout` error:
```
clientside_callback(
    """
    function(_) {
        window.location.reload();
    }
    """,
    Input("reset-button", "n_clicks"),
    prevent_initial_call=True,
)
```





Discussion:

Resolving patch:
diff --git a/dash/_callback.py b/dash/_callback.py
--- a/dash/_callback.py
+++ b/dash/_callback.py
@@ -549,6 +549,7 @@ def register_clientside_callback(
     **kwargs,
 ):
     output, inputs, state, prevent_initial_call = handle_callback_args(args, kwargs)
+    no_output = isinstance(output, (list,)) and len(output) == 0
     insert_callback(
         callback_list,
         callback_map,
@@ -559,6 +560,7 @@ def register_clientside_callback(
         state,
         None,
         prevent_initial_call,
+        no_output=no_output,
     )
 
     # If JS source is explicitly given, create a namespace and function


Test patch:
diff --git a/tests/integration/callbacks/test_arbitrary_callbacks.py b/tests/integration/callbacks/test_arbitrary_callbacks.py
--- a/tests/integration/callbacks/test_arbitrary_callbacks.py
+++ b/tests/integration/callbacks/test_arbitrary_callbacks.py
@@ -1,7 +1,15 @@
 import time
 from multiprocessing import Value
 
-from dash import Dash, Input, Output, html, set_props, register_page
+from dash import (
+    Dash,
+    Input,
+    Output,
+    html,
+    set_props,
+    register_page,
+    clientside_callback,
+)
 
 
 def test_arb001_global_set_props(dash_duo):
@@ -188,3 +196,39 @@ def on_click(_):
     dash_duo.wait_for_style_to_equal(
         "#output", "background-color", "rgba(255, 0, 0, 1)"
     )
+
+
+def test_arb007_clientside_no_output(dash_duo):
+    app = Dash()
+
+    app.layout = [
+        html.Button("start", id="start1"),
+        html.Button("start2", id="start2"),
+        html.Div(id="output"),
+    ]
+
+    clientside_callback(
+        """
+        function(_) {
+            dash_clientside.set_props('output', {children: 'start1'})
+        }
+        """,
+        Input("start1", "n_clicks"),
+        prevent_initial_call=True,
+    )
+    clientside_callback(
+        """
+        function(_) {
+            dash_clientside.set_props('output', {children: 'start2'})
+        }
+        """,
+        Input("start2", "n_clicks"),
+        prevent_initial_call=True,
+    )
+
+    dash_duo.start_server(app)
+
+    dash_duo.find_element("#start1").click()
+    dash_duo.wait_for_text_to_equal("#output", "start1")
+    dash_duo.find_element("#start2").click()
+    dash_duo.wait_for_text_to_equal("#output", "start2")
Repository: plotly/dash

Issue:
[BUG] No Layout Exception when using string elements when the layout is a list
In all versions of Dash this works:

```python 
app.layout = html.Div(["Select City", dcc.Dropdown()])
```

In dash >= 2.17, this will throw an error:

```python 
app.layout = ["Select City", dcc.Dropdown()]
```

Here is a full example.  When I run the app, I see the following error.  After refreshing the screen it works fine.

```python
from dash import Dash, dcc
app = Dash(__name__)

app.layout = ["Select City", dcc.Dropdown()]

if __name__ == '__main__':
    app.run(debug=True)


```

![image](https://github.com/plotly/dash/assets/72614349/2931a433-d570-4fd4-ac37-3781a83d5849)





Discussion:

Resolving patch:
diff --git a/dash/_validate.py b/dash/_validate.py
--- a/dash/_validate.py
+++ b/dash/_validate.py
@@ -439,11 +439,13 @@ def _validate_id(comp):
 
     if isinstance(layout_value, (list, tuple)):
         for component in layout_value:
+            if isinstance(component, (str,)):
+                continue
             if isinstance(component, (Component,)):
                 _validate(component)
             else:
                 raise exceptions.NoLayoutException(
-                    "List of components as layout must be a list of components only."
+                    "Only strings and components are allowed in a list layout."
                 )
     else:
         _validate(layout_value)


Test patch:
diff --git a/tests/integration/test_integration.py b/tests/integration/test_integration.py
--- a/tests/integration/test_integration.py
+++ b/tests/integration/test_integration.py
@@ -433,6 +433,8 @@ def test_inin028_layout_as_list(dash_duo):
     app = Dash()
 
     app.layout = [
+        "string1",
+        "string2",
         html.Div("one", id="one"),
         html.Div("two", id="two"),
         html.Button("direct", id="direct"),
@@ -458,6 +460,9 @@ def on_nested_click(n_clicks):
 
     dash_duo.start_server(app)
 
+    dash_duo.wait_for_contains_text("#react-entry-point", "string1")
+    dash_duo.wait_for_contains_text("#react-entry-point", "string2")
+
     dash_duo.wait_for_text_to_equal("#one", "one")
     dash_duo.wait_for_text_to_equal("#two", "two")
Repository: googleapis/python-bigquery

Issue:
Refactor logic in synth.py for excluding noxfile
As explained in a [comment](https://github.com/googleapis/python-bigquery/pull/1#discussion_r375560206), preventing the synthtool for overriding the customized `noxfile.py` can be achieved in a more straightforward way than currently used.



Discussion:

Resolving patch:
diff --git a/synth.py b/synth.py
--- a/synth.py
+++ b/synth.py
@@ -14,8 +14,6 @@
 
 """This script is used to synthesize generated parts of this library."""
 
-import os
-
 import synthtool as s
 from synthtool import gcp
 
@@ -63,8 +61,6 @@
 # Add templated files
 # ----------------------------------------------------------------------------
 templated_files = common.py_library(cov_level=100)
-# we do not want to override the custom noxfile with the generated one
-os.remove(os.path.join(templated_files, "noxfile.py"))
-s.move(templated_files)
+s.move(templated_files, excludes=["noxfile.py"])
 
 s.shell.run(["nox", "-s", "blacken"], hide_output=False)


Test patch:
Repository: googleapis/python-bigquery

Issue:
Testing: drop majyk coverage number: `--cov-fail-under=97`



Discussion:

Resolving patch:
diff --git a/noxfile.py b/noxfile.py
--- a/noxfile.py
+++ b/noxfile.py
@@ -36,14 +36,10 @@ def default(session):
     session.install("grpcio")
     session.install("-e", "test_utils")
 
-    coverage_fail_under = "--cov-fail-under=97"
-
     # fastparquet is not included in .[all] because, in general, it's redundant
     # with pyarrow. We still want to run some unit tests with fastparquet
     # serialization, though.
-    dev_install = ".[all,fastparquet]"
-
-    session.install("-e", dev_install)
+    session.install("-e", ".[all,fastparquet]")
 
     # IPython does not support Python 2 after version 5.x
     if session.python == "2.7":
@@ -60,7 +56,7 @@ def default(session):
         "--cov-append",
         "--cov-config=.coveragerc",
         "--cov-report=",
-        coverage_fail_under,
+        "--cov-fail-under=0",
         os.path.join("tests", "unit"),
         *session.posargs,
     )


Test patch:
Repository: googleapis/python-bigquery

Issue:
BigQuery: test with all optional dependencies in Python 3.8
Blocked on:

- Apache Arrow: https://issues.apache.org/jira/browse/ARROW-6920
- fastparquet: https://github.com/dask/fastparquet/issues/468


Discussion:
Both blockers seem to have been resolved, I'll check if this has been closed.

Resolving patch:
diff --git a/noxfile.py b/noxfile.py
--- a/noxfile.py
+++ b/noxfile.py
@@ -43,14 +43,6 @@ def default(session):
     # serialization, though.
     dev_install = ".[all,fastparquet]"
 
-    # There is no pyarrow or fastparquet wheel for Python 3.8.
-    if session.python == "3.8":
-        # Since many tests are skipped due to missing dependencies, test
-        # coverage is much lower in Python 3.8. Remove once we can test with
-        # pyarrow.
-        coverage_fail_under = "--cov-fail-under=91"
-        dev_install = ".[pandas,tqdm]"
-
     session.install("-e", dev_install)
 
     # IPython does not support Python 2 after version 5.x
@@ -80,7 +72,7 @@ def unit(session):
     default(session)
 
 
-@nox.session(python=["2.7", "3.7"])
+@nox.session(python=["2.7", "3.8"])
 def system(session):
     """Run the system test suite."""
 
@@ -110,7 +102,7 @@ def system(session):
     )
 
 
-@nox.session(python=["2.7", "3.7"])
+@nox.session(python=["2.7", "3.8"])
 def snippets(session):
     """Run the snippets test suite."""
 
@@ -130,7 +122,7 @@ def snippets(session):
     session.run("py.test", "samples", *session.posargs)
 
 
-@nox.session(python="3.7")
+@nox.session(python="3.8")
 def cover(session):
     """Run the final coverage report.
 
@@ -142,7 +134,7 @@ def cover(session):
     session.run("coverage", "erase")
 
 
-@nox.session(python="3.7")
+@nox.session(python="3.8")
 def lint(session):
     """Run linters.
 
@@ -159,7 +151,7 @@ def lint(session):
     session.run("black", "--check", *BLACK_PATHS)
 
 
-@nox.session(python="3.7")
+@nox.session(python="3.8")
 def lint_setup_py(session):
     """Verify that setup.py is valid (including RST check)."""
 
@@ -180,7 +172,7 @@ def blacken(session):
     session.run("black", *BLACK_PATHS)
 
 
-@nox.session(python="3.7")
+@nox.session(python="3.8")
 def docs(session):
     """Build the docs."""
 
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -105,6 +105,7 @@
         "Programming Language :: Python :: 3.5",
         "Programming Language :: Python :: 3.6",
         "Programming Language :: Python :: 3.7",
+        "Programming Language :: Python :: 3.8",
         "Operating System :: OS Independent",
         "Topic :: Internet",
     ],


Test patch: