From 8c5db194905ee4e1d58a5ff69b0e3768af6e9b63 Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Sat, 25 Jan 2025 14:14:48 -0800 Subject: [PATCH] Code formatting (#635). --- borgmatic/actions/borg.py | 4 +-- borgmatic/actions/break_lock.py | 4 +-- borgmatic/actions/change_passphrase.py | 4 +-- borgmatic/actions/check.py | 4 +-- borgmatic/actions/compact.py | 8 ++---- borgmatic/actions/create.py | 4 +-- borgmatic/actions/export_tar.py | 4 +-- borgmatic/actions/extract.py | 4 +-- borgmatic/actions/info.py | 4 +-- borgmatic/actions/mount.py | 4 +-- borgmatic/actions/repo_delete.py | 3 +- borgmatic/actions/repo_info.py | 4 +-- borgmatic/actions/restore.py | 8 ++---- borgmatic/actions/transfer.py | 4 +-- borgmatic/commands/borgmatic.py | 30 +++++++++++--------- borgmatic/hooks/command.py | 4 +-- borgmatic/hooks/data_source/bootstrap.py | 4 +-- borgmatic/hooks/data_source/lvm.py | 8 ++---- borgmatic/hooks/data_source/mariadb.py | 12 ++------ borgmatic/hooks/data_source/mongodb.py | 4 +-- borgmatic/hooks/data_source/mysql.py | 12 ++------ borgmatic/hooks/data_source/postgresql.py | 8 ++---- borgmatic/hooks/data_source/sqlite.py | 4 +-- borgmatic/hooks/data_source/zfs.py | 8 ++---- borgmatic/logger.py | 16 ++++++++--- tests/unit/borg/test_create.py | 4 +-- tests/unit/hooks/data_source/test_mariadb.py | 15 ++++------ tests/unit/hooks/data_source/test_mysql.py | 15 ++++------ tests/unit/hooks/data_source/test_sqlite.py | 3 +- tests/unit/hooks/test_command.py | 7 ++--- 30 files changed, 75 insertions(+), 142 deletions(-) diff --git a/borgmatic/actions/borg.py b/borgmatic/actions/borg.py index fe2facdb..cb9f6e3f 100644 --- a/borgmatic/actions/borg.py +++ b/borgmatic/actions/borg.py @@ -22,9 +22,7 @@ def run_borg( if borg_arguments.repository is None or borgmatic.config.validate.repositories_match( repository, borg_arguments.repository ): - logger.info( - 'Running arbitrary Borg command' - ) + logger.info('Running arbitrary Borg command') archive_name = borgmatic.borg.repo_list.resolve_archive_name( repository['path'], borg_arguments.archive, diff --git a/borgmatic/actions/break_lock.py b/borgmatic/actions/break_lock.py index 8375a6eb..80319a30 100644 --- a/borgmatic/actions/break_lock.py +++ b/borgmatic/actions/break_lock.py @@ -21,9 +21,7 @@ def run_break_lock( if break_lock_arguments.repository is None or borgmatic.config.validate.repositories_match( repository, break_lock_arguments.repository ): - logger.info( - 'Breaking repository and cache locks' - ) + logger.info('Breaking repository and cache locks') borgmatic.borg.break_lock.break_lock( repository['path'], config, diff --git a/borgmatic/actions/change_passphrase.py b/borgmatic/actions/change_passphrase.py index 3671d72c..7c4a3974 100644 --- a/borgmatic/actions/change_passphrase.py +++ b/borgmatic/actions/change_passphrase.py @@ -24,9 +24,7 @@ def run_change_passphrase( repository, change_passphrase_arguments.repository ) ): - logger.info( - 'Changing repository passphrase' - ) + logger.info('Changing repository passphrase') borgmatic.borg.change_passphrase.change_passphrase( repository['path'], config, diff --git a/borgmatic/actions/check.py b/borgmatic/actions/check.py index 2555613f..2d514ad0 100644 --- a/borgmatic/actions/check.py +++ b/borgmatic/actions/check.py @@ -762,9 +762,7 @@ def run_check( write_check_time(make_check_time_path(config, repository_id, 'extract')) if 'spot' in checks: - with borgmatic.config.paths.Runtime_directory( - config - ) as borgmatic_runtime_directory: + with borgmatic.config.paths.Runtime_directory(config) as borgmatic_runtime_directory: spot_check( repository, config, diff --git a/borgmatic/actions/compact.py b/borgmatic/actions/compact.py index 970e5d49..b0b070bf 100644 --- a/borgmatic/actions/compact.py +++ b/borgmatic/actions/compact.py @@ -37,9 +37,7 @@ def run_compact( **hook_context, ) if borgmatic.borg.feature.available(borgmatic.borg.feature.Feature.COMPACT, local_borg_version): - logger.info( - f'Compacting segments{dry_run_label}' - ) + logger.info(f'Compacting segments{dry_run_label}') borgmatic.borg.compact.compact_segments( global_arguments.dry_run, repository['path'], @@ -53,9 +51,7 @@ def run_compact( threshold=compact_arguments.threshold, ) else: # pragma: nocover - logger.info( - 'Skipping compact (only available/needed in Borg 1.2+)' - ) + logger.info('Skipping compact (only available/needed in Borg 1.2+)') borgmatic.hooks.command.execute_hook( config.get('after_compact'), diff --git a/borgmatic/actions/create.py b/borgmatic/actions/create.py index 1710351c..51d733d3 100644 --- a/borgmatic/actions/create.py +++ b/borgmatic/actions/create.py @@ -286,9 +286,7 @@ def run_create( logger.info(f'Creating archive{dry_run_label}') working_directory = borgmatic.config.paths.get_working_directory(config) - with borgmatic.config.paths.Runtime_directory( - config - ) as borgmatic_runtime_directory: + with borgmatic.config.paths.Runtime_directory(config) as borgmatic_runtime_directory: borgmatic.hooks.dispatch.call_hooks_even_if_unconfigured( 'remove_data_source_dumps', config, diff --git a/borgmatic/actions/export_tar.py b/borgmatic/actions/export_tar.py index 7ce6203e..d5c6bacb 100644 --- a/borgmatic/actions/export_tar.py +++ b/borgmatic/actions/export_tar.py @@ -22,9 +22,7 @@ def run_export_tar( if export_tar_arguments.repository is None or borgmatic.config.validate.repositories_match( repository, export_tar_arguments.repository ): - logger.info( - f'Exporting archive {export_tar_arguments.archive} as tar file' - ) + logger.info(f'Exporting archive {export_tar_arguments.archive} as tar file') borgmatic.borg.export_tar.export_tar_archive( global_arguments.dry_run, repository['path'], diff --git a/borgmatic/actions/extract.py b/borgmatic/actions/extract.py index fd20a05b..0216f820 100644 --- a/borgmatic/actions/extract.py +++ b/borgmatic/actions/extract.py @@ -33,9 +33,7 @@ def run_extract( if extract_arguments.repository is None or borgmatic.config.validate.repositories_match( repository, extract_arguments.repository ): - logger.info( - f'Extracting archive {extract_arguments.archive}' - ) + logger.info(f'Extracting archive {extract_arguments.archive}') borgmatic.borg.extract.extract_archive( global_arguments.dry_run, repository['path'], diff --git a/borgmatic/actions/info.py b/borgmatic/actions/info.py index 76bd7554..7dfb6df7 100644 --- a/borgmatic/actions/info.py +++ b/borgmatic/actions/info.py @@ -27,9 +27,7 @@ def run_info( repository, info_arguments.repository ): if not info_arguments.json: - logger.answer( - 'Displaying archive summary information' - ) + logger.answer('Displaying archive summary information') archive_name = borgmatic.borg.repo_list.resolve_archive_name( repository['path'], info_arguments.archive, diff --git a/borgmatic/actions/mount.py b/borgmatic/actions/mount.py index 3bddc619..f7917463 100644 --- a/borgmatic/actions/mount.py +++ b/borgmatic/actions/mount.py @@ -23,9 +23,7 @@ def run_mount( repository, mount_arguments.repository ): if mount_arguments.archive: - logger.info( - f'Mounting archive {mount_arguments.archive}' - ) + logger.info(f'Mounting archive {mount_arguments.archive}') else: # pragma: nocover logger.info('Mounting repository') diff --git a/borgmatic/actions/repo_delete.py b/borgmatic/actions/repo_delete.py index 242ffaa9..29227b15 100644 --- a/borgmatic/actions/repo_delete.py +++ b/borgmatic/actions/repo_delete.py @@ -21,8 +21,7 @@ def run_repo_delete( repository, repo_delete_arguments.repository ): logger.answer( - 'Deleting repository' - + (' cache' if repo_delete_arguments.cache_only else '') + 'Deleting repository' + (' cache' if repo_delete_arguments.cache_only else '') ) borgmatic.borg.repo_delete.delete_repository( diff --git a/borgmatic/actions/repo_info.py b/borgmatic/actions/repo_info.py index 4d4509fa..c8f035c0 100644 --- a/borgmatic/actions/repo_info.py +++ b/borgmatic/actions/repo_info.py @@ -25,9 +25,7 @@ def run_repo_info( repository, repo_info_arguments.repository ): if not repo_info_arguments.json: - logger.answer( - 'Displaying repository summary information' - ) + logger.answer('Displaying repository summary information') json_output = borgmatic.borg.repo_info.display_repository_info( repository['path'], diff --git a/borgmatic/actions/restore.py b/borgmatic/actions/restore.py index 660e7130..595b66ae 100644 --- a/borgmatic/actions/restore.py +++ b/borgmatic/actions/restore.py @@ -172,9 +172,7 @@ def restore_single_dump( Dump(hook_name, data_source['name'], data_source.get('hostname'), data_source.get('port')) ) - logger.info( - f'Restoring data source {dump_metadata}' - ) + logger.info(f'Restoring data source {dump_metadata}') dump_patterns = borgmatic.hooks.dispatch.call_hooks( 'make_data_source_dump_patterns', @@ -443,9 +441,7 @@ def run_restore( logger.info(f'Restoring data sources from archive {restore_arguments.archive}') - with borgmatic.config.paths.Runtime_directory( - config - ) as borgmatic_runtime_directory: + with borgmatic.config.paths.Runtime_directory(config) as borgmatic_runtime_directory: borgmatic.hooks.dispatch.call_hooks_even_if_unconfigured( 'remove_data_source_dumps', config, diff --git a/borgmatic/actions/transfer.py b/borgmatic/actions/transfer.py index ff94b56e..8a27d16b 100644 --- a/borgmatic/actions/transfer.py +++ b/borgmatic/actions/transfer.py @@ -17,9 +17,7 @@ def run_transfer( ''' Run the "transfer" action for the given repository. ''' - logger.info( - 'Transferring archives to repository' - ) + logger.info('Transferring archives to repository') borgmatic.borg.transfer.transfer_archives( global_arguments.dry_run, repository['path'], diff --git a/borgmatic/commands/borgmatic.py b/borgmatic/commands/borgmatic.py index fefbd8e9..2ea24086 100644 --- a/borgmatic/commands/borgmatic.py +++ b/borgmatic/commands/borgmatic.py @@ -39,7 +39,13 @@ from borgmatic.commands.arguments import parse_arguments from borgmatic.config import checks, collect, validate from borgmatic.hooks import command, dispatch from borgmatic.hooks.monitoring import monitor -from borgmatic.logger import DISABLED, add_custom_log_levels, configure_logging, should_do_markup, set_log_prefix +from borgmatic.logger import ( + DISABLED, + add_custom_log_levels, + configure_logging, + set_log_prefix, + should_do_markup, +) from borgmatic.signals import configure_signals from borgmatic.verbosity import verbosity_to_log_level @@ -131,15 +137,11 @@ def run_configuration(config_filename, config, config_paths, arguments): try: while not repo_queue.empty(): repository, retry_num = repo_queue.get() - set_log_prefix(repository.get('label', repository['path'])) - logger.debug( - 'Running actions for repository' - ) + set_log_prefix(repository.get('label', repository['path'])) + logger.debug('Running actions for repository') timeout = retry_num * retry_wait if timeout: - logger.warning( - f'Sleeping {timeout}s before next retry' - ) + logger.warning(f'Sleeping {timeout}s before next retry') time.sleep(timeout) try: yield from run_actions( @@ -165,9 +167,7 @@ def run_configuration(config_filename, config, config_paths, arguments): log_command_error_output=True, ) ) - logger.warning( - f'Retrying... attempt {retry_num + 1}/{retries}' - ) + logger.warning(f'Retrying... attempt {retry_num + 1}/{retries}') continue if command.considered_soft_failure(error): @@ -819,9 +819,11 @@ def collect_configuration_run_summary_logs(configs, config_paths, arguments): try: for config_filename, config in configs.items(): - set_log_prefix(config_filename) + set_log_prefix(config_filename) results = list(run_configuration(config_filename, config, config_paths, arguments)) - error_logs = tuple(result for result in results if isinstance(result, logging.LogRecord)) + error_logs = tuple( + result for result in results if isinstance(result, logging.LogRecord) + ) if error_logs: yield from log_error_records('An error occurred') @@ -837,7 +839,7 @@ def collect_configuration_run_summary_logs(configs, config_paths, arguments): if results: json_results.extend(results) finally: - set_log_prefix(None) + set_log_prefix(None) if 'umount' in arguments: logger.info(f"Unmounting mount point {arguments['umount'].mount_point}") diff --git a/borgmatic/hooks/command.py b/borgmatic/hooks/command.py index d0e55b62..d446ecca 100644 --- a/borgmatic/hooks/command.py +++ b/borgmatic/hooks/command.py @@ -60,9 +60,7 @@ def execute_hook(commands, umask, config_filename, description, dry_run, **conte dry_run_label = ' (dry run; not actually running hooks)' if dry_run else '' context['configuration_filename'] = config_filename - commands = [ - interpolate_context(description, command, context) for command in commands - ] + commands = [interpolate_context(description, command, context) for command in commands] if len(commands) == 1: logger.info(f'Running command for {description} hook{dry_run_label}') diff --git a/borgmatic/hooks/data_source/bootstrap.py b/borgmatic/hooks/data_source/bootstrap.py index b6ac1b4d..67d75421 100644 --- a/borgmatic/hooks/data_source/bootstrap.py +++ b/borgmatic/hooks/data_source/bootstrap.py @@ -83,9 +83,7 @@ def remove_data_source_dumps(hook_config, config, borgmatic_runtime_directory, d for manifest_directory in glob.glob(manifest_glob): manifest_file_path = os.path.join(manifest_directory, 'manifest.json') - logger.debug( - f'Removing bootstrap manifest at {manifest_file_path}{dry_run_label}' - ) + logger.debug(f'Removing bootstrap manifest at {manifest_file_path}{dry_run_label}') if dry_run: continue diff --git a/borgmatic/hooks/data_source/lvm.py b/borgmatic/hooks/data_source/lvm.py index 958ec8f7..8436d0f6 100644 --- a/borgmatic/hooks/data_source/lvm.py +++ b/borgmatic/hooks/data_source/lvm.py @@ -338,9 +338,7 @@ def remove_data_source_dumps(hook_config, config, borgmatic_runtime_directory, d ), 'lvm_snapshots', ) - logger.debug( - f'Looking for snapshots to remove in {snapshots_glob}{dry_run_label}' - ) + logger.debug(f'Looking for snapshots to remove in {snapshots_glob}{dry_run_label}') umount_command = hook_config.get('umount_command', 'umount') for snapshots_directory in glob.glob(snapshots_glob): @@ -364,9 +362,7 @@ def remove_data_source_dumps(hook_config, config, borgmatic_runtime_directory, d if not os.path.isdir(snapshot_mount_path): continue - logger.debug( - f'Unmounting LVM snapshot at {snapshot_mount_path}{dry_run_label}' - ) + logger.debug(f'Unmounting LVM snapshot at {snapshot_mount_path}{dry_run_label}') if dry_run: continue diff --git a/borgmatic/hooks/data_source/mariadb.py b/borgmatic/hooks/data_source/mariadb.py index 1d2ac8fd..abf7ba96 100644 --- a/borgmatic/hooks/data_source/mariadb.py +++ b/borgmatic/hooks/data_source/mariadb.py @@ -102,9 +102,7 @@ def execute_dump_command( + ('--result-file', dump_filename) ) - logger.debug( - f'Dumping MariaDB database "{database_name}" to {dump_filename}{dry_run_label}' - ) + logger.debug(f'Dumping MariaDB database "{database_name}" to {dump_filename}{dry_run_label}') if dry_run: return None @@ -155,9 +153,7 @@ def dump_data_sources( for database in databases: dump_path = make_dump_path(borgmatic_runtime_directory) extra_environment = {'MYSQL_PWD': database['password']} if 'password' in database else None - dump_database_names = database_names_to_dump( - database, extra_environment, dry_run - ) + dump_database_names = database_names_to_dump(database, extra_environment, dry_run) if not dump_database_names: if dry_run: @@ -209,9 +205,7 @@ def remove_data_source_dumps( borgmatic_runtime_directory to construct the destination path. If this is a dry run, then don't actually remove anything. ''' - dump.remove_data_source_dumps( - make_dump_path(borgmatic_runtime_directory), 'MariaDB', dry_run - ) + dump.remove_data_source_dumps(make_dump_path(borgmatic_runtime_directory), 'MariaDB', dry_run) def make_data_source_dump_patterns( diff --git a/borgmatic/hooks/data_source/mongodb.py b/borgmatic/hooks/data_source/mongodb.py index b5c2c744..a1a006a9 100644 --- a/borgmatic/hooks/data_source/mongodb.py +++ b/borgmatic/hooks/data_source/mongodb.py @@ -123,9 +123,7 @@ def remove_data_source_dumps( borgmatic_runtime_directory to construct the destination path. If this is a dry run, then don't actually remove anything. ''' - dump.remove_data_source_dumps( - make_dump_path(borgmatic_runtime_directory), 'MongoDB', dry_run - ) + dump.remove_data_source_dumps(make_dump_path(borgmatic_runtime_directory), 'MongoDB', dry_run) def make_data_source_dump_patterns( diff --git a/borgmatic/hooks/data_source/mysql.py b/borgmatic/hooks/data_source/mysql.py index 40d9d959..d302d1f5 100644 --- a/borgmatic/hooks/data_source/mysql.py +++ b/borgmatic/hooks/data_source/mysql.py @@ -101,9 +101,7 @@ def execute_dump_command( + ('--result-file', dump_filename) ) - logger.debug( - f'Dumping MySQL database "{database_name}" to {dump_filename}{dry_run_label}' - ) + logger.debug(f'Dumping MySQL database "{database_name}" to {dump_filename}{dry_run_label}') if dry_run: return None @@ -154,9 +152,7 @@ def dump_data_sources( for database in databases: dump_path = make_dump_path(borgmatic_runtime_directory) extra_environment = {'MYSQL_PWD': database['password']} if 'password' in database else None - dump_database_names = database_names_to_dump( - database, extra_environment, dry_run - ) + dump_database_names = database_names_to_dump(database, extra_environment, dry_run) if not dump_database_names: if dry_run: @@ -208,9 +204,7 @@ def remove_data_source_dumps( borgmatic runtime directory to construct the destination path. If this is a dry run, then don't actually remove anything. ''' - dump.remove_data_source_dumps( - make_dump_path(borgmatic_runtime_directory), 'MySQL', dry_run - ) + dump.remove_data_source_dumps(make_dump_path(borgmatic_runtime_directory), 'MySQL', dry_run) def make_data_source_dump_patterns( diff --git a/borgmatic/hooks/data_source/postgresql.py b/borgmatic/hooks/data_source/postgresql.py index 95022264..94a6e1f5 100644 --- a/borgmatic/hooks/data_source/postgresql.py +++ b/borgmatic/hooks/data_source/postgresql.py @@ -137,9 +137,7 @@ def dump_data_sources( for database in databases: extra_environment = make_extra_environment(database) dump_path = make_dump_path(borgmatic_runtime_directory) - dump_database_names = database_names_to_dump( - database, extra_environment, dry_run - ) + dump_database_names = database_names_to_dump(database, extra_environment, dry_run) if not dump_database_names: if dry_run: @@ -350,9 +348,7 @@ def restore_data_source_dump( data_source, restore_connection_params=connection_params ) - logger.debug( - f"Restoring PostgreSQL database {data_source['name']}{dry_run_label}" - ) + logger.debug(f"Restoring PostgreSQL database {data_source['name']}{dry_run_label}") if dry_run: return diff --git a/borgmatic/hooks/data_source/sqlite.py b/borgmatic/hooks/data_source/sqlite.py index 15b02bc9..4d5ce9a0 100644 --- a/borgmatic/hooks/data_source/sqlite.py +++ b/borgmatic/hooks/data_source/sqlite.py @@ -105,9 +105,7 @@ def remove_data_source_dumps( borgmatic runtime directory to construct the destination path. If this is a dry run, then don't actually remove anything. ''' - dump.remove_data_source_dumps( - make_dump_path(borgmatic_runtime_directory), 'SQLite', dry_run - ) + dump.remove_data_source_dumps(make_dump_path(borgmatic_runtime_directory), 'SQLite', dry_run) def make_data_source_dump_patterns( diff --git a/borgmatic/hooks/data_source/zfs.py b/borgmatic/hooks/data_source/zfs.py index c1ddb38c..82a71e7a 100644 --- a/borgmatic/hooks/data_source/zfs.py +++ b/borgmatic/hooks/data_source/zfs.py @@ -335,9 +335,7 @@ def remove_data_source_dumps(hook_config, config, borgmatic_runtime_directory, d ), 'zfs_snapshots', ) - logger.debug( - f'Looking for snapshots to remove in {snapshots_glob}{dry_run_label}' - ) + logger.debug(f'Looking for snapshots to remove in {snapshots_glob}{dry_run_label}') umount_command = hook_config.get('umount_command', 'umount') for snapshots_directory in glob.glob(snapshots_glob): @@ -362,9 +360,7 @@ def remove_data_source_dumps(hook_config, config, borgmatic_runtime_directory, d if not os.path.isdir(snapshot_mount_path): continue - logger.debug( - f'Unmounting ZFS snapshot at {snapshot_mount_path}{dry_run_label}' - ) + logger.debug(f'Unmounting ZFS snapshot at {snapshot_mount_path}{dry_run_label}') if not dry_run: try: diff --git a/borgmatic/logger.py b/borgmatic/logger.py index 888206a2..2a3cb62c 100644 --- a/borgmatic/logger.py +++ b/borgmatic/logger.py @@ -89,7 +89,9 @@ class Multi_stream_handler(logging.Handler): class Console_no_color_formatter(logging.Formatter): def __init__(self, *args, **kwargs): - super(Console_no_color_formatter, self).__init__('{prefix}{message}', style='{', defaults={'prefix': ''}, *args, **kwargs) + super(Console_no_color_formatter, self).__init__( + '{prefix}{message}', style='{', defaults={'prefix': ''}, *args, **kwargs + ) class Color(enum.Enum): @@ -103,7 +105,9 @@ class Color(enum.Enum): class Console_color_formatter(logging.Formatter): def __init__(self, *args, **kwargs): - super(Console_color_formatter, self).__init__('{prefix}{message}', style='{', defaults={'prefix': ''}, *args, **kwargs) + super(Console_color_formatter, self).__init__( + '{prefix}{message}', style='{', defaults={'prefix': ''}, *args, **kwargs + ) def format(self, record): add_custom_log_levels() @@ -255,7 +259,9 @@ def configure_logging( if syslog_path: syslog_handler = logging.handlers.SysLogHandler(address=syslog_path) syslog_handler.setFormatter( - logging.Formatter('borgmatic: {levelname} {prefix}{message}', style='{', defaults={'prefix': ''}) # noqa: FS003 + logging.Formatter( + 'borgmatic: {levelname} {prefix}{message}', style='{', defaults={'prefix': ''} + ) # noqa: FS003 ) syslog_handler.setLevel(syslog_log_level) handlers.append(syslog_handler) @@ -264,7 +270,9 @@ def configure_logging( file_handler = logging.handlers.WatchedFileHandler(log_file) file_handler.setFormatter( logging.Formatter( - log_file_format or '[{asctime}] {levelname}: {prefix}{message}', style='{', defaults={'prefix': ''} # noqa: FS003 + log_file_format or '[{asctime}] {levelname}: {prefix}{message}', + style='{', + defaults={'prefix': ''}, # noqa: FS003 ) ) file_handler.setLevel(log_file_log_level) diff --git a/tests/unit/borg/test_create.py b/tests/unit/borg/test_create.py index 84abcddc..1d103233 100644 --- a/tests/unit/borg/test_create.py +++ b/tests/unit/borg/test_create.py @@ -21,9 +21,7 @@ def test_write_patterns_file_writes_pattern_lines(): def test_write_patterns_file_with_empty_exclude_patterns_does_not_raise(): - module.write_patterns_file( - [], borgmatic_runtime_directory='/run/user/0' - ) + module.write_patterns_file([], borgmatic_runtime_directory='/run/user/0') def test_write_patterns_file_appends_to_existing(): diff --git a/tests/unit/hooks/data_source/test_mariadb.py b/tests/unit/hooks/data_source/test_mariadb.py index cc711738..2e4bec78 100644 --- a/tests/unit/hooks/data_source/test_mariadb.py +++ b/tests/unit/hooks/data_source/test_mariadb.py @@ -9,9 +9,7 @@ from borgmatic.hooks.data_source import mariadb as module def test_database_names_to_dump_passes_through_name(): extra_environment = flexmock() - names = module.database_names_to_dump( - {'name': 'foo'}, extra_environment, dry_run=False - ) + names = module.database_names_to_dump({'name': 'foo'}, extra_environment, dry_run=False) assert names == ('foo',) @@ -20,9 +18,7 @@ def test_database_names_to_dump_bails_for_dry_run(): extra_environment = flexmock() flexmock(module).should_receive('execute_command_and_capture_output').never() - names = module.database_names_to_dump( - {'name': 'all'}, extra_environment, dry_run=True - ) + names = module.database_names_to_dump({'name': 'all'}, extra_environment, dry_run=True) assert names == () @@ -34,16 +30,15 @@ def test_database_names_to_dump_queries_mariadb_for_database_names(): extra_environment=extra_environment, ).and_return('foo\nbar\nmysql\n').once() - names = module.database_names_to_dump( - {'name': 'all'}, extra_environment, dry_run=False - ) + names = module.database_names_to_dump({'name': 'all'}, extra_environment, dry_run=False) assert names == ('foo', 'bar') def test_use_streaming_true_for_any_databases(): assert module.use_streaming( - databases=[flexmock(), flexmock()], config=flexmock(), + databases=[flexmock(), flexmock()], + config=flexmock(), ) diff --git a/tests/unit/hooks/data_source/test_mysql.py b/tests/unit/hooks/data_source/test_mysql.py index b9ab1dfb..a056e7e5 100644 --- a/tests/unit/hooks/data_source/test_mysql.py +++ b/tests/unit/hooks/data_source/test_mysql.py @@ -9,9 +9,7 @@ from borgmatic.hooks.data_source import mysql as module def test_database_names_to_dump_passes_through_name(): extra_environment = flexmock() - names = module.database_names_to_dump( - {'name': 'foo'}, extra_environment, dry_run=False - ) + names = module.database_names_to_dump({'name': 'foo'}, extra_environment, dry_run=False) assert names == ('foo',) @@ -20,9 +18,7 @@ def test_database_names_to_dump_bails_for_dry_run(): extra_environment = flexmock() flexmock(module).should_receive('execute_command_and_capture_output').never() - names = module.database_names_to_dump( - {'name': 'all'}, extra_environment, dry_run=True - ) + names = module.database_names_to_dump({'name': 'all'}, extra_environment, dry_run=True) assert names == () @@ -34,16 +30,15 @@ def test_database_names_to_dump_queries_mysql_for_database_names(): extra_environment=extra_environment, ).and_return('foo\nbar\nmysql\n').once() - names = module.database_names_to_dump( - {'name': 'all'}, extra_environment, dry_run=False - ) + names = module.database_names_to_dump({'name': 'all'}, extra_environment, dry_run=False) assert names == ('foo', 'bar') def test_use_streaming_true_for_any_databases(): assert module.use_streaming( - databases=[flexmock(), flexmock()], config=flexmock(), + databases=[flexmock(), flexmock()], + config=flexmock(), ) diff --git a/tests/unit/hooks/data_source/test_sqlite.py b/tests/unit/hooks/data_source/test_sqlite.py index 41526793..02c343a3 100644 --- a/tests/unit/hooks/data_source/test_sqlite.py +++ b/tests/unit/hooks/data_source/test_sqlite.py @@ -7,7 +7,8 @@ from borgmatic.hooks.data_source import sqlite as module def test_use_streaming_true_for_any_databases(): assert module.use_streaming( - databases=[flexmock(), flexmock()], config=flexmock(), + databases=[flexmock(), flexmock()], + config=flexmock(), ) diff --git a/tests/unit/hooks/test_command.py b/tests/unit/hooks/test_command.py index 01d04be0..7f2e7384 100644 --- a/tests/unit/hooks/test_command.py +++ b/tests/unit/hooks/test_command.py @@ -20,9 +20,7 @@ def test_interpolate_context_interpolates_variables(): command = 'ls {foo}{baz} {baz}' # noqa: FS003 context = {'foo': 'bar', 'baz': 'quux'} - assert ( - module.interpolate_context('pre-backup', command, context) == 'ls barquux quux' - ) + assert module.interpolate_context('pre-backup', command, context) == 'ls barquux quux' def test_interpolate_context_escapes_interpolated_variables(): @@ -30,8 +28,7 @@ def test_interpolate_context_escapes_interpolated_variables(): context = {'foo': 'bar', 'inject': 'hi; naughty-command'} assert ( - module.interpolate_context('pre-backup', command, context) - == "ls bar 'hi; naughty-command'" + module.interpolate_context('pre-backup', command, context) == "ls bar 'hi; naughty-command'" )