Skip to content

Commit fe9e893

Browse files
committed
lint
1 parent 46a232e commit fe9e893

File tree

8 files changed

+63
-38
lines changed

8 files changed

+63
-38
lines changed

scripts/slack_digest.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,9 @@ class CategoryRule:
128128
name="Python SDK",
129129
column_header="Py",
130130
emoji="🐍",
131-
matcher=lambda path: path.startswith("weave/")
132-
and not path.startswith("weave/trace_server/"),
131+
matcher=lambda path: (
132+
path.startswith("weave/") and not path.startswith("weave/trace_server/")
133+
),
133134
),
134135
]
135136

tests/trace/data_serialization/test_cases/media_cases.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,10 @@ def markdown_equality_check(a, b):
202202
"exp_content": b'import weave\nfrom typing import Any\nfrom rich.markdown import Markdown\n\n@weave.op\ndef load(artifact: "MemTraceFilesArtifact", name: str, val: Any) -> Markdown:\n """Load markdown from file and metadata."""\n if "markup" in val:\n markup = val["markup"]\n else:\n with artifact.open("markup.md", binary=False) as f:\n markup = f.read()\n\n kwargs = {}\n if val and isinstance(val, dict) and "code_theme" in val:\n kwargs["code_theme"] = val["code_theme"]\n\n return Markdown(markup=markup, **kwargs)\n',
203203
},
204204
],
205-
equality_check=lambda a, b: markdown_equality_check(a["inline"], b["inline"])
206-
and markdown_equality_check(a["file"], b["file"]),
205+
equality_check=lambda a, b: (
206+
markdown_equality_check(a["inline"], b["inline"])
207+
and markdown_equality_check(a["file"], b["file"])
208+
),
207209
python_version_code_capture=(3, 13),
208210
),
209211
# Video
@@ -239,8 +241,9 @@ def markdown_equality_check(a, b):
239241
"exp_content": VIDEO_BYTES,
240242
},
241243
],
242-
equality_check=lambda a, b: a.duration
243-
== b.duration, # could do better, but this is a good start
244+
equality_check=lambda a, b: (
245+
a.duration == b.duration
246+
), # could do better, but this is a good start
244247
python_version_code_capture=(3, 13),
245248
),
246249
# Content
@@ -463,8 +466,9 @@ def markdown_equality_check(a, b):
463466
"exp_content": VIDEO_BYTES,
464467
},
465468
],
466-
equality_check=lambda a, b: a.duration
467-
== b.duration, # could do better, but this is a good start
469+
equality_check=lambda a, b: (
470+
a.duration == b.duration
471+
), # could do better, but this is a good start
468472
python_version_code_capture=(3, 13),
469473
),
470474
SerializationTestCase(

tests/trace_server/test_clickhouse_trace_server_migrator.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,11 @@ def test_create_distributed_table_sql_id_sharded():
393393
Mock(), replicated_cluster="test_cluster", migration_dir=DEFAULT_MIGRATION_DIR
394394
)
395395
sql = distributed_migrator._create_distributed_table_sql("calls_complete")
396-
expected = "CREATE TABLE IF NOT EXISTS calls_complete ON CLUSTER test_cluster\n AS calls_complete_local\n ENGINE = Distributed(test_cluster, currentDatabase(), calls_complete_local, sipHash64(id))"
396+
expected = """
397+
CREATE TABLE IF NOT EXISTS calls_complete ON CLUSTER test_cluster
398+
AS calls_complete_local
399+
ENGINE = Distributed(test_cluster, currentDatabase(), calls_complete_local, sipHash64(id))
400+
"""
397401
assert sql.strip() == expected.strip()
398402

399403

weave/integrations/huggingface/huggingface_inference_client_sdk.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,9 @@ def wrapper(fn: Callable) -> Callable:
8383
return _add_accumulator(
8484
op, # type: ignore
8585
make_accumulator=lambda inputs: huggingface_accumulator,
86-
should_accumulate=lambda inputs: isinstance(inputs, dict)
87-
and bool(inputs.get("stream")),
86+
should_accumulate=lambda inputs: (
87+
isinstance(inputs, dict) and bool(inputs.get("stream"))
88+
),
8889
)
8990

9091
return wrapper
@@ -107,8 +108,9 @@ async def _async_wrapper(*args: Any, **kwargs: Any) -> Any:
107108
return _add_accumulator(
108109
op, # type: ignore
109110
make_accumulator=lambda inputs: huggingface_accumulator,
110-
should_accumulate=lambda inputs: isinstance(inputs, dict)
111-
and bool(inputs.get("stream")),
111+
should_accumulate=lambda inputs: (
112+
isinstance(inputs, dict) and bool(inputs.get("stream"))
113+
),
112114
)
113115

114116
return wrapper

weave/integrations/openai/openai_sdk.py

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -415,11 +415,13 @@ def _openai_stream_options_is_set(inputs: dict) -> bool:
415415
op._set_on_input_handler(openai_on_input_handler)
416416
return _add_accumulator(
417417
op, # type: ignore
418-
make_accumulator=lambda inputs: lambda acc, value: openai_accumulator(
419-
acc,
420-
value,
421-
skip_last=not _openai_stream_options_is_set(inputs),
422-
stream_start_time=inputs.get(WEAVE_STREAM_START_TIME),
418+
make_accumulator=lambda inputs: (
419+
lambda acc, value: openai_accumulator(
420+
acc,
421+
value,
422+
skip_last=not _openai_stream_options_is_set(inputs),
423+
stream_start_time=inputs.get(WEAVE_STREAM_START_TIME),
424+
)
423425
),
424426
should_accumulate=should_use_accumulator,
425427
on_finish_post_processor=openai_on_finish_post_processor,
@@ -459,11 +461,13 @@ def _openai_stream_options_is_set(inputs: dict) -> bool:
459461
op._set_on_input_handler(openai_on_input_handler)
460462
return _add_accumulator(
461463
op, # type: ignore
462-
make_accumulator=lambda inputs: lambda acc, value: openai_accumulator(
463-
acc,
464-
value,
465-
skip_last=not _openai_stream_options_is_set(inputs),
466-
stream_start_time=inputs.get(WEAVE_STREAM_START_TIME),
464+
make_accumulator=lambda inputs: (
465+
lambda acc, value: openai_accumulator(
466+
acc,
467+
value,
468+
skip_last=not _openai_stream_options_is_set(inputs),
469+
stream_start_time=inputs.get(WEAVE_STREAM_START_TIME),
470+
)
467471
),
468472
should_accumulate=should_use_accumulator,
469473
on_finish_post_processor=openai_on_finish_post_processor,
@@ -691,8 +695,8 @@ def _inner(*args: Any, **kwargs: Any) -> Any:
691695
op._set_on_input_handler(openai_on_input_handler)
692696
return _add_accumulator(
693697
op, # type: ignore
694-
make_accumulator=lambda inputs: lambda acc, value: responses_accumulator(
695-
acc, value
698+
make_accumulator=lambda inputs: (
699+
lambda acc, value: responses_accumulator(acc, value)
696700
),
697701
should_accumulate=should_use_responses_accumulator,
698702
on_finish_post_processor=responses_on_finish_post_processor,
@@ -715,8 +719,8 @@ async def _inner(*args: Any, **kwargs: Any) -> Any:
715719
op._set_on_input_handler(openai_on_input_handler)
716720
return _add_accumulator(
717721
op, # type: ignore
718-
make_accumulator=lambda inputs: lambda acc, value: responses_accumulator(
719-
acc, value
722+
make_accumulator=lambda inputs: (
723+
lambda acc, value: responses_accumulator(acc, value)
720724
),
721725
should_accumulate=should_use_responses_accumulator,
722726
on_finish_post_processor=responses_on_finish_post_processor,

weave/integrations/openai_realtime/openai_realtime_websocket_patcher.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,9 @@ async def wrapper(*args: Any, **kwargs: Any) -> Any:
180180
make_new_value=make_new_async_value,
181181
),
182182
SymbolPatcher(
183-
get_base_symbol=lambda: importlib.import_module(
184-
"aiohttp"
185-
).ClientSession,
183+
get_base_symbol=lambda: (
184+
importlib.import_module("aiohttp").ClientSession
185+
),
186186
attribute_name="ws_connect",
187187
make_new_value=make_aiohttp_ws_connect,
188188
),

weave/integrations/vertexai/vertexai_sdk.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,9 @@ def wrapper(fn: Callable) -> Callable:
9999
return _add_accumulator(
100100
op, # type: ignore
101101
make_accumulator=lambda inputs: vertexai_accumulator,
102-
should_accumulate=lambda inputs: isinstance(inputs, dict)
103-
and bool(inputs.get("stream")),
102+
should_accumulate=lambda inputs: (
103+
isinstance(inputs, dict) and bool(inputs.get("stream"))
104+
),
104105
)
105106

106107
return wrapper
@@ -124,8 +125,9 @@ async def _async_wrapper(*args: Any, **kwargs: Any) -> Any:
124125
return _add_accumulator(
125126
op, # type: ignore
126127
make_accumulator=lambda inputs: vertexai_accumulator,
127-
should_accumulate=lambda inputs: isinstance(inputs, dict)
128-
and bool(inputs.get("stream")),
128+
should_accumulate=lambda inputs: (
129+
isinstance(inputs, dict) and bool(inputs.get("stream"))
130+
),
129131
)
130132

131133
return wrapper

weave/trace_server/clickhouse_trace_server_migrator.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -516,28 +516,36 @@ def _add_on_cluster_clause(self, sql_query: str) -> str:
516516
# ALTER TABLE
517517
if SQLPatterns.ALTER_TABLE_STMT.search(sql_query):
518518
return SQLPatterns.ALTER_TABLE_NAME_PATTERN.sub(
519-
lambda m: f"{m.group(1)}{m.group(2)} ON CLUSTER {self.replicated_cluster}{m.group(3)}",
519+
lambda m: (
520+
f"{m.group(1)}{m.group(2)} ON CLUSTER {self.replicated_cluster}{m.group(3)}"
521+
),
520522
sql_query,
521523
)
522524

523525
# CREATE TABLE
524526
if SQLPatterns.CREATE_TABLE_STMT.search(sql_query):
525527
return SQLPatterns.CREATE_TABLE_NAME_PATTERN.sub(
526-
lambda m: f"{m.group(1)}{m.group(2)} ON CLUSTER {self.replicated_cluster}{m.group(3)}",
528+
lambda m: (
529+
f"{m.group(1)}{m.group(2)} ON CLUSTER {self.replicated_cluster}{m.group(3)}"
530+
),
527531
sql_query,
528532
)
529533

530534
# DROP VIEW
531535
if SQLPatterns.DROP_VIEW_STMT.search(sql_query):
532536
return SQLPatterns.DROP_VIEW_NAME_PATTERN.sub(
533-
lambda m: f"{m.group(1)}{m.group(2)} ON CLUSTER {self.replicated_cluster}{m.group(3)}",
537+
lambda m: (
538+
f"{m.group(1)}{m.group(2)} ON CLUSTER {self.replicated_cluster}{m.group(3)}"
539+
),
534540
sql_query,
535541
)
536542

537543
# CREATE VIEW / CREATE MATERIALIZED VIEW
538544
if SQLPatterns.CREATE_VIEW_STMT.search(sql_query):
539545
return SQLPatterns.CREATE_VIEW_NAME_PATTERN.sub(
540-
lambda m: f"{m.group(1)}{m.group(2)} ON CLUSTER {self.replicated_cluster}{m.group(3)}",
546+
lambda m: (
547+
f"{m.group(1)}{m.group(2)} ON CLUSTER {self.replicated_cluster}{m.group(3)}"
548+
),
541549
sql_query,
542550
)
543551

0 commit comments

Comments
 (0)