Skip to content

Commit

Permalink
pyupgrade (#5500)
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 8fe95b4df1a334695ad09f141784cc84c1bc1686
  • Loading branch information
embe-pw authored and Manul from Pathway committed Jan 26, 2024
1 parent a97ef16 commit a65aeff
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 20 deletions.
4 changes: 2 additions & 2 deletions integration_tests/kafka/test_backfilling.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
def generate_wordcount_input(n_words, n_word_repetitions):
input = []
for word_idx in range(n_words):
word = "word_{}".format(word_idx)
word = f"word_{word_idx}"
input += [word] * n_word_repetitions
random.shuffle(input)
return input
Expand Down Expand Up @@ -51,7 +51,7 @@ def topic_stats(self):
total_incorrect_counts = 0
expected_word_counts = self.expected_word_counts()

with open(self.output_file_path, "r") as f:
with open(self.output_file_path) as f:
for raw_entry in f.readlines():
if not raw_entry:
continue
Expand Down
12 changes: 6 additions & 6 deletions integration_tests/s3/test_s3_interops.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,9 @@ def test_s3_backfilling(tmp_path: pathlib.Path):

def test_s3_json_read_and_recovery(tmp_path: pathlib.Path):
pstorage_s3_path = (
"integration_tests/test_s3_json_read_write_pstorage_full/{}".format(time.time())
f"integration_tests/test_s3_json_read_write_pstorage_full/{time.time()}"
)
input_s3_path = "integration_tests/test_s3_json_read_write/{}".format(time.time())
input_s3_path = f"integration_tests/test_s3_json_read_write/{time.time()}"
output_path = tmp_path / "output.json"

def run_pw_program():
Expand Down Expand Up @@ -356,7 +356,7 @@ def test_s3_alternative_path(tmp_path: pathlib.Path):
write_lines(model_output_path, input_contents)

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

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

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

table = pw.io.s3.read(
"s3://aws-integrationtest/{}".format(input_s3_path),
f"s3://aws-integrationtest/{input_s3_path}",
format="csv",
schema=InputSchema,
mode="static",
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/webserver/test_rest_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def uppercase_logic(queries: pw.Table) -> pw.Table:
continue

schema = response.json()
assert schema["paths"].keys() == set(["/uppercase"])
assert schema["paths"].keys() == {"/uppercase"}
succeeded = True
break

Expand Down
4 changes: 1 addition & 3 deletions integration_tests/wordcount/pw_wordcount.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@
snapshot_interval_ms=5000,
)
else:
raise ValueError(
"Unknown persistent storage type: {}".format(args.pstorage_type)
)
raise ValueError(f"Unknown persistent storage type: {args.pstorage_type}")

class InputSchema(pw.Schema):
word: str
Expand Down
4 changes: 2 additions & 2 deletions python/pathway/internals/column.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
from __future__ import annotations

from abc import ABC, abstractmethod
from collections.abc import Iterable
from collections.abc import Callable, Iterable
from dataclasses import dataclass
from functools import cached_property
from itertools import chain
from types import EllipsisType
from typing import TYPE_CHECKING, Any, Callable, ClassVar
from typing import TYPE_CHECKING, Any, ClassVar

import pathway.internals as pw
from pathway.internals import column_properties as cp, dtype as dt, trace
Expand Down
4 changes: 2 additions & 2 deletions python/pathway/internals/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import functools
import warnings
from collections.abc import Mapping
from typing import TYPE_CHECKING, Any, Callable, Generic, TypeVar, cast, overload
from collections.abc import Callable, Mapping
from typing import TYPE_CHECKING, Any, Generic, TypeVar, cast, overload

import pathway.internals.column as clmn
import pathway.internals.expression as expr
Expand Down
2 changes: 1 addition & 1 deletion python/pathway/tests/test_graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1294,7 +1294,7 @@ def test_clustering_quality():
mod_from_external_lib_as_number = community.modularity(tmp, modified_graph)

def compare_mod(mod):
return f"{mod:.14f}" == "{:.14f}".format(mod_from_external_lib_as_number)
return f"{mod:.14f}" == f"{mod_from_external_lib_as_number:.14f}"

external_mod = exact_modularity(
WeightedGraph.from_vertices_and_weighted_edges(vertices, doubled_edges), vc
Expand Down
2 changes: 1 addition & 1 deletion python/pathway/tests/test_openapi_schema_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class InputSchema(pw.Schema):
description = webserver.openapi_description_json
openapi_spec_validator.validate(description)

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


def test_raw_input_format():
Expand Down
4 changes: 2 additions & 2 deletions python/pathway/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,9 +501,9 @@ def warns_here(
first_line = frame.f_lineno
del frame
file_name = code.co_filename
function_lines = set(
function_lines = {
line for (_start, _end, line) in code.co_lines() if line is not None
)
}
del code

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

0 comments on commit a65aeff

Please sign in to comment.