We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Invalid f-string in _warnings
### Description:

```
f4978b1149 skimage/_shared/_warnings.py (Jarrod Millman       2022-10-11 17:14:49 -0700 145)             msg = f"No warning raised matching:\n{{'\n'.join(remaining)}}"
c0a0490eed skimage/_shared/_warnings.py (Steven Silvester     2014-12-23 10:59:47 -0600 146)             raise ValueError(msg)
```

That f-string cannot render correctly.



--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `skimage/_shared/_warnings.py`
Content:
```
1 from contextlib import contextmanager
2 import sys
3 import warnings
4 import re
5 import functools
6 import os
7 
8 __all__ = ['all_warnings', 'expected_warnings', 'warn']
9 
10 
11 # A version of `warnings.warn` with a default stacklevel of 2.
12 # functool is used so as not to increase the call stack accidentally
13 warn = functools.partial(warnings.warn, stacklevel=2)
14 
15 
16 @contextmanager
17 def all_warnings():
18     """
19     Context for use in testing to ensure that all warnings are raised.
20 
21     Examples
22     --------
23     >>> import warnings
24     >>> def foo():
25     ...     warnings.warn(RuntimeWarning("bar"), stacklevel=2)
26 
27     We raise the warning once, while the warning filter is set to "once".
28     Hereafter, the warning is invisible, even with custom filters:
29 
30     >>> with warnings.catch_warnings():
31     ...     warnings.simplefilter('once')
32     ...     foo()                         # doctest: +SKIP
33 
34     We can now run ``foo()`` without a warning being raised:
35 
36     >>> from numpy.testing import assert_warns
37     >>> foo()                             # doctest: +SKIP
38 
39     To catch the warning, we call in the help of ``all_warnings``:
40 
41     >>> with all_warnings():
42     ...     assert_warns(RuntimeWarning, foo)
43     """
44     # _warnings.py is on the critical import path.
45     # Since this is a testing only function, we lazy import inspect.
46     import inspect
47     # Whenever a warning is triggered, Python adds a __warningregistry__
48     # member to the *calling* module.  The exercise here is to find
49     # and eradicate all those breadcrumbs that were left lying around.
50     #
51     # We proceed by first searching all parent calling frames and explicitly
52     # clearing their warning registries (necessary for the doctests above to
53     # pass).  Then, we search for all submodules of skimage and clear theirs
54     # as well (necessary for the skimage test suite to pass).
55 
56     frame = inspect.currentframe()
57     if frame:
58         for f in inspect.getouterframes(frame):
59             f[0].f_locals['__warningregistry__'] = {}
60     del frame
61 
62     for mod_name, mod in list(sys.modules.items()):
63         try:
64             mod.__warningregistry__.clear()
65         except AttributeError:
66             pass
67 
68     with warnings.catch_warnings(record=True) as w:
69         warnings.simplefilter("always")
70         yield w
71 
72 
73 @contextmanager
74 def expected_warnings(matching):
75     r"""Context for use in testing to catch known warnings matching regexes
76 
77     Parameters
78     ----------
79     matching : None or a list of strings or compiled regexes
80         Regexes for the desired warning to catch
81         If matching is None, this behaves as a no-op.
82 
83     Examples
84     --------
85     >>> import numpy as np
86     >>> rng = np.random.default_rng()
87     >>> image = rng.integers(0, 2**16, size=(100, 100), dtype=np.uint16)
88     >>> # rank filters are slow when bit-depth exceeds 10 bits
89     >>> from skimage import filters
90     >>> with expected_warnings(['Bad rank filter performance']):
91     ...     median_filtered = filters.rank.median(image)
92 
93     Notes
94     -----
95     Uses `all_warnings` to ensure all warnings are raised.
96     Upon exiting, it checks the recorded warnings for the desired matching
97     pattern(s).
98     Raises a ValueError if any match was not found or an unexpected
99     warning was raised.
100     Allows for three types of behaviors: `and`, `or`, and `optional` matches.
101     This is done to accommodate different build environments or loop conditions
102     that may produce different warnings.  The behaviors can be combined.
103     If you pass multiple patterns, you get an orderless `and`, where all of the
104     warnings must be raised.
105     If you use the `|` operator in a pattern, you can catch one of several
106     warnings.
107     Finally, you can use `|\A\Z` in a pattern to signify it as optional.
108 
109     """
110     if isinstance(matching, str):
111         raise ValueError('``matching`` should be a list of strings and not '
112                          'a string itself.')
113 
114     # Special case for disabling the context manager
115     if matching is None:
116         yield None
117         return
118 
119     strict_warnings = os.environ.get('SKIMAGE_TEST_STRICT_WARNINGS', '1')
120     if strict_warnings.lower() == 'true':
121         strict_warnings = True
122     elif strict_warnings.lower() == 'false':
123         strict_warnings = False
124     else:
125         strict_warnings = bool(int(strict_warnings))
126 
127     with all_warnings() as w:
128         # enter context
129         yield w
130         # exited user context, check the recorded warnings
131         # Allow users to provide None
132         while None in matching:
133             matching.remove(None)
134         remaining = [m for m in matching if r'\A\Z' not in m.split('|')]
135         for warn in w:
136             found = False
137             for match in matching:
138                 if re.search(match, str(warn.message)) is not None:
139                     found = True
140                     if match in remaining:
141                         remaining.remove(match)
142             if strict_warnings and not found:
143                 raise ValueError(f'Unexpected warning: {str(warn.message)}')
144         if strict_warnings and (len(remaining) > 0):
145             msg = f"No warning raised matching:\n{{'\n'.join(remaining)}}"
146             raise ValueError(msg)
147
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/skimage/_shared/_warnings.py b/skimage/_shared/_warnings.py
--- a/skimage/_shared/_warnings.py
+++ b/skimage/_shared/_warnings.py
@@ -142,5 +142,6 @@
             if strict_warnings and not found:
                 raise ValueError(f'Unexpected warning: {str(warn.message)}')
         if strict_warnings and (len(remaining) > 0):
-            msg = f"No warning raised matching:\n{{'\n'.join(remaining)}}"
+            newline = "\n"
+            msg = f"No warning raised matching:{newline}{newline.join(remaining)}"
             raise ValueError(msg)

{"golden_diff": "diff --git a/skimage/_shared/_warnings.py b/skimage/_shared/_warnings.py\n--- a/skimage/_shared/_warnings.py\n+++ b/skimage/_shared/_warnings.py\n@@ -142,5 +142,6 @@\n             if strict_warnings and not found:\n                 raise ValueError(f'Unexpected warning: {str(warn.message)}')\n         if strict_warnings and (len(remaining) > 0):\n-            msg = f\"No warning raised matching:\\n{{'\\n'.join(remaining)}}\"\n+            newline = \"\\n\"\n+            msg = f\"No warning raised matching:{newline}{newline.join(remaining)}\"\n             raise ValueError(msg)\n", "issue": "Invalid f-string in _warnings\n### Description:\r\n\r\n```\r\nf4978b1149 skimage/_shared/_warnings.py (Jarrod Millman       2022-10-11 17:14:49 -0700 145)             msg = f\"No warning raised matching:\\n{{'\\n'.join(remaining)}}\"\r\nc0a0490eed skimage/_shared/_warnings.py (Steven Silvester     2014-12-23 10:59:47 -0600 146)             raise ValueError(msg)\r\n```\r\n\r\nThat f-string cannot render correctly.\r\n\r\n\n", "before_files": [{"content": "from contextlib import contextmanager\nimport sys\nimport warnings\nimport re\nimport functools\nimport os\n\n__all__ = ['all_warnings', 'expected_warnings', 'warn']\n\n\n# A version of `warnings.warn` with a default stacklevel of 2.\n# functool is used so as not to increase the call stack accidentally\nwarn = functools.partial(warnings.warn, stacklevel=2)\n\n\n@contextmanager\ndef all_warnings():\n    \"\"\"\n    Context for use in testing to ensure that all warnings are raised.\n\n    Examples\n    --------\n    >>> import warnings\n    >>> def foo():\n    ...     warnings.warn(RuntimeWarning(\"bar\"), stacklevel=2)\n\n    We raise the warning once, while the warning filter is set to \"once\".\n    Hereafter, the warning is invisible, even with custom filters:\n\n    >>> with warnings.catch_warnings():\n    ...     warnings.simplefilter('once')\n    ...     foo()                         # doctest: +SKIP\n\n    We can now run ``foo()`` without a warning being raised:\n\n    >>> from numpy.testing import assert_warns\n    >>> foo()                             # doctest: +SKIP\n\n    To catch the warning, we call in the help of ``all_warnings``:\n\n    >>> with all_warnings():\n    ...     assert_warns(RuntimeWarning, foo)\n    \"\"\"\n    # _warnings.py is on the critical import path.\n    # Since this is a testing only function, we lazy import inspect.\n    import inspect\n    # Whenever a warning is triggered, Python adds a __warningregistry__\n    # member to the *calling* module.  The exercise here is to find\n    # and eradicate all those breadcrumbs that were left lying around.\n    #\n    # We proceed by first searching all parent calling frames and explicitly\n    # clearing their warning registries (necessary for the doctests above to\n    # pass).  Then, we search for all submodules of skimage and clear theirs\n    # as well (necessary for the skimage test suite to pass).\n\n    frame = inspect.currentframe()\n    if frame:\n        for f in inspect.getouterframes(frame):\n            f[0].f_locals['__warningregistry__'] = {}\n    del frame\n\n    for mod_name, mod in list(sys.modules.items()):\n        try:\n            mod.__warningregistry__.clear()\n        except AttributeError:\n            pass\n\n    with warnings.catch_warnings(record=True) as w:\n        warnings.simplefilter(\"always\")\n        yield w\n\n\n@contextmanager\ndef expected_warnings(matching):\n    r\"\"\"Context for use in testing to catch known warnings matching regexes\n\n    Parameters\n    ----------\n    matching : None or a list of strings or compiled regexes\n        Regexes for the desired warning to catch\n        If matching is None, this behaves as a no-op.\n\n    Examples\n    --------\n    >>> import numpy as np\n    >>> rng = np.random.default_rng()\n    >>> image = rng.integers(0, 2**16, size=(100, 100), dtype=np.uint16)\n    >>> # rank filters are slow when bit-depth exceeds 10 bits\n    >>> from skimage import filters\n    >>> with expected_warnings(['Bad rank filter performance']):\n    ...     median_filtered = filters.rank.median(image)\n\n    Notes\n    -----\n    Uses `all_warnings` to ensure all warnings are raised.\n    Upon exiting, it checks the recorded warnings for the desired matching\n    pattern(s).\n    Raises a ValueError if any match was not found or an unexpected\n    warning was raised.\n    Allows for three types of behaviors: `and`, `or`, and `optional` matches.\n    This is done to accommodate different build environments or loop conditions\n    that may produce different warnings.  The behaviors can be combined.\n    If you pass multiple patterns, you get an orderless `and`, where all of the\n    warnings must be raised.\n    If you use the `|` operator in a pattern, you can catch one of several\n    warnings.\n    Finally, you can use `|\\A\\Z` in a pattern to signify it as optional.\n\n    \"\"\"\n    if isinstance(matching, str):\n        raise ValueError('``matching`` should be a list of strings and not '\n                         'a string itself.')\n\n    # Special case for disabling the context manager\n    if matching is None:\n        yield None\n        return\n\n    strict_warnings = os.environ.get('SKIMAGE_TEST_STRICT_WARNINGS', '1')\n    if strict_warnings.lower() == 'true':\n        strict_warnings = True\n    elif strict_warnings.lower() == 'false':\n        strict_warnings = False\n    else:\n        strict_warnings = bool(int(strict_warnings))\n\n    with all_warnings() as w:\n        # enter context\n        yield w\n        # exited user context, check the recorded warnings\n        # Allow users to provide None\n        while None in matching:\n            matching.remove(None)\n        remaining = [m for m in matching if r'\\A\\Z' not in m.split('|')]\n        for warn in w:\n            found = False\n            for match in matching:\n                if re.search(match, str(warn.message)) is not None:\n                    found = True\n                    if match in remaining:\n                        remaining.remove(match)\n            if strict_warnings and not found:\n                raise ValueError(f'Unexpected warning: {str(warn.message)}')\n        if strict_warnings and (len(remaining) > 0):\n            msg = f\"No warning raised matching:\\n{{'\\n'.join(remaining)}}\"\n            raise ValueError(msg)\n", "path": "skimage/_shared/_warnings.py"}], "after_files": [{"content": "from contextlib import contextmanager\nimport sys\nimport warnings\nimport re\nimport functools\nimport os\n\n__all__ = ['all_warnings', 'expected_warnings', 'warn']\n\n\n# A version of `warnings.warn` with a default stacklevel of 2.\n# functool is used so as not to increase the call stack accidentally\nwarn = functools.partial(warnings.warn, stacklevel=2)\n\n\n@contextmanager\ndef all_warnings():\n    \"\"\"\n    Context for use in testing to ensure that all warnings are raised.\n\n    Examples\n    --------\n    >>> import warnings\n    >>> def foo():\n    ...     warnings.warn(RuntimeWarning(\"bar\"), stacklevel=2)\n\n    We raise the warning once, while the warning filter is set to \"once\".\n    Hereafter, the warning is invisible, even with custom filters:\n\n    >>> with warnings.catch_warnings():\n    ...     warnings.simplefilter('once')\n    ...     foo()                         # doctest: +SKIP\n\n    We can now run ``foo()`` without a warning being raised:\n\n    >>> from numpy.testing import assert_warns\n    >>> foo()                             # doctest: +SKIP\n\n    To catch the warning, we call in the help of ``all_warnings``:\n\n    >>> with all_warnings():\n    ...     assert_warns(RuntimeWarning, foo)\n    \"\"\"\n    # _warnings.py is on the critical import path.\n    # Since this is a testing only function, we lazy import inspect.\n    import inspect\n    # Whenever a warning is triggered, Python adds a __warningregistry__\n    # member to the *calling* module.  The exercise here is to find\n    # and eradicate all those breadcrumbs that were left lying around.\n    #\n    # We proceed by first searching all parent calling frames and explicitly\n    # clearing their warning registries (necessary for the doctests above to\n    # pass).  Then, we search for all submodules of skimage and clear theirs\n    # as well (necessary for the skimage test suite to pass).\n\n    frame = inspect.currentframe()\n    if frame:\n        for f in inspect.getouterframes(frame):\n            f[0].f_locals['__warningregistry__'] = {}\n    del frame\n\n    for mod_name, mod in list(sys.modules.items()):\n        try:\n            mod.__warningregistry__.clear()\n        except AttributeError:\n            pass\n\n    with warnings.catch_warnings(record=True) as w:\n        warnings.simplefilter(\"always\")\n        yield w\n\n\n@contextmanager\ndef expected_warnings(matching):\n    r\"\"\"Context for use in testing to catch known warnings matching regexes\n\n    Parameters\n    ----------\n    matching : None or a list of strings or compiled regexes\n        Regexes for the desired warning to catch\n        If matching is None, this behaves as a no-op.\n\n    Examples\n    --------\n    >>> import numpy as np\n    >>> rng = np.random.default_rng()\n    >>> image = rng.integers(0, 2**16, size=(100, 100), dtype=np.uint16)\n    >>> # rank filters are slow when bit-depth exceeds 10 bits\n    >>> from skimage import filters\n    >>> with expected_warnings(['Bad rank filter performance']):\n    ...     median_filtered = filters.rank.median(image)\n\n    Notes\n    -----\n    Uses `all_warnings` to ensure all warnings are raised.\n    Upon exiting, it checks the recorded warnings for the desired matching\n    pattern(s).\n    Raises a ValueError if any match was not found or an unexpected\n    warning was raised.\n    Allows for three types of behaviors: `and`, `or`, and `optional` matches.\n    This is done to accommodate different build environments or loop conditions\n    that may produce different warnings.  The behaviors can be combined.\n    If you pass multiple patterns, you get an orderless `and`, where all of the\n    warnings must be raised.\n    If you use the `|` operator in a pattern, you can catch one of several\n    warnings.\n    Finally, you can use `|\\A\\Z` in a pattern to signify it as optional.\n\n    \"\"\"\n    if isinstance(matching, str):\n        raise ValueError('``matching`` should be a list of strings and not '\n                         'a string itself.')\n\n    # Special case for disabling the context manager\n    if matching is None:\n        yield None\n        return\n\n    strict_warnings = os.environ.get('SKIMAGE_TEST_STRICT_WARNINGS', '1')\n    if strict_warnings.lower() == 'true':\n        strict_warnings = True\n    elif strict_warnings.lower() == 'false':\n        strict_warnings = False\n    else:\n        strict_warnings = bool(int(strict_warnings))\n\n    with all_warnings() as w:\n        # enter context\n        yield w\n        # exited user context, check the recorded warnings\n        # Allow users to provide None\n        while None in matching:\n            matching.remove(None)\n        remaining = [m for m in matching if r'\\A\\Z' not in m.split('|')]\n        for warn in w:\n            found = False\n            for match in matching:\n                if re.search(match, str(warn.message)) is not None:\n                    found = True\n                    if match in remaining:\n                        remaining.remove(match)\n            if strict_warnings and not found:\n                raise ValueError(f'Unexpected warning: {str(warn.message)}')\n        if strict_warnings and (len(remaining) > 0):\n            newline = \"\\n\"\n            msg = f\"No warning raised matching:{newline}{newline.join(remaining)}\"\n            raise ValueError(msg)\n", "path": "skimage/_shared/_warnings.py"}]}