Skip to content

Commit a65aeff

Browse files
embe-pwManul from Pathway
authored and
Manul from Pathway
committed
pyupgrade (#5500)
GitOrigin-RevId: 8fe95b4df1a334695ad09f141784cc84c1bc1686
1 parent a97ef16 commit a65aeff

File tree

9 files changed

+18
-20
lines changed

9 files changed

+18
-20
lines changed

integration_tests/kafka/test_backfilling.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
def generate_wordcount_input(n_words, n_word_repetitions):
1717
input = []
1818
for word_idx in range(n_words):
19-
word = "word_{}".format(word_idx)
19+
word = f"word_{word_idx}"
2020
input += [word] * n_word_repetitions
2121
random.shuffle(input)
2222
return input
@@ -51,7 +51,7 @@ def topic_stats(self):
5151
total_incorrect_counts = 0
5252
expected_word_counts = self.expected_word_counts()
5353

54-
with open(self.output_file_path, "r") as f:
54+
with open(self.output_file_path) as f:
5555
for raw_entry in f.readlines():
5656
if not raw_entry:
5757
continue

integration_tests/s3/test_s3_interops.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,9 @@ def test_s3_backfilling(tmp_path: pathlib.Path):
209209

210210
def test_s3_json_read_and_recovery(tmp_path: pathlib.Path):
211211
pstorage_s3_path = (
212-
"integration_tests/test_s3_json_read_write_pstorage_full/{}".format(time.time())
212+
f"integration_tests/test_s3_json_read_write_pstorage_full/{time.time()}"
213213
)
214-
input_s3_path = "integration_tests/test_s3_json_read_write/{}".format(time.time())
214+
input_s3_path = f"integration_tests/test_s3_json_read_write/{time.time()}"
215215
output_path = tmp_path / "output.json"
216216

217217
def run_pw_program():
@@ -356,7 +356,7 @@ def test_s3_alternative_path(tmp_path: pathlib.Path):
356356
write_lines(model_output_path, input_contents)
357357

358358
table = pw.io.s3_csv.read(
359-
"s3://aws-integrationtest/{}".format(input_s3_path),
359+
f"s3://aws-integrationtest/{input_s3_path}",
360360
aws_s3_settings=pw.io.s3_csv.AwsS3Settings(
361361
access_key="AKIAX67C7K343BP4QUWN",
362362
secret_access_key=os.environ["AWS_S3_SECRET_ACCESS_KEY"],
@@ -384,7 +384,7 @@ def test_s3_wrong_path(tmp_path: pathlib.Path):
384384
output_path = tmp_path / "output.csv"
385385

386386
table = pw.io.s3_csv.read(
387-
"s3://aws-integrationtest/{}".format(input_s3_path),
387+
f"s3://aws-integrationtest/{input_s3_path}",
388388
aws_s3_settings=pw.io.s3_csv.AwsS3Settings(
389389
access_key="AKIAX67C7K343BP4QUWN",
390390
secret_access_key=os.environ["AWS_S3_SECRET_ACCESS_KEY"],
@@ -414,7 +414,7 @@ def test_s3_creds_from_profiles(tmp_path: pathlib.Path):
414414
write_lines(model_output_path, input_contents)
415415

416416
table = pw.io.s3_csv.read(
417-
"s3://aws-integrationtest/{}".format(input_s3_path),
417+
f"s3://aws-integrationtest/{input_s3_path}",
418418
aws_s3_settings=pw.io.s3_csv.AwsS3Settings(region="eu-central-1"),
419419
value_columns=["key", "value"],
420420
mode="static",
@@ -448,7 +448,7 @@ class InputSchema(pw.Schema):
448448
value: str
449449

450450
table = pw.io.s3.read(
451-
"s3://aws-integrationtest/{}".format(input_s3_path),
451+
f"s3://aws-integrationtest/{input_s3_path}",
452452
format="csv",
453453
schema=InputSchema,
454454
mode="static",

integration_tests/webserver/test_rest_connector.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ def uppercase_logic(queries: pw.Table) -> pw.Table:
327327
continue
328328

329329
schema = response.json()
330-
assert schema["paths"].keys() == set(["/uppercase"])
330+
assert schema["paths"].keys() == {"/uppercase"}
331331
succeeded = True
332332
break
333333

integration_tests/wordcount/pw_wordcount.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@
3838
snapshot_interval_ms=5000,
3939
)
4040
else:
41-
raise ValueError(
42-
"Unknown persistent storage type: {}".format(args.pstorage_type)
43-
)
41+
raise ValueError(f"Unknown persistent storage type: {args.pstorage_type}")
4442

4543
class InputSchema(pw.Schema):
4644
word: str

python/pathway/internals/column.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
from __future__ import annotations
44

55
from abc import ABC, abstractmethod
6-
from collections.abc import Iterable
6+
from collections.abc import Callable, Iterable
77
from dataclasses import dataclass
88
from functools import cached_property
99
from itertools import chain
1010
from types import EllipsisType
11-
from typing import TYPE_CHECKING, Any, Callable, ClassVar
11+
from typing import TYPE_CHECKING, Any, ClassVar
1212

1313
import pathway.internals as pw
1414
from pathway.internals import column_properties as cp, dtype as dt, trace

python/pathway/internals/table.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
import functools
66
import warnings
7-
from collections.abc import Mapping
8-
from typing import TYPE_CHECKING, Any, Callable, Generic, TypeVar, cast, overload
7+
from collections.abc import Callable, Mapping
8+
from typing import TYPE_CHECKING, Any, Generic, TypeVar, cast, overload
99

1010
import pathway.internals.column as clmn
1111
import pathway.internals.expression as expr

python/pathway/tests/test_graphs.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1294,7 +1294,7 @@ def test_clustering_quality():
12941294
mod_from_external_lib_as_number = community.modularity(tmp, modified_graph)
12951295

12961296
def compare_mod(mod):
1297-
return f"{mod:.14f}" == "{:.14f}".format(mod_from_external_lib_as_number)
1297+
return f"{mod:.14f}" == f"{mod_from_external_lib_as_number:.14f}"
12981298

12991299
external_mod = exact_modularity(
13001300
WeightedGraph.from_vertices_and_weighted_edges(vertices, doubled_edges), vc

python/pathway/tests/test_openapi_schema_generation.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class InputSchema(pw.Schema):
9191
description = webserver.openapi_description_json
9292
openapi_spec_validator.validate(description)
9393

94-
assert description["paths"].keys() == set(["/one", "/two"])
94+
assert description["paths"].keys() == {"/one", "/two"}
9595

9696

9797
def test_raw_input_format():

python/pathway/tests/utils.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -501,9 +501,9 @@ def warns_here(
501501
first_line = frame.f_lineno
502502
del frame
503503
file_name = code.co_filename
504-
function_lines = set(
504+
function_lines = {
505505
line for (_start, _end, line) in code.co_lines() if line is not None
506-
)
506+
}
507507
del code
508508

509509
with pytest.warns(expected_warning, match=match) as context:

0 commit comments

Comments
 (0)