Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jan 13, 2025
1 parent 068b8ea commit f59e580
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions solara/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def cli():
"--restart-dir",
"restart_dirs",
multiple=True,
help="Set restart directories explicitly, instead of using the current working" " directory.",
help="Set restart directories explicitly, instead of using the current working directory.",
type=click.Path(exists=True),
)
@click.option(
Expand All @@ -172,7 +172,7 @@ def cli():
"--workers",
default=None,
type=int,
help="Number of worker processes. Defaults to the $WEB_CONCURRENCY environment" " variable if available, or 1. Not valid with --auto-restart/-a.",
help="Number of worker processes. Defaults to the $WEB_CONCURRENCY environment variable if available, or 1. Not valid with --auto-restart/-a.",
)
@click.option(
"--env-file",
Expand Down
10 changes: 5 additions & 5 deletions solara/_stores.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def check_mutations(self):
code = tb.code_context[0]
else:
code = "<No code context available>"
msg += f"The last value was read in the following code:\n" f"{tb.filename}:{tb.lineno}\n" f"{code}"
msg += f"The last value was read in the following code:\n{tb.filename}:{tb.lineno}\n{code}"
raise ValueError(msg)
elif not isinstance(store_value.set_value, _SetValueNotSet) and not self.equals(store_value.set_value, store_value.private):
tb = store_value.set_traceback
Expand Down Expand Up @@ -120,7 +120,7 @@ def check_mutations(self):
code = tb.code_context[0]
else:
code = "<No code context available>"
msg += "The last time the value was set was at:\n" f"{tb.filename}:{tb.lineno}\n" f"{code}"
msg += f"The last time the value was set was at:\n{tb.filename}:{tb.lineno}\n{code}"
raise ValueError(msg)

def _ensure_public_exists(self):
Expand Down Expand Up @@ -164,7 +164,7 @@ def _check_equals(self, a: S, b: S):
code = tb.code_context[0]
else:
code = "<No code context available>"
warn += "This warning was triggered from:\n" f"{tb.filename}:{tb.lineno}\n" f"{code}"
warn += f"This warning was triggered from:\n{tb.filename}:{tb.lineno}\n{code}"
warnings.warn(warn)
self._enabled = False

Expand Down Expand Up @@ -239,7 +239,7 @@ def __init__(self, value: S, equals: Callable[[Any, Any], bool] = solara.util.eq
code = tb.code_context[0]
else:
code = "<No code context available>"
msg += "This warning was triggered from:\n" f"{tb.filename}:{tb.lineno}\n" f"{code}"
msg += f"This warning was triggered from:\n{tb.filename}:{tb.lineno}\n{code}"
warnings.warn(msg)
self._mutation_detection = False
super().__init__(equals=equals)
Expand All @@ -256,7 +256,7 @@ def _check_mutation(self):
code = tb.code_context[0].strip()
else:
code = "No code context available"
msg = f"Reactive variable was initialized at {tb.filename}:{tb.lineno} with {initial!r}, but was mutated to {current!r}.\n" f"{code}"
msg = f"Reactive variable was initialized at {tb.filename}:{tb.lineno} with {initial!r}, but was mutated to {current!r}.\n{code}"
else:
msg = f"Reactive variable was initialized with a value of {initial!r}, but was mutated to {current!r} (unable to report the location in the source code)."
raise ValueError(msg)
Expand Down
2 changes: 1 addition & 1 deletion solara/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def get_server_python_executable(silent: bool = False):
else:
python = pythons[0]
if not silent:
warnings.warn("Found multiple find servers:\n%s\n" "We are assuming the server is running under Python executable: %s" % (info, python))
warnings.warn("Found multiple find servers:\n%s\nWe are assuming the server is running under Python executable: %s" % (info, python))
else:
python = pythons[0]
return python
Expand Down
4 changes: 2 additions & 2 deletions solara/lab/components/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,12 @@ def ChatMessage(
.chat-message-{msg_uuid}.left{{
border-top-left-radius: 0;
background-color:var(--color);
{ "margin-left: 10px !important;" if notch else ""}
{"margin-left: 10px !important;" if notch else ""}
}}
.chat-message-{msg_uuid}.right{{
border-top-right-radius: 0;
background-color:var(--color);
{ "margin-right: 10px !important;" if notch else ""}
{"margin-right: 10px !important;" if notch else ""}
}}
{extra_styles}
"""
Expand Down
2 changes: 1 addition & 1 deletion solara/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ async def app_loop(
created_widgets_count = len(widgets_ids_after - widgets_ids)
close_widgets_count = len(widgets_ids - widgets_ids_after)
print( # noqa: T201
f"timing: total={t2-t0:.3f}s, deserialize={t1-t0:.3f}s, kernel={t2-t1:.3f}s"
f"timing: total={t2 - t0:.3f}s, deserialize={t1 - t0:.3f}s, kernel={t2 - t1:.3f}s"
f" widget: created: {created_widgets_count} closed: {close_widgets_count}"
)
finally:
Expand Down
10 changes: 5 additions & 5 deletions solara/server/starlette.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ async def root(request: Request, fullpath: str = ""):
forwarded_proto = request.headers.get("x-forwarded-proto")
host = request.headers.get("host")
if forwarded_proto and forwarded_proto != request.scope["scheme"]:
warnings.warn(f"""Header x-forwarded-proto={forwarded_proto!r} does not match scheme={request.scope['scheme']!r} as given by the asgi framework (probably uvicorn)
warnings.warn(f"""Header x-forwarded-proto={forwarded_proto!r} does not match scheme={request.scope["scheme"]!r} as given by the asgi framework (probably uvicorn)
This might be a configuration mismatch behind a reverse proxy and can cause issues with redirect urls, and auth.
Expand Down Expand Up @@ -439,10 +439,10 @@ async def root(request: Request, fullpath: str = ""):
See also https://solara.dev/documentation/getting_started/deploying/self-hosted
"""
if "script-name" in request.headers:
msg += f"""It looks like the reverse proxy sets the script-name header to {request.headers['script-name']!r}
msg += f"""It looks like the reverse proxy sets the script-name header to {request.headers["script-name"]!r}
"""
if "x-script-name" in request.headers:
msg += f"""It looks like the reverse proxy sets the x-script-name header to {request.headers['x-script-name']!r}
msg += f"""It looks like the reverse proxy sets the x-script-name header to {request.headers["x-script-name"]!r}
"""
if configured_root_path:
msg += f"""It looks like the root path was configured to {configured_root_path!r} in the settings
Expand Down Expand Up @@ -502,8 +502,8 @@ async def root(request: Request, fullpath: str = ""):
samesite = "none"
secure = True
elif request.base_url.hostname != "localhost":
warnings.warn(f"""Cookies with samesite=none require https, but according to the asgi framework, the scheme is {request.scope['scheme']!r}
and the x-forwarded-proto header is {request.headers.get('x-forwarded-proto', 'http')!r}. We will fallback to samesite=lax.
warnings.warn(f"""Cookies with samesite=none require https, but according to the asgi framework, the scheme is {request.scope["scheme"]!r}
and the x-forwarded-proto header is {request.headers.get("x-forwarded-proto", "http")!r}. We will fallback to samesite=lax.
If you embed solara in an iframe, make sure you forward the x-forwarded-proto header correctly so that the session cookie can be set.
Expand Down
2 changes: 1 addition & 1 deletion solara/test/pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def context_session(
if capture_screenshot:
for index, page in enumerate(pages):
human_readable_status = "failed" if failed else "finished"
screenshot_path = _build_artifact_test_folder(pytestconfig, request, f"test-{human_readable_status}-{index+1}.png")
screenshot_path = _build_artifact_test_folder(pytestconfig, request, f"test-{human_readable_status}-{index + 1}.png")
try:
page.screenshot(timeout=5000, path=screenshot_path)
except Error:
Expand Down
4 changes: 2 additions & 2 deletions solara/toestand.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ def __init__(self, default_value: S, key=None, equals: Callable[[Any, Any], bool
code = tb.code_context[0]
else:
code = "<No code context available>"
msg += "This warning was triggered from:\n" f"{tb.filename}:{tb.lineno}\n" f"{code}"
msg += f"This warning was triggered from:\n{tb.filename}:{tb.lineno}\n{code}"
warnings.warn(msg)
self._mutation_detection = False
cls = type(default_value)
Expand All @@ -425,7 +425,7 @@ def _check_mutation(self):
code = tb.code_context[0].strip()
else:
code = "No code context available"
msg = f"Reactive variable was initialized at {tb.filename}:{tb.lineno} with {initial!r}, but was mutated to {current!r}.\n" f"{code}"
msg = f"Reactive variable was initialized at {tb.filename}:{tb.lineno} with {initial!r}, but was mutated to {current!r}.\n{code}"
else:
msg = f"Reactive variable was initialized with a value of {initial!r}, but was mutated to {current!r} (unable to report the location in the source code)."
raise ValueError(msg)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def Page():
for pokemon in pokemons[:20]:
with solara.Div():
name = pokemon["name"]
url = f'{pokemon_base_url}/{pokemon["image"]}'
url = f"{pokemon_base_url}/{pokemon['image']}"
# TODO: how to do this with solara
rv.Img(src=url, contain=True, max_height="200px")
solara.Text(name)
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/pivottable_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def Test():
assert data["values_x"] == ["106", "171"]
assert data["values_y"] == ["158", "119"]
assert data["values"] == [["12", "94"], ["146", "25"]]
assert data["total"] == f"{len(df[df.pclass==2]):,}"
assert data["total"] == f"{len(df[df.pclass == 2]):,}"
set_filter(None)
# wait for the filter to be applied (data should change)
rc.find(PivotTableWidget).assert_wait(lambda w: w.d["values"] != [["12", "94"], ["146", "25"]], timeout=10)
Expand Down

0 comments on commit f59e580

Please sign in to comment.