Skip to content

Commit

Permalink
code style
Browse files Browse the repository at this point in the history
  • Loading branch information
Xun Cai committed Apr 22, 2024
1 parent efd3980 commit d00175a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 4 additions & 4 deletions pgtricks/pg_dump_splitsort.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def group(self, group1: str) -> str:

def split_sql_file( # noqa: C901 too complex
sql_filepath: str,
max_memory: int = 100 * 2 ** 20,
max_memory: int = 100 * 2**20,
) -> None:
"""Split a SQL file so that each COPY statement is in its own file."""
directory = os.path.dirname(sql_filepath)
Expand Down Expand Up @@ -125,10 +125,10 @@ def new_output(filename: str) -> IO[str]:


def main() -> None:
max_memory = 100 * 2 ** 20
max_memory = 100 * 2**20
if len(sys.argv) > 2:
max_memory = int(sys.argv[2]) * 2 ** 20
split_sql_file(sys.argv[1], max_memory)
max_memory = int(sys.argv[2]) * 2**20
split_sql_file(sys.argv[1], max_memory)


if __name__ == '__main__':
Expand Down
5 changes: 4 additions & 1 deletion pgtricks/tests/test_mergesort.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for the `pgtricks.mergesort` module."""

import functools
from types import GeneratorType
from typing import Iterable, cast
Expand Down Expand Up @@ -73,7 +74,9 @@ def test_mergesort_iterate_disk(tmpdir, lf):
@pytest.mark.parametrize("lf", ["\n", "\r\n"])
def test_mergesort_iterate_memory(tmpdir, lf):
"""Test iterating over the sorted lines when all lines fit in memory."""
m = MergeSort(directory=tmpdir, max_memory=1000000, key=functools.cmp_to_key(linecomp))
m = MergeSort(
directory=tmpdir, max_memory=1000000, key=functools.cmp_to_key(linecomp)
)
for value in [3, 1, 4, 1, 5, 9, 2, 10, 6, 5, 3, 8, 4]:
m.append(f"{value}{lf}")
assert next(m) == f"1{lf}"
Expand Down

0 comments on commit d00175a

Please sign in to comment.