From 8a440560d0dcab3780cd86122521f159d3ecad13 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 5 Dec 2022 22:26:11 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- septentrion/cli.py | 2 +- septentrion/configuration.py | 2 +- septentrion/db.py | 2 +- septentrion/files.py | 3 +-- septentrion/migration.py | 3 +-- septentrion/style.py | 2 +- tests/integration/test_runner.py | 4 ++-- tests/unit/test_configuration.py | 3 +-- 8 files changed, 9 insertions(+), 12 deletions(-) diff --git a/septentrion/cli.py b/septentrion/cli.py index 043510e..b86de92 100644 --- a/septentrion/cli.py +++ b/septentrion/cli.py @@ -60,7 +60,7 @@ class CommaSeparatedMultipleString(StringParamType): envvar_list_splitter = "," def split_envvar_value(self, rv: str): - values = super(CommaSeparatedMultipleString, self).split_envvar_value(rv) + values = super().split_envvar_value(rv) return tuple(value.strip() for value in values) diff --git a/septentrion/configuration.py b/septentrion/configuration.py index e7bd35c..ecc901f 100644 --- a/septentrion/configuration.py +++ b/septentrion/configuration.py @@ -68,7 +68,7 @@ def read_default_configuration_files() -> Tuple[str, pathlib.Path]: def read_configuration_file(path: pathlib.Path) -> str: - with open(path, "r") as handler: + with open(path) as handler: logger.info(f"Reading configuration from {path}") return handler.read() diff --git a/septentrion/db.py b/septentrion/db.py index fe7fd89..dc821b1 100644 --- a/septentrion/db.py +++ b/septentrion/db.py @@ -77,7 +77,7 @@ def execute( conn.commit() -class Query(object): +class Query: def __init__( self, settings: configuration.Settings, diff --git a/septentrion/files.py b/septentrion/files.py index 49c41ad..6cb6e7f 100644 --- a/septentrion/files.py +++ b/septentrion/files.py @@ -110,5 +110,4 @@ def list_migrations_and_paths( def file_lines_generator(path: pathlib.Path): with open(path) as f: - for line in f: - yield line + yield from f diff --git a/septentrion/migration.py b/septentrion/migration.py index b3580b1..f4a047c 100644 --- a/septentrion/migration.py +++ b/septentrion/migration.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import io import logging import pathlib @@ -192,6 +191,6 @@ def create_fake_entries( def run_script(settings: configuration.Settings, path: pathlib.Path) -> None: logger.info("Running SQL file %s", path) - with io.open(path, "r", encoding="utf8") as f: + with open(path, encoding="utf8") as f: script = runner.Script(settings=settings, file_handler=f, path=path) script.run() diff --git a/septentrion/style.py b/septentrion/style.py index ac730ba..4dc0f7b 100644 --- a/septentrion/style.py +++ b/septentrion/style.py @@ -7,7 +7,7 @@ colorama.init() -class Stylist(object): +class Stylist: styles: Dict[str, str] = { "reset": colorama.Style.RESET_ALL, "title": colorama.Fore.CYAN + colorama.Style.BRIGHT, diff --git a/tests/integration/test_runner.py b/tests/integration/test_runner.py index fc63791..4334d51 100644 --- a/tests/integration/test_runner.py +++ b/tests/integration/test_runner.py @@ -15,7 +15,7 @@ def _run_script(script): path = tmp_path / "script.sql" path.write_text(script) - with io.open(path, "r", encoding="utf8") as f: + with open(path, encoding="utf8") as f: script = Script(settings, f, path) script.run() @@ -65,7 +65,7 @@ def test_run_integer_in_settings(db, settings_factory, env, tmp_path): settings.PORT = 5432 path = tmp_path / "script.sql" path.write_text("SELECT 1;") - with io.open(path, "r", encoding="utf8") as f: + with open(path, encoding="utf8") as f: script = Script(settings, f, path) script.run() diff --git a/tests/unit/test_configuration.py b/tests/unit/test_configuration.py index 45a8c77..5e666f2 100644 --- a/tests/unit/test_configuration.py +++ b/tests/unit/test_configuration.py @@ -92,8 +92,7 @@ def test_load_configuration_files_value(caplog, conf, expected, has_warning): def test_load_configuration_files_value_from_file(caplog, mocker): with open( - pathlib.Path(__file__).parents[2] / "tests/test_data/config_file.ini", "r" - ) as f: + pathlib.Path(__file__).parents[2] / "tests/test_data/config_file.ini") as f: configuration.load_configuration_files(value=f)