2
0
Dan Helfman 2 сар өмнө
parent
commit
87b9ad5aea

+ 13 - 10
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}')
 

+ 0 - 1
borgmatic/config/arguments.py

@@ -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
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

+ 3 - 2
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)

+ 3 - 1
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

+ 0 - 3
tests/unit/config/test_schema.py

@@ -75,6 +75,3 @@ def test_get_properties_interleaves_oneof_list_properties():
             ('field3', {'example': 'Example 3'}),
         ]
     )
-
-
-