Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Oct 23, 2023
1 parent b9eacd7 commit 98a184e
Show file tree
Hide file tree
Showing 14 changed files with 9 additions and 25 deletions.
2 changes: 1 addition & 1 deletion septentrion/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Check warning on line 63 in septentrion/cli.py

View check run for this annotation

Codecov / codecov/patch

septentrion/cli.py#L63

Added line #L63 was not covered by tests
return tuple(value.strip() for value in values)


Expand Down
2 changes: 1 addition & 1 deletion septentrion/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
2 changes: 0 additions & 2 deletions septentrion/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ def build_migration_plan(
def describe_migration_plan(
settings: configuration.Settings, stylist: style.Stylist = style.noop_stylist
) -> None:

if not db.is_schema_initialized(settings=settings):
from_version = get_best_schema_version(settings=settings)
with stylist.activate("title") as echo:
Expand Down Expand Up @@ -212,7 +211,6 @@ def describe_migration_plan(
echo("Version {}".format(version))

for migration_elem in migrations:

name, applied, path, is_manual = migration_elem
stylist.draw_checkbox(name, checked=applied)
stylist.echo()
3 changes: 1 addition & 2 deletions septentrion/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def execute(
conn.commit()


class Query(object):
class Query:
def __init__(
self,
settings: configuration.Settings,
Expand Down Expand Up @@ -153,7 +153,6 @@ def get_applied_migrations(


def is_schema_initialized(settings: configuration.Settings) -> bool:

try:
with Query(settings=settings, query=query_is_schema_initialized) as cur:
try:
Expand Down
5 changes: 1 addition & 4 deletions septentrion/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ def get_known_versions(settings: configuration.Settings) -> List[versions.Versio
def is_manual_migration(
migration_path: pathlib.Path, migration_contents: Iterable[str]
) -> bool:

if "manual" in migration_path.parts:
return True

Expand Down Expand Up @@ -100,7 +99,6 @@ def get_migrations_files_mapping(
def list_migrations_and_paths(
folder: pathlib.Path, ignore_symlinks: bool
) -> Iterable[Tuple[str, pathlib.Path]]:

for file in iter_files(root=folder, ignore_symlinks=ignore_symlinks):
if not file.suffix == ".sql" or not file.stem[-3:] in ("ddl", "dml"):
continue
Expand All @@ -110,5 +108,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

Check warning on line 111 in septentrion/files.py

View check run for this annotation

Codecov / codecov/patch

septentrion/files.py#L111

Added line #L111 was not covered by tests
1 change: 0 additions & 1 deletion septentrion/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


def extract_metadata(package_name: str) -> Mapping[str, str]:

# Backport of Python 3.8's future importlib.metadata()
try:
metadata = importlib_metadata.metadata(package_name)
Expand Down
5 changes: 1 addition & 4 deletions septentrion/migration.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import io
import logging
import pathlib
Expand All @@ -23,7 +22,6 @@
def migrate(
settings: configuration.Settings, stylist: style.Stylist = style.noop_stylist
) -> None:

logger.info("Starting migrations")

if not db.is_schema_initialized(settings=settings):
Expand Down Expand Up @@ -141,7 +139,6 @@ def init_schema(
content="Applying {}...".format(init_version),
content_after="Applied {}".format(init_version),
):

run_script(settings=settings, path=schema_path)

create_fake_entries(settings=settings, version=init_version)
Expand Down Expand Up @@ -192,6 +189,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()
1 change: 0 additions & 1 deletion septentrion/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ def _env(self):
return {key: str(value) for key, value in environment.items() if value}

def _run_simple(self):

try:
cmd = subprocess.run(
["psql", "--set", "ON_ERROR_STOP=on", "-f", str(self.path)],
Expand Down
2 changes: 1 addition & 1 deletion septentrion/style.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion septentrion/versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

@dataclasses.dataclass(order=True, unsafe_hash=True, frozen=True)
class Version:

version_tuple: tuple = dataclasses.field(compare=True)
original_string: str = dataclasses.field(compare=False)

Expand Down
2 changes: 0 additions & 2 deletions tests/acceptance/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@


def test_initialize(db):

settings_kwargs = {
# database connection settings
"host": db["host"],
Expand All @@ -21,7 +20,6 @@ def test_initialize(db):


def test_initialize_customize_names(db):

settings_kwargs = {
# database connection settings
"host": db["host"],
Expand Down
1 change: 0 additions & 1 deletion tests/acceptance/test_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


def test_migrate(db):

settings_kwargs = {
# database connection settings
"host": db["host"],
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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()

Expand Down
3 changes: 1 addition & 2 deletions tests/unit/test_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down

0 comments on commit 98a184e

Please sign in to comment.