From 6eac576a149ee28123e8c59ec94d95b81b40f477 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 28 Oct 2024 21:54:33 +0000 Subject: [PATCH 1/2] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/pre-commit-hooks: v4.1.0 → v5.0.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.1.0...v5.0.0) - [github.com/psf/black: 22.1.0 → 24.10.0](https://github.com/psf/black/compare/22.1.0...24.10.0) - [github.com/PyCQA/isort: 5.10.1 → 5.13.2](https://github.com/PyCQA/isort/compare/5.10.1...5.13.2) - [github.com/PyCQA/flake8: 4.0.1 → 7.1.1](https://github.com/PyCQA/flake8/compare/4.0.1...7.1.1) - [github.com/pre-commit/mirrors-mypy: v0.931 → v1.13.0](https://github.com/pre-commit/mirrors-mypy/compare/v0.931...v1.13.0) - [github.com/asottile/pyupgrade: v2.31.0 → v3.19.0](https://github.com/asottile/pyupgrade/compare/v2.31.0...v3.19.0) - [github.com/PyCQA/doc8: 0.10.1 → v1.1.2](https://github.com/PyCQA/doc8/compare/0.10.1...v1.1.2) --- .pre-commit-config.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 276d883..4cdb885 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,7 +2,7 @@ # See https://pre-commit.com/hooks.html for more hooks repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.1.0 + rev: v5.0.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer @@ -10,33 +10,33 @@ repos: - id: check-added-large-files - repo: https://github.com/psf/black - rev: "22.1.0" + rev: "24.10.0" hooks: - id: black - repo: https://github.com/PyCQA/isort - rev: "5.10.1" + rev: "5.13.2" hooks: - id: isort - repo: https://github.com/PyCQA/flake8 - rev: "4.0.1" + rev: "7.1.1" hooks: - id: flake8 - repo: https://github.com/pre-commit/mirrors-mypy - rev: "v0.931" + rev: "v1.13.0" hooks: - id: mypy files: ^sphinx_github_changelog/ args: ["--ignore-missing-imports", "--scripts-are-modules"] - repo: https://github.com/asottile/pyupgrade - rev: "v2.31.0" + rev: "v3.19.0" hooks: - id: pyupgrade - repo: https://github.com/PyCQA/doc8 - rev: "0.10.1" + rev: "v1.1.2" hooks: - id: doc8 From 1c1e4ebb485874f4d9459d305e37dc4b5842f97c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 28 Oct 2024 21:54:46 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- septentrion/cli.py | 3 ++- septentrion/configuration.py | 3 ++- septentrion/core.py | 1 + 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 +-- 9 files changed, 12 insertions(+), 12 deletions(-) diff --git a/septentrion/cli.py b/septentrion/cli.py index 043510e..488f8df 100644 --- a/septentrion/cli.py +++ b/septentrion/cli.py @@ -3,6 +3,7 @@ from other modules to get the information it needs, then format it and display it. """ + import functools import logging import os @@ -60,7 +61,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..7eb71ee 100644 --- a/septentrion/configuration.py +++ b/septentrion/configuration.py @@ -2,6 +2,7 @@ This is the code around settings loading. For a definition of the settings, see cli.py (for now) """ + import configparser import logging import pathlib @@ -68,7 +69,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/core.py b/septentrion/core.py index ec77f8a..5ce7c42 100644 --- a/septentrion/core.py +++ b/septentrion/core.py @@ -2,6 +2,7 @@ This is where the migration plan is computed, by merging information from the existing files (septentrion.files) and from the db (septentrion.db) """ + import logging from typing import Any, Dict, Iterable, Optional 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)