Code formatting (#303).

This commit is contained in:
Dan Helfman
2025-03-17 10:02:25 -07:00
parent eca78fbc2c
commit 87b9ad5aea
6 changed files with 20 additions and 18 deletions
+13 -10
View File
@@ -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}')
-1
View File
@@ -3,7 +3,6 @@ import re
import ruamel.yaml
LIST_INDEX_KEY_PATTERN = re.compile(r'^(?P<list_name>[a-zA-z-]+)\[(?P<index>\d+)\]$')
+1 -1
View File
@@ -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
+3 -2
View File
@@ -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)
+3 -1
View File
@@ -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
-3
View File
@@ -75,6 +75,3 @@ def test_get_properties_interleaves_oneof_list_properties():
('field3', {'example': 'Example 3'}),
]
)