From 87b9ad5aeaebdf02b4d448b97a5ac9ecf221dc6d Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Mon, 17 Mar 2025 10:02:25 -0700 Subject: [PATCH] Code formatting (#303). --- borgmatic/commands/arguments.py | 23 +++++++++++++---------- borgmatic/config/arguments.py | 1 - borgmatic/config/generate.py | 2 +- borgmatic/config/override.py | 5 +++-- borgmatic/config/validate.py | 4 +++- tests/unit/config/test_schema.py | 3 --- 6 files changed, 20 insertions(+), 18 deletions(-) diff --git a/borgmatic/commands/arguments.py b/borgmatic/commands/arguments.py index 555f41de..6b3abf9c 100644 --- a/borgmatic/commands/arguments.py +++ b/borgmatic/commands/arguments.py @@ -1,17 +1,17 @@ import collections import decimal -import itertools import io +import itertools import json import re import sys from argparse import ArgumentParser -from borgmatic.config import collect -import borgmatic.config.schema - import ruamel.yaml +import borgmatic.config.schema +from borgmatic.config import collect + ACTION_ALIASES = { 'repo-create': ['rcreate', 'init', '-I'], 'prune': ['-p'], @@ -340,10 +340,7 @@ def add_arguments_from_schema(arguments_group, schema, unparsed_arguments, names if properties: for name, child in properties.items(): add_arguments_from_schema( - arguments_group, - child, - unparsed_arguments, - names + (name,) + arguments_group, child, unparsed_arguments, names + (name,) ) return @@ -359,7 +356,7 @@ def add_arguments_from_schema(arguments_group, schema, unparsed_arguments, names arguments_group, child, unparsed_arguments, - names[:-1] + (f'{names[-1]}[0]',) + (name,) + names[:-1] + (f'{names[-1]}[0]',) + (name,), ) flag_name = '.'.join(names) @@ -381,7 +378,13 @@ def add_arguments_from_schema(arguments_group, schema, unparsed_arguments, names description = description.replace('%', '%%') try: - argument_type = {'string': str, 'integer': int, 'number': decimal.Decimal, 'boolean': bool, 'array': str}[schema_type] + argument_type = { + 'string': str, + 'integer': int, + 'number': decimal.Decimal, + 'boolean': bool, + 'array': str, + }[schema_type] except KeyError: raise ValueError(f'Unknown type in configuration schema: {schema_type}') diff --git a/borgmatic/config/arguments.py b/borgmatic/config/arguments.py index dab37b5b..7a71c926 100644 --- a/borgmatic/config/arguments.py +++ b/borgmatic/config/arguments.py @@ -3,7 +3,6 @@ import re import ruamel.yaml - LIST_INDEX_KEY_PATTERN = re.compile(r'^(?P[a-zA-z-]+)\[(?P\d+)\]$') diff --git a/borgmatic/config/generate.py b/borgmatic/config/generate.py index e0a646d8..fbc29c81 100644 --- a/borgmatic/config/generate.py +++ b/borgmatic/config/generate.py @@ -5,8 +5,8 @@ import re import ruamel.yaml -from borgmatic.config import load, normalize import borgmatic.config.schema +from borgmatic.config import load, normalize INDENT = 4 SEQUENCE_INDENT = 2 diff --git a/borgmatic/config/override.py b/borgmatic/config/override.py index 0893f669..9067e6f9 100644 --- a/borgmatic/config/override.py +++ b/borgmatic/config/override.py @@ -3,7 +3,6 @@ import logging import ruamel.yaml - logger = logging.getLogger(__name__) @@ -139,7 +138,9 @@ def apply_overrides(config, schema, raw_overrides): overrides = parse_overrides(raw_overrides, schema) if overrides: - logger.warning("The --override flag is deprecated and will be removed from a future release. Instead, use a command-line flag corresponding to the configuration option you'd like to set.") + logger.warning( + "The --override flag is deprecated and will be removed from a future release. Instead, use a command-line flag corresponding to the configuration option you'd like to set." + ) for keys, value in overrides: set_values(config, keys, value) diff --git a/borgmatic/config/validate.py b/borgmatic/config/validate.py index 35c8e809..063f5767 100644 --- a/borgmatic/config/validate.py +++ b/borgmatic/config/validate.py @@ -84,7 +84,9 @@ def apply_logical_validation(config_filename, parsed_configuration): ) -def parse_configuration(config_filename, schema_filename, global_arguments, overrides=None, resolve_env=True): +def parse_configuration( + config_filename, schema_filename, global_arguments, overrides=None, resolve_env=True +): ''' Given the path to a config filename in YAML format, the path to a schema filename in a YAML rendition of JSON Schema format, global arguments as an argparse.Namespace, a sequence of diff --git a/tests/unit/config/test_schema.py b/tests/unit/config/test_schema.py index e10992b6..a07b19ba 100644 --- a/tests/unit/config/test_schema.py +++ b/tests/unit/config/test_schema.py @@ -75,6 +75,3 @@ def test_get_properties_interleaves_oneof_list_properties(): ('field3', {'example': 'Example 3'}), ] ) - - -