From b9000ed926df8c1f43b73e3ebefced153c6c6d28 Mon Sep 17 00:00:00 2001 From: Saugat Pachhai Date: Tue, 18 May 2021 21:36:15 +0545 Subject: [PATCH] pre-commit: update black to 21.5b1 (#6032) * pre-commit: update black to 21.5b1 also updated others, but black is more noticeable * remove magic trailing comma --- .pre-commit-config.yaml | 6 +-- dvc/_debug.py | 8 ++-- dvc/checkout.py | 10 ++--- dvc/command/add.py | 2 +- dvc/command/base.py | 8 ++-- dvc/command/check_ignore.py | 2 +- dvc/command/checkout.py | 4 +- dvc/command/completion.py | 15 ++------ dvc/command/daemon.py | 2 +- dvc/command/data_sync.py | 9 ++--- dvc/command/experiments.py | 25 +++++-------- dvc/command/freeze.py | 4 +- dvc/command/get.py | 2 +- dvc/command/get_url.py | 2 +- dvc/command/git_hook.py | 10 ++--- dvc/command/imp.py | 2 +- dvc/command/imp_url.py | 2 +- dvc/command/live.py | 2 +- dvc/command/move.py | 4 +- dvc/command/plots.py | 6 +-- dvc/command/run.py | 6 +-- dvc/command/stage.py | 6 +-- dvc/command/unprotect.py | 2 +- dvc/command/update.py | 2 +- dvc/compare.py | 5 +-- dvc/config.py | 2 +- dvc/daemon.py | 2 +- dvc/data_cloud.py | 8 +--- dvc/dependency/param.py | 2 +- dvc/dependency/repo.py | 2 +- dvc/dvcfile.py | 2 +- dvc/exceptions.py | 6 +-- dvc/external_repo.py | 5 +-- dvc/fs/base.py | 19 ++++------ dvc/fs/gdrive.py | 2 +- dvc/fs/local.py | 2 +- dvc/fs/repo.py | 8 ++-- dvc/fs/ssh/connection.py | 2 +- dvc/fs/webdav.py | 7 +--- dvc/ignore.py | 4 +- dvc/istextfile.py | 8 ++-- dvc/logger.py | 2 +- dvc/objects/db/base.py | 4 +- dvc/objects/stage.py | 6 +-- dvc/objects/tree.py | 2 +- dvc/output/base.py | 4 +- dvc/parsing/__init__.py | 4 +- dvc/parsing/context.py | 4 +- dvc/remote/index.py | 2 +- dvc/repo/__init__.py | 13 ++----- dvc/repo/checkout.py | 7 +--- dvc/repo/collect.py | 6 +-- dvc/repo/diff.py | 2 +- dvc/repo/experiments/__init__.py | 12 +++--- dvc/repo/experiments/base.py | 2 +- dvc/repo/experiments/executor/base.py | 4 +- dvc/repo/experiments/executor/local.py | 4 +- dvc/repo/experiments/pull.py | 8 +--- dvc/repo/experiments/push.py | 10 ++--- dvc/repo/experiments/remove.py | 2 +- dvc/repo/experiments/show.py | 2 +- dvc/repo/fetch.py | 8 ++-- dvc/repo/ls.py | 4 +- dvc/repo/move.py | 2 +- dvc/repo/plots/data.py | 2 +- dvc/repo/plots/template.py | 2 +- dvc/repo/stage.py | 8 ++-- dvc/schema.py | 5 +-- dvc/scm/base.py | 5 +-- dvc/scm/git/backend/dulwich.py | 2 +- dvc/scm/git/backend/gitpython.py | 2 +- dvc/scm/git/backend/pygit2.py | 2 +- dvc/scm/git/stash.py | 2 +- dvc/stage/loader.py | 2 +- dvc/stage/monitor.py | 2 +- dvc/stage/utils.py | 5 +-- dvc/ui/__init__.py | 4 +- dvc/utils/__init__.py | 14 ++----- dvc/utils/humanize.py | 2 +- dvc/utils/table.py | 2 +- scripts/build.py | 12 ++++-- scripts/fpm/notarize.py | 4 +- scripts/fpm/sign.py | 3 +- scripts/innosetup/build.py | 4 +- tests/func/experiments/test_checkpoints.py | 2 +- tests/func/experiments/test_diff.py | 5 +-- tests/func/experiments/test_experiments.py | 4 +- tests/func/metrics/test_show.py | 8 ++-- tests/func/params/test_diff.py | 6 +-- tests/func/parsing/test_errors.py | 6 +-- tests/func/parsing/test_foreach.py | 5 +-- tests/func/parsing/test_interpolated_entry.py | 18 ++++----- tests/func/parsing/test_resolver.py | 2 +- tests/func/plots/conftest.py | 4 +- tests/func/plots/test_modify.py | 9 +---- tests/func/plots/test_show.py | 35 ++++-------------- tests/func/test_add.py | 8 ++-- tests/func/test_api.py | 2 +- tests/func/test_check_ignore.py | 2 +- tests/func/test_checkout.py | 2 +- tests/func/test_config.py | 3 +- tests/func/test_data_cloud.py | 6 +-- tests/func/test_diff.py | 12 +++--- tests/func/test_dvcfile.py | 4 +- tests/func/test_external_repo.py | 2 +- tests/func/test_gc.py | 10 +---- tests/func/test_get_url.py | 4 +- tests/func/test_ignore.py | 6 +-- tests/func/test_import.py | 6 +-- tests/func/test_live.py | 23 ++---------- tests/func/test_lockfile.py | 2 +- tests/func/test_ls.py | 4 +- tests/func/test_merge_driver.py | 12 +++--- tests/func/test_odb.py | 4 +- tests/func/test_remote.py | 8 +--- tests/func/test_remove.py | 4 +- tests/func/test_repro.py | 2 +- tests/func/test_run_multistage.py | 6 +-- tests/func/test_run_single_stage.py | 14 +++---- tests/func/test_scm.py | 2 +- tests/func/test_stage_load.py | 37 +++++++++---------- tests/func/test_state.py | 16 +++++--- tests/func/test_update.py | 9 +---- tests/remotes/__init__.py | 2 +- tests/remotes/azure.py | 5 +-- tests/remotes/gdrive.py | 5 +-- tests/remotes/gs.py | 5 +-- tests/remotes/s3.py | 4 +- tests/remotes/ssh.py | 5 +-- tests/remotes/webhdfs.py | 6 +-- tests/unit/command/test_config.py | 2 +- tests/unit/command/test_dag.py | 12 +----- tests/unit/command/test_experiments.py | 4 +- tests/unit/command/test_live.py | 4 +- tests/unit/command/test_params.py | 2 +- tests/unit/command/test_plots.py | 2 +- tests/unit/dependency/test_params.py | 18 ++------- tests/unit/fs/test_dvc.py | 4 +- tests/unit/fs/test_repo.py | 24 ++++++------ tests/unit/fs/test_s3.py | 4 +- tests/unit/objects/db/test_local.py | 4 +- tests/unit/output/test_local.py | 2 +- tests/unit/output/test_output.py | 6 +-- tests/unit/remote/test_base.py | 8 +--- tests/unit/remote/test_http.py | 5 +-- tests/unit/remote/test_index.py | 4 +- tests/unit/scm/test_git.py | 14 ++----- tests/unit/stage/test_cache.py | 2 +- tests/unit/stage/test_run.py | 4 +- tests/unit/test_compare.py | 4 +- tests/unit/test_ignore.py | 8 ++-- tests/unit/test_interpolate.py | 2 +- tests/unit/test_lockfile.py | 2 +- tests/unit/ui/test_table.py | 4 +- 154 files changed, 346 insertions(+), 570 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2329a5f06..5a42d96eb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,7 @@ repos: - id: black language_version: python3 repo: https://github.com/ambv/black - rev: 19.10b0 + rev: 21.5b1 - hooks: - id: isort language_version: python3 @@ -18,7 +18,7 @@ repos: - flake8-debugger - flake8-string-format repo: https://gitlab.com/pycqa/flake8 - rev: 3.9.0 + rev: 3.9.2 - hooks: - id: mypy language_version: python3 @@ -39,7 +39,7 @@ repos: id: beautysh language_version: python3 repo: https://github.com/lovesegfault/beautysh - rev: 6.0.1 + rev: v6.1.0 - hooks: - args: - git-hook diff --git a/dvc/_debug.py b/dvc/_debug.py index 13d6f7486..c3a6d3b14 100644 --- a/dvc/_debug.py +++ b/dvc/_debug.py @@ -77,15 +77,15 @@ def add_debugging_flags(parser): from argparse import SUPPRESS parser.add_argument( - "--cprofile", action="store_true", default=False, help=SUPPRESS, + "--cprofile", action="store_true", default=False, help=SUPPRESS ) parser.add_argument("--cprofile-dump", help=SUPPRESS) parser.add_argument( - "--pdb", action="store_true", default=False, help=SUPPRESS, + "--pdb", action="store_true", default=False, help=SUPPRESS ) parser.add_argument( - "--instrument", action="store_true", default=False, help=SUPPRESS, + "--instrument", action="store_true", default=False, help=SUPPRESS ) parser.add_argument( - "--instrument-open", action="store_true", default=False, help=SUPPRESS, + "--instrument-open", action="store_true", default=False, help=SUPPRESS ) diff --git a/dvc/checkout.py b/dvc/checkout.py index 96247c20a..bcb6d38cc 100644 --- a/dvc/checkout.py +++ b/dvc/checkout.py @@ -97,7 +97,7 @@ def _do_link(cache, from_info, to_info, link_method): link_method(from_info, to_info) logger.debug( - "Created '%s': %s -> %s", cache.cache_types[0], from_info, to_info, + "Created '%s': %s -> %s", cache.cache_types[0], from_info, to_info ) @@ -187,7 +187,7 @@ def _checkout_file( def _remove_redundant_files( - path_info, fs, obj, cache, force, dvcignore: Optional[DvcIgnoreFilter], + path_info, fs, obj, cache, force, dvcignore: Optional[DvcIgnoreFilter] ): if dvcignore: existing_files = set(dvcignore.walk_files(fs, path_info)) @@ -263,7 +263,7 @@ def _checkout( ): if not obj.hash_info.isdir: ret = _checkout_file( - path_info, fs, obj, cache, force, progress_callback, relink, state, + path_info, fs, obj, cache, force, progress_callback, relink, state ) else: ret = _checkout_dir( @@ -328,9 +328,7 @@ def checkout( if failed or skip: if progress_callback and obj: - progress_callback( - str(path_info), len(obj), - ) + progress_callback(str(path_info), len(obj)) if failed: raise CheckoutError([failed]) return diff --git a/dvc/command/add.py b/dvc/command/add.py index 83d23ab82..70920cc20 100644 --- a/dvc/command/add.py +++ b/dvc/command/add.py @@ -117,6 +117,6 @@ def add_parser(subparsers, parent_parser): ), ) parser.add_argument( - "targets", nargs="+", help="Input files/directories to add.", + "targets", nargs="+", help="Input files/directories to add." ).complete = completion.FILE parser.set_defaults(func=CmdAdd) diff --git a/dvc/command/base.py b/dvc/command/base.py index 94e1e40d1..8c61423d2 100644 --- a/dvc/command/base.py +++ b/dvc/command/base.py @@ -7,11 +7,11 @@ logger = logging.getLogger(__name__) def fix_subparsers(subparsers): """Workaround for bug in Python 3. See more info at: - https://bugs.python.org/issue16308 - https://github.com/iterative/dvc/issues/769 + https://bugs.python.org/issue16308 + https://github.com/iterative/dvc/issues/769 - Args: - subparsers: subparsers to fix. + Args: + subparsers: subparsers to fix. """ subparsers.required = True subparsers.dest = "cmd" diff --git a/dvc/command/check_ignore.py b/dvc/command/check_ignore.py index cffa7c5bd..f5a7a498c 100644 --- a/dvc/command/check_ignore.py +++ b/dvc/command/check_ignore.py @@ -120,6 +120,6 @@ def add_parser(subparsers, parent_parser): help="Read paths from standard input instead of providing `targets`.", ) parser.add_argument( - "targets", nargs="*", help="File or directory paths to check", + "targets", nargs="*", help="File or directory paths to check" ).complete = completion.FILE parser.set_defaults(func=CmdCheckIgnore) diff --git a/dvc/command/checkout.py b/dvc/command/checkout.py index a0dfe0477..7981cdc41 100644 --- a/dvc/command/checkout.py +++ b/dvc/command/checkout.py @@ -11,9 +11,9 @@ from dvc.ui import ui def log_changes(stats): colors = [ - ("modified", colorama.Fore.YELLOW,), + ("modified", colorama.Fore.YELLOW), ("added", colorama.Fore.GREEN), - ("deleted", colorama.Fore.RED,), + ("deleted", colorama.Fore.RED), ] for state, color in colors: diff --git a/dvc/command/completion.py b/dvc/command/completion.py index 850bfb9d1..49d6c3474 100644 --- a/dvc/command/completion.py +++ b/dvc/command/completion.py @@ -68,25 +68,16 @@ _dvc_compadd_exps() { """, } -DVC_FILE = { - "bash": "_dvc_compgen_DVCFiles", - "zsh": "_dvc_compadd_DVCFiles", -} +DVC_FILE = {"bash": "_dvc_compgen_DVCFiles", "zsh": "_dvc_compadd_DVCFiles"} -STAGE = { - "bash": "_dvc_compgen_stages", - "zsh": "_dvc_compadd_stages", -} +STAGE = {"bash": "_dvc_compgen_stages", "zsh": "_dvc_compadd_stages"} DVCFILES_AND_STAGE = { "bash": "_dvc_compgen_stages_and_files", "zsh": "_dvc_compadd_stages_and_files", } -EXPERIMENT = { - "bash": "_dvc_compgen_exps", - "zsh": "_dvc_compadd_exps", -} +EXPERIMENT = {"bash": "_dvc_compgen_exps", "zsh": "_dvc_compadd_exps"} class CmdCompletion(CmdBaseNoRepo): diff --git a/dvc/command/daemon.py b/dvc/command/daemon.py index bbed4e2e8..cf82bcc93 100644 --- a/dvc/command/daemon.py +++ b/dvc/command/daemon.py @@ -67,6 +67,6 @@ def add_parser(subparsers, parent_parser): help=DAEMON_ANALYTICS_HELP, ) daemon_analytics_parser.add_argument( - "target", help="Analytics file.", + "target", help="Analytics file." ).complete = completion.FILE daemon_analytics_parser.set_defaults(func=CmdDaemonAnalytics) diff --git a/dvc/command/data_sync.py b/dvc/command/data_sync.py index 6281435c0..a7c8c39e4 100644 --- a/dvc/command/data_sync.py +++ b/dvc/command/data_sync.py @@ -139,7 +139,7 @@ def add_parser(subparsers, _parent_parser): formatter_class=argparse.RawDescriptionHelpFormatter, ) pull_parser.add_argument( - "-r", "--remote", help="Remote storage to pull from", metavar="", + "-r", "--remote", help="Remote storage to pull from", metavar="" ) pull_parser.add_argument( "-a", @@ -208,7 +208,7 @@ def add_parser(subparsers, _parent_parser): formatter_class=argparse.RawDescriptionHelpFormatter, ) push_parser.add_argument( - "-r", "--remote", help="Remote storage to push to", metavar="", + "-r", "--remote", help="Remote storage to push to", metavar="" ) push_parser.add_argument( "-a", @@ -272,10 +272,7 @@ def add_parser(subparsers, _parent_parser): formatter_class=argparse.RawDescriptionHelpFormatter, ) fetch_parser.add_argument( - "-r", - "--remote", - help="Remote storage to fetch from", - metavar="", + "-r", "--remote", help="Remote storage to fetch from", metavar="" ) fetch_parser.add_argument( "-a", diff --git a/dvc/command/experiments.py b/dvc/command/experiments.py index ed53dfece..66a57a455 100644 --- a/dvc/command/experiments.py +++ b/dvc/command/experiments.py @@ -304,14 +304,7 @@ def experiments_table( from dvc.compare import TabularData - headers = [ - "Experiment", - "rev", - "queued", - "typ", - "Created", - "parent", - ] + headers = ["Experiment", "rev", "queued", "typ", "Created", "parent"] td = TabularData( lconcat(headers, metric_headers, param_headers), fill_value=FILL_VALUE ) @@ -714,7 +707,7 @@ class CmdExperimentsRemove(CmdBase): def run(self): self.repo.experiments.remove( - exp_names=self.args.experiment, queue=self.args.queue, + exp_names=self.args.experiment, queue=self.args.queue ) return 0 @@ -875,7 +868,7 @@ def add_parser(subparsers, parent_parser): help="Fail if this command would overwrite conflicting changes.", ) experiments_apply_parser.add_argument( - "experiment", help="Experiment to be applied.", + "experiment", help="Experiment to be applied." ).complete = completion.EXPERIMENT experiments_apply_parser.set_defaults(func=CmdExperimentsApply) @@ -1040,10 +1033,10 @@ def add_parser(subparsers, parent_parser): formatter_class=argparse.RawDescriptionHelpFormatter, ) experiments_branch_parser.add_argument( - "experiment", help="Experiment to be promoted.", + "experiment", help="Experiment to be promoted." ) experiments_branch_parser.add_argument( - "branch", help="Git branch name to use.", + "branch", help="Git branch name to use." ) experiments_branch_parser.set_defaults(func=CmdExperimentsBranch) @@ -1066,7 +1059,7 @@ def add_parser(subparsers, parent_parser): metavar="", ) experiments_list_parser.add_argument( - "--all", action="store_true", help="List all experiments.", + "--all", action="store_true", help="List all experiments." ) experiments_list_parser.add_argument( "--names-only", @@ -1138,7 +1131,7 @@ def add_parser(subparsers, parent_parser): metavar="", ) experiments_push_parser.add_argument( - "experiment", help="Experiment to push.", metavar="", + "experiment", help="Experiment to push.", metavar="" ).complete = completion.EXPERIMENT experiments_push_parser.set_defaults(func=CmdExperimentsPush) @@ -1194,7 +1187,7 @@ def add_parser(subparsers, parent_parser): metavar="", ) experiments_pull_parser.add_argument( - "experiment", help="Experiment to pull.", metavar="", + "experiment", help="Experiment to pull.", metavar="" ) experiments_pull_parser.set_defaults(func=CmdExperimentsPull) @@ -1207,7 +1200,7 @@ def add_parser(subparsers, parent_parser): formatter_class=argparse.RawDescriptionHelpFormatter, ) experiments_remove_parser.add_argument( - "--queue", action="store_true", help="Remove all queued experiments.", + "--queue", action="store_true", help="Remove all queued experiments." ) experiments_remove_parser.add_argument( "experiment", diff --git a/dvc/command/freeze.py b/dvc/command/freeze.py index 14b319f0e..d9124b11a 100644 --- a/dvc/command/freeze.py +++ b/dvc/command/freeze.py @@ -40,7 +40,7 @@ def add_parser(subparsers, parent_parser): formatter_class=argparse.RawDescriptionHelpFormatter, ) freeze_parser.add_argument( - "targets", nargs="+", help="Stages or .dvc files to freeze", + "targets", nargs="+", help="Stages or .dvc files to freeze" ).complete = completion.DVC_FILE freeze_parser.set_defaults(func=CmdFreeze) @@ -53,6 +53,6 @@ def add_parser(subparsers, parent_parser): formatter_class=argparse.RawDescriptionHelpFormatter, ) unfreeze_parser.add_argument( - "targets", nargs="+", help="Stages or .dvc files to unfreeze", + "targets", nargs="+", help="Stages or .dvc files to unfreeze" ).complete = completion.DVC_FILE unfreeze_parser.set_defaults(func=CmdUnfreeze) diff --git a/dvc/command/get.py b/dvc/command/get.py index 5f0666f62..15f70f4a1 100644 --- a/dvc/command/get.py +++ b/dvc/command/get.py @@ -64,7 +64,7 @@ def add_parser(subparsers, parent_parser): "url", help="Location of DVC or Git repository to download from" ) get_parser.add_argument( - "path", help="Path to a file or directory within the repository", + "path", help="Path to a file or directory within the repository" ).complete = completion.FILE get_parser.add_argument( "-o", diff --git a/dvc/command/get_url.py b/dvc/command/get_url.py index 6c950673b..848842783 100644 --- a/dvc/command/get_url.py +++ b/dvc/command/get_url.py @@ -34,7 +34,7 @@ def add_parser(subparsers, parent_parser): "url", help="See `dvc import-url -h` for full list of supported URLs." ) get_parser.add_argument( - "out", nargs="?", help="Destination path to put data to.", + "out", nargs="?", help="Destination path to put data to." ).complete = completion.DIR get_parser.add_argument( "-j", diff --git a/dvc/command/git_hook.py b/dvc/command/git_hook.py index e936ce6f3..4da6a3f99 100644 --- a/dvc/command/git_hook.py +++ b/dvc/command/git_hook.py @@ -105,7 +105,7 @@ def add_parser(subparsers, parent_parser): help=PRE_COMMIT_HELP, ) pre_commit_parser.add_argument( - "args", nargs="*", help="Arguments passed by GIT or pre-commit tool.", + "args", nargs="*", help="Arguments passed by GIT or pre-commit tool." ) pre_commit_parser.set_defaults(func=CmdPreCommit) @@ -117,7 +117,7 @@ def add_parser(subparsers, parent_parser): help=POST_CHECKOUT_HELP, ) post_checkout_parser.add_argument( - "args", nargs="*", help="Arguments passed by GIT or pre-commit tool.", + "args", nargs="*", help="Arguments passed by GIT or pre-commit tool." ) post_checkout_parser.set_defaults(func=CmdPostCheckout) @@ -129,7 +129,7 @@ def add_parser(subparsers, parent_parser): help=PRE_PUSH_HELP, ) pre_push_parser.add_argument( - "args", nargs="*", help="Arguments passed by GIT or pre-commit tool.", + "args", nargs="*", help="Arguments passed by GIT or pre-commit tool." ) pre_push_parser.set_defaults(func=CmdPrePush) @@ -146,9 +146,7 @@ def add_parser(subparsers, parent_parser): help="Ancestor's version of the conflicting file.", ) merge_driver_parser.add_argument( - "--our", - required=True, - help="Current version of the conflicting file.", + "--our", required=True, help="Current version of the conflicting file." ) merge_driver_parser.add_argument( "--their", diff --git a/dvc/command/imp.py b/dvc/command/imp.py index 240204cde..2fad3bcb9 100644 --- a/dvc/command/imp.py +++ b/dvc/command/imp.py @@ -48,7 +48,7 @@ def add_parser(subparsers, parent_parser): "url", help="Location of DVC or Git repository to download from" ) import_parser.add_argument( - "path", help="Path to a file or directory within the repository", + "path", help="Path to a file or directory within the repository" ).complete = completion.FILE import_parser.add_argument( "-o", diff --git a/dvc/command/imp_url.py b/dvc/command/imp_url.py index 0bf54663a..5198d4f02 100644 --- a/dvc/command/imp_url.py +++ b/dvc/command/imp_url.py @@ -58,7 +58,7 @@ def add_parser(subparsers, parent_parser): "remote://remote_name/path/to/file/or/dir (see `dvc remote`)", ) import_parser.add_argument( - "out", nargs="?", help="Destination path to put files to.", + "out", nargs="?", help="Destination path to put files to." ).complete = completion.DIR import_parser.add_argument( "--file", diff --git a/dvc/command/live.py b/dvc/command/live.py index e83c2017a..1eb753457 100644 --- a/dvc/command/live.py +++ b/dvc/command/live.py @@ -35,7 +35,7 @@ class CmdLiveDiff(CmdLive): def shared_parent_parser(): parent_parser = argparse.ArgumentParser(add_help=False) parent_parser.add_argument( - "target", help="Logs dir to produce summary from", + "target", help="Logs dir to produce summary from" ).complete = completion.DIR parent_parser.add_argument( "-o", diff --git a/dvc/command/move.py b/dvc/command/move.py index 6a48db72c..2f6156cdd 100644 --- a/dvc/command/move.py +++ b/dvc/command/move.py @@ -37,9 +37,9 @@ def add_parser(subparsers, parent_parser): formatter_class=argparse.RawDescriptionHelpFormatter, ) move_parser.add_argument( - "src", help="Source path to a data file or directory.", + "src", help="Source path to a data file or directory." ).complete = completion.FILE move_parser.add_argument( - "dst", help="Destination path.", + "dst", help="Destination path." ).complete = completion.FILE move_parser.set_defaults(func=CmdMove) diff --git a/dvc/command/plots.py b/dvc/command/plots.py index 72c236709..cc0f331ae 100644 --- a/dvc/command/plots.py +++ b/dvc/command/plots.py @@ -87,7 +87,7 @@ class CmdPlotsDiff(CmdPlots): class CmdPlotsModify(CmdPlots): def run(self): self.repo.plots.modify( - self.args.target, props=self._props(), unset=self.args.unset, + self.args.target, props=self._props(), unset=self.args.unset ) return 0 @@ -160,7 +160,7 @@ def add_parser(subparsers, parent_parser): help=argparse.SUPPRESS, ) plots_diff_parser.add_argument( - "revisions", nargs="*", default=None, help="Git commits to plot from", + "revisions", nargs="*", default=None, help="Git commits to plot from" ) _add_props_arguments(plots_diff_parser) _add_output_arguments(plots_diff_parser) @@ -175,7 +175,7 @@ def add_parser(subparsers, parent_parser): formatter_class=argparse.RawDescriptionHelpFormatter, ) plots_modify_parser.add_argument( - "target", help="Metric file to set properties to", + "target", help="Metric file to set properties to" ).complete = completion.FILE _add_props_arguments(plots_modify_parser) plots_modify_parser.add_argument( diff --git a/dvc/command/run.py b/dvc/command/run.py index 998723ce3..343ff782b 100644 --- a/dvc/command/run.py +++ b/dvc/command/run.py @@ -83,11 +83,9 @@ def add_parser(subparsers, parent_parser): help=RUN_HELP, formatter_class=argparse.RawDescriptionHelpFormatter, ) + run_parser.add_argument("-n", "--name", help="Stage name.") run_parser.add_argument( - "-n", "--name", help="Stage name.", - ) - run_parser.add_argument( - "--file", metavar="", help=argparse.SUPPRESS, + "--file", metavar="", help=argparse.SUPPRESS ) run_parser.add_argument( "--no-exec", diff --git a/dvc/command/stage.py b/dvc/command/stage.py index d234008f7..8a1bd066b 100644 --- a/dvc/command/stage.py +++ b/dvc/command/stage.py @@ -75,9 +75,7 @@ class CmdStageList(CmdBase): # removing duplicates while maintaining order collected = chain.from_iterable( self.repo.stage.collect( - target=target, - recursive=self.args.recursive, - accept_group=True, + target=target, recursive=self.args.recursive, accept_group=True ) for target in self.args.targets ) @@ -201,7 +199,7 @@ def _add_common_args(parser): metavar="", ) parser.add_argument( - "--live", help="Declare output as dvclive.", metavar="", + "--live", help="Declare output as dvclive.", metavar="" ) parser.add_argument( "--live-no-cache", diff --git a/dvc/command/unprotect.py b/dvc/command/unprotect.py index f14d0b748..479b50d6e 100644 --- a/dvc/command/unprotect.py +++ b/dvc/command/unprotect.py @@ -33,6 +33,6 @@ def add_parser(subparsers, parent_parser): formatter_class=argparse.RawDescriptionHelpFormatter, ) unprotect_parser.add_argument( - "targets", nargs="+", help="Data files/directories to unprotect.", + "targets", nargs="+", help="Data files/directories to unprotect." ).complete = completion.FILE unprotect_parser.set_defaults(func=CmdUnprotect) diff --git a/dvc/command/update.py b/dvc/command/update.py index ebe77ae02..01e67acba 100644 --- a/dvc/command/update.py +++ b/dvc/command/update.py @@ -36,7 +36,7 @@ def add_parser(subparsers, parent_parser): formatter_class=argparse.RawDescriptionHelpFormatter, ) update_parser.add_argument( - "targets", nargs="+", help=".dvc files to update.", + "targets", nargs="+", help=".dvc files to update." ).complete = completion.DVC_FILE update_parser.add_argument( "--rev", diff --git a/dvc/compare.py b/dvc/compare.py index df4ee087b..54f0628b1 100644 --- a/dvc/compare.py +++ b/dvc/compare.py @@ -275,10 +275,7 @@ def metrics_table( for branch, val in metrics.items(): for fname, metric in val.items(): - row_data: Dict[str, str] = { - "Revision": branch, - "Path": fname, - } + row_data: Dict[str, str] = {"Revision": branch, "Path": fname} flattened = ( flatten(format_dict(metric)) if isinstance(metric, dict) diff --git a/dvc/config.py b/dvc/config.py index 13a746b41..a9d8b328d 100644 --- a/dvc/config.py +++ b/dvc/config.py @@ -63,7 +63,7 @@ class Config(dict): CONFIG_LOCAL = "config.local" def __init__( - self, dvc_dir=None, validate=True, fs=None, config=None, + self, dvc_dir=None, validate=True, fs=None, config=None ): # pylint: disable=super-init-not-called from dvc.fs.local import LocalFileSystem diff --git a/dvc/daemon.py b/dvc/daemon.py index 61eb8a7fd..9bd45e30d 100644 --- a/dvc/daemon.py +++ b/dvc/daemon.py @@ -33,7 +33,7 @@ def _spawn_windows(cmd, env): startupinfo.dwFlags |= STARTF_USESHOWWINDOW _popen( - cmd, env=env, creationflags=creationflags, startupinfo=startupinfo, + cmd, env=env, creationflags=creationflags, startupinfo=startupinfo ).communicate() diff --git a/dvc/data_cloud.py b/dvc/data_cloud.py index 45ed2a171..8825d4510 100644 --- a/dvc/data_cloud.py +++ b/dvc/data_cloud.py @@ -48,9 +48,7 @@ class DataCloud: return get_remote(self.repo, name=name) - def push( - self, cache, jobs=None, remote=None, show_checksums=False, - ): + def push(self, cache, jobs=None, remote=None, show_checksums=False): """Push data items in a cloud-agnostic way. Args: @@ -70,9 +68,7 @@ class DataCloud: show_checksums=show_checksums, ) - def pull( - self, cache, jobs=None, remote=None, show_checksums=False, - ): + def pull(self, cache, jobs=None, remote=None, show_checksums=False): """Pull data items in a cloud-agnostic way. Args: diff --git a/dvc/dependency/param.py b/dvc/dependency/param.py index cb0dad2da..741d7278d 100644 --- a/dvc/dependency/param.py +++ b/dvc/dependency/param.py @@ -128,7 +128,7 @@ class ParamsDependency(LocalDependency): if missing_params: raise MissingParamsError( "Parameters '{}' are missing from '{}'.".format( - ", ".join(missing_params), self, + ", ".join(missing_params), self ) ) diff --git a/dvc/dependency/repo.py b/dvc/dependency/repo.py index af8865327..6d94d5f0e 100644 --- a/dvc/dependency/repo.py +++ b/dvc/dependency/repo.py @@ -94,7 +94,7 @@ class RepoDependency(LocalDependency): except (NoOutputOrStageError, NoRemoteError): pass obj = stage( - odb, path_info, repo.repo_fs, odb.fs.PARAM_CHECKSUM, jobs=jobs, + odb, path_info, repo.repo_fs, odb.fs.PARAM_CHECKSUM, jobs=jobs ) save(odb, obj, jobs=jobs) diff --git a/dvc/dvcfile.py b/dvc/dvcfile.py index 9b2df3a87..5c4392082 100644 --- a/dvc/dvcfile.py +++ b/dvc/dvcfile.py @@ -40,7 +40,7 @@ class FileIsGitIgnored(DvcException): def __init__(self, path, pipeline_file=False): super().__init__( "{}'{}' is git-ignored.".format( - "bad DVC file name " if pipeline_file else "", path, + "bad DVC file name " if pipeline_file else "", path ) ) diff --git a/dvc/exceptions.py b/dvc/exceptions.py index 563af6a64..c64847d93 100644 --- a/dvc/exceptions.py +++ b/dvc/exceptions.py @@ -35,7 +35,7 @@ class OutputDuplicationError(DvcException): ) else: msg = "output '{}' is already specified in stages:\n{}".format( - output, "\n".join(f"\t- {s.addressing}" for s in stages), + output, "\n".join(f"\t- {s.addressing}" for s in stages) ) super().__init__(msg) self.stages = stages @@ -283,7 +283,7 @@ class CheckoutError(DvcException): m = ( "Checkout failed for following targets:\n{}\nIs your " "cache up to date?\n{}".format( - "\n".join(targets), error_link("missing-files"), + "\n".join(targets), error_link("missing-files") ) ) super().__init__(m) @@ -380,7 +380,7 @@ class CacheLinkError(DvcException): def __init__(self, path_infos): msg = "No possible cache link types for '{}'. {}".format( - ", ".join([str(path) for path in path_infos]), self.SUPPORT_LINK, + ", ".join([str(path) for path in path_infos]), self.SUPPORT_LINK ) super().__init__(msg) self.path_infos = path_infos diff --git a/dvc/external_repo.py b/dvc/external_repo.py index 918d2c64c..b693e7953 100644 --- a/dvc/external_repo.py +++ b/dvc/external_repo.py @@ -36,10 +36,7 @@ def external_repo( rev = rev or "refs/remotes/origin/HEAD" cache_config = { - "cache": { - "dir": cache_dir or _get_cache_dir(url), - "type": cache_types, - } + "cache": {"dir": cache_dir or _get_cache_dir(url), "type": cache_types} } config = _get_remote_config(url) if os.path.isdir(url) else {} diff --git a/dvc/fs/base.py b/dvc/fs/base.py index 632404725..392ec5407 100644 --- a/dvc/fs/base.py +++ b/dvc/fs/base.py @@ -149,8 +149,7 @@ class BaseFileSystem: return False # We can't be sure by default def walk(self, top, topdown=True, onerror=None, **kwargs): - """Return a generator with (root, dirs, files). - """ + """Return a generator with (root, dirs, files).""" raise NotImplementedError def walk_files(self, path_info, **kwargs): @@ -209,9 +208,7 @@ class BaseFileSystem: return False return hash_.endswith(cls.CHECKSUM_DIR_SUFFIX) - def upload( - self, from_info, to_info, name=None, no_progress_bar=False, - ): + def upload(self, from_info, to_info, name=None, no_progress_bar=False): if not hasattr(self, "_upload"): raise RemoteActionNotImplemented("upload", self.scheme) @@ -266,14 +263,14 @@ class BaseFileSystem: if not _only_file and self.isdir(from_info): return self._download_dir( - from_info, to_info, name, no_progress_bar, jobs, **kwargs, + from_info, to_info, name, no_progress_bar, jobs, **kwargs ) - return self._download_file(from_info, to_info, name, no_progress_bar,) + return self._download_file(from_info, to_info, name, no_progress_bar) download_file = partialmethod(download, _only_file=True) def _download_dir( - self, from_info, to_info, name, no_progress_bar, jobs, **kwargs, + self, from_info, to_info, name, no_progress_bar, jobs, **kwargs ): from_infos = list(self.walk_files(from_info, **kwargs)) if not from_infos: @@ -290,7 +287,7 @@ class BaseFileSystem: disable=no_progress_bar, ) as pbar: download_files = pbar.wrap_fn( - partial(self._download_file, name=name, no_progress_bar=True,) + partial(self._download_file, name=name, no_progress_bar=True) ) max_workers = jobs or self.jobs with ThreadPoolExecutor(max_workers=max_workers) as executor: @@ -314,9 +311,7 @@ class BaseFileSystem: entry.cancel() raise exc - def _download_file( - self, from_info, to_info, name, no_progress_bar, - ): + def _download_file(self, from_info, to_info, name, no_progress_bar): makedirs(to_info.parent, exist_ok=True) logger.debug("Downloading '%s' to '%s'", from_info, to_info) diff --git a/dvc/fs/gdrive.py b/dvc/fs/gdrive.py index dd7844c96..5a65d9997 100644 --- a/dvc/fs/gdrive.py +++ b/dvc/fs/gdrive.py @@ -138,7 +138,7 @@ class GDriveFileSystem(BaseFileSystem): # pylint:disable=abstract-method if os.getenv(GDriveFileSystem.GDRIVE_CREDENTIALS_DATA) else config.get( "gdrive_user_credentials_file", - os.path.join(tmp_dir, self.DEFAULT_USER_CREDENTIALS_FILE,), + os.path.join(tmp_dir, self.DEFAULT_USER_CREDENTIALS_FILE), ) ) diff --git a/dvc/fs/local.py b/dvc/fs/local.py index 60ea174a0..0a2120356 100644 --- a/dvc/fs/local.py +++ b/dvc/fs/local.py @@ -161,7 +161,7 @@ class LocalFileSystem(BaseFileSystem): } def _upload( - self, from_file, to_info, name=None, no_progress_bar=False, **_kwargs, + self, from_file, to_info, name=None, no_progress_bar=False, **_kwargs ): makedirs(to_info.parent, exist_ok=True) diff --git a/dvc/fs/repo.py b/dvc/fs/repo.py index bc59c0e69..634900591 100644 --- a/dvc/fs/repo.py +++ b/dvc/fs/repo.py @@ -35,7 +35,7 @@ class RepoFileSystem(BaseFileSystem): # pylint:disable=abstract-method PARAM_CHECKSUM = "md5" def __init__( - self, repo=None, subrepos=False, repo_factory: RepoFactory = None, + self, repo=None, subrepos=False, repo_factory: RepoFactory = None ): super().__init__() @@ -245,8 +245,8 @@ class RepoFileSystem(BaseFileSystem): # pylint:disable=abstract-method def _subrepo_walk(self, dir_path, **kwargs): """Walk into a new repo. - NOTE: subrepo will only be discovered when walking if - ignore_subrepos is set to False. + NOTE: subrepo will only be discovered when walking if + ignore_subrepos is set to False. """ fs, dvc_fs = self._get_fs_pair(dir_path) fs_walk = fs.walk(dir_path, topdown=True) @@ -378,7 +378,7 @@ class RepoFileSystem(BaseFileSystem): # pylint:disable=abstract-method with open(to_file, "wb+") as to_fobj: with Tqdm.wrapattr( - to_fobj, "write", desc=name, disable=no_progress_bar, + to_fobj, "write", desc=name, disable=no_progress_bar ) as wrapped: with self.open(from_info, "rb", **kwargs) as from_fobj: shutil.copyfileobj(from_fobj, wrapped) diff --git a/dvc/fs/ssh/connection.py b/dvc/fs/ssh/connection.py index 5a8c5905d..9baad43b1 100644 --- a/dvc/fs/ssh/connection.py +++ b/dvc/fs/ssh/connection.py @@ -24,7 +24,7 @@ logger = logging.getLogger(__name__) def sizeof_fmt(num, suffix="B"): - """ Convert number of bytes to human-readable string """ + """Convert number of bytes to human-readable string""" for unit in ["", "K", "M", "G", "T", "P", "E", "Z"]: if abs(num) < 1024.0: return f"{num:3.1f}{unit}{suffix}" diff --git a/dvc/fs/webdav.py b/dvc/fs/webdav.py index eca6c5129..1e393c602 100644 --- a/dvc/fs/webdav.py +++ b/dvc/fs/webdav.py @@ -241,7 +241,7 @@ class WebDAVFileSystem(BaseFileSystem): # pylint:disable=abstract-method # Uploads file to remote def _upload( - self, from_file, to_info, name=None, no_progress_bar=False, **_kwargs, + self, from_file, to_info, name=None, no_progress_bar=False, **_kwargs ): # First try to create parent directories self.makedirs(to_info.parent) @@ -267,7 +267,4 @@ class WebDAVFileSystem(BaseFileSystem): # pylint:disable=abstract-method def info(self, path_info): info = self._client.info(path_info.path) - return { - "size": int(info["size"]), - "etag": info["etag"], - } + return {"size": int(info["size"]), "etag": info["etag"]} diff --git a/dvc/ignore.py b/dvc/ignore.py index 2f1026322..d18e3114a 100644 --- a/dvc/ignore.py +++ b/dvc/ignore.py @@ -57,7 +57,7 @@ class DvcIgnorePatterns(DvcIgnore): dirname = os.path.normpath(os.path.dirname(path)) with fs.open(path, encoding="utf-8") as fobj: path_spec_lines = [ - PatternInfo(line, "{}:{}:{}".format(name, line_no + 1, line),) + PatternInfo(line, "{}:{}:{}".format(name, line_no + 1, line)) for line_no, line in enumerate( map(str.strip, fobj.readlines()) ) @@ -366,7 +366,7 @@ class DvcIgnoreFilter: pattern = self._get_trie_pattern(dirname) if pattern: matches = pattern.matches( - dirname, basename, os.path.isdir(full_target), True, + dirname, basename, os.path.isdir(full_target), True ) if matches: diff --git a/dvc/istextfile.py b/dvc/istextfile.py index d8602c1d6..d7250fb6a 100644 --- a/dvc/istextfile.py +++ b/dvc/istextfile.py @@ -23,10 +23,10 @@ def istextblock(block): def istextfile(fname, fs, blocksize=512): - """ Uses heuristics to guess whether the given file is text or binary, - by reading a single block of bytes from the file. - If more than 30% of the chars in the block are non-text, or there - are NUL ('\x00') bytes in the block, assume this is a binary file. + """Uses heuristics to guess whether the given file is text or binary, + by reading a single block of bytes from the file. + If more than 30% of the chars in the block are non-text, or there + are NUL ('\x00') bytes in the block, assume this is a binary file. """ with fs.open(fname, "rb") as fobj: block = fobj.read(blocksize) diff --git a/dvc/logger.py b/dvc/logger.py index 3de943115..fa67f5859 100644 --- a/dvc/logger.py +++ b/dvc/logger.py @@ -256,7 +256,7 @@ def setup(level=logging.INFO): "console_trace", "console_errors", ], - }, + } }, "disable_existing_loggers": False, } diff --git a/dvc/objects/db/base.py b/dvc/objects/db/base.py index 4e637a805..7c0902ce7 100644 --- a/dvc/objects/db/base.py +++ b/dvc/objects/db/base.py @@ -35,7 +35,7 @@ class ObjectDB: self.fs.makedirs(path_info) def get(self, hash_info): - """ get raw object """ + """get raw object""" return HashFile( # Prefer string path over PathInfo when possible due to performance self.hash_to_path(hash_info.value), @@ -289,7 +289,7 @@ class ObjectDB: with ThreadPoolExecutor( max_workers=jobs or self.fs.jobs ) as executor: - in_remote = executor.map(list_with_update, traverse_prefixes,) + in_remote = executor.map(list_with_update, traverse_prefixes) yield from itertools.chain.from_iterable(in_remote) def all(self, jobs=None, name=None): diff --git a/dvc/objects/stage.py b/dvc/objects/stage.py index e069340f3..142d67cf3 100644 --- a/dvc/objects/stage.py +++ b/dvc/objects/stage.py @@ -47,7 +47,7 @@ def _get_file_hash(path_info, fs, name): def get_file_hash(path_info, fs, name, state=None): if state: hash_info = state.get( # pylint: disable=assignment-from-none - path_info, fs, + path_info, fs ) if hash_info: return hash_info @@ -109,9 +109,7 @@ def _iter_objects(path_info, fs, name, odb, state, upload, **kwargs): if not upload and name in fs.DETAIL_FIELDS: for details in fs.find(path_info, detail=True): file_info = path_info.replace(path=details["name"]) - hash_info = HashInfo( - name, details[name], size=details.get("size"), - ) + hash_info = HashInfo(name, details[name], size=details.get("size")) yield file_info, HashFile(file_info, fs, hash_info) return None diff --git a/dvc/objects/tree.py b/dvc/objects/tree.py index 77db7e8f3..79cd181da 100644 --- a/dvc/objects/tree.py +++ b/dvc/objects/tree.py @@ -198,7 +198,7 @@ def merge(odb, ancestor_info, our_info, their_info): our = load(odb, our_info) their = load(odb, their_info) - merged_dict = _merge(ancestor.as_dict(), our.as_dict(), their.as_dict(),) + merged_dict = _merge(ancestor.as_dict(), our.as_dict(), their.as_dict()) merged = Tree(None, None, None) for key, hi in merged_dict.items(): diff --git a/dvc/output/base.py b/dvc/output/base.py index 80aefd2b0..3f3544b39 100644 --- a/dvc/output/base.py +++ b/dvc/output/base.py @@ -503,7 +503,7 @@ class BaseOutput: self.repo.scm.ignore(self.fspath) def transfer( - self, source, odb=None, jobs=None, update=False, no_progress_bar=False, + self, source, odb=None, jobs=None, update=False, no_progress_bar=False ): from dvc.fs import get_cloud_fs @@ -677,7 +677,7 @@ class BaseOutput: return ret ret.add_child_cache( - self.hash_info.value, self.collect_used_dir_cache(**kwargs), + self.hash_info.value, self.collect_used_dir_cache(**kwargs) ) return ret diff --git a/dvc/parsing/__init__.py b/dvc/parsing/__init__.py index 61f91fcac..e2a1451ad 100644 --- a/dvc/parsing/__init__.py +++ b/dvc/parsing/__init__.py @@ -447,9 +447,7 @@ class ForeachDefinition: # generated stages. We do it once when accessing do_definition. return entry.resolve_stage(skip_checks=True) except ContextError as exc: - format_and_raise( - exc, f"stage '{generated}'", self.relpath, - ) + format_and_raise(exc, f"stage '{generated}'", self.relpath) # let mypy know that this state is unreachable as format_and_raise # does not return at all (it's not able to understand it for some diff --git a/dvc/parsing/context.py b/dvc/parsing/context.py index d2df9ae9c..b1ab78cc3 100644 --- a/dvc/parsing/context.py +++ b/dvc/parsing/context.py @@ -396,9 +396,7 @@ class Context(CtxDict): raise ReservedKeyError(matches) return super().merge_update(other, overwrite=overwrite) - def merge_from( - self, fs, item: str, wdir: PathInfo, overwrite=False, - ): + def merge_from(self, fs, item: str, wdir: PathInfo, overwrite=False): path, _, keys_str = item.partition(":") select_keys = lfilter(bool, keys_str.split(",")) if keys_str else None diff --git a/dvc/remote/index.py b/dvc/remote/index.py index 3f070afa5..33a8331f4 100644 --- a/dvc/remote/index.py +++ b/dvc/remote/index.py @@ -134,7 +134,7 @@ class RemoteIndex: logger.error( "Index file version '{}' will be reformatted " "to the current version '{}'.".format( - version, self.VERSION, + version, self.VERSION ) ) cmd = "DROP TABLE IF EXISTS {};" diff --git a/dvc/repo/__init__.py b/dvc/repo/__init__.py index 43195419b..b844cf6f1 100644 --- a/dvc/repo/__init__.py +++ b/dvc/repo/__init__.py @@ -147,9 +147,7 @@ class Repo: from dvc.state import State, StateNoop self.url = url - self._fs_conf = { - "repo_factory": repo_factory, - } + self._fs_conf = {"repo_factory": repo_factory} if rev and not scm: scm = SCM(root_dir or os.curdir) @@ -317,10 +315,7 @@ class Repo: return self.odb.local.unprotect(PathInfo(target)) def _ignore(self): - flist = [ - self.config.files["local"], - self.tmp_dir, - ] + flist = [self.config.files["local"], self.tmp_dir] if path_isin(self.odb.local.cache_dir, self.root_dir): flist += [self.odb.local.cache_dir] @@ -407,7 +402,7 @@ class Repo: if used_run_cache: used_cache = self.stage_cache.get_used_cache( - used_run_cache, remote=remote, force=force, jobs=jobs, + used_run_cache, remote=remote, force=force, jobs=jobs ) cache.update(used_cache) @@ -491,7 +486,7 @@ class Repo: path = PathInfo(self.root_dir) / path try: with fs.open( - path, mode=mode, encoding=encoding, remote=remote, + path, mode=mode, encoding=encoding, remote=remote ) as fobj: yield fobj except FileNotFoundError as exc: diff --git a/dvc/repo/checkout.py b/dvc/repo/checkout.py index e53906745..356a83957 100644 --- a/dvc/repo/checkout.py +++ b/dvc/repo/checkout.py @@ -87,12 +87,7 @@ def checkout( **kwargs, ): - stats = { - "added": [], - "deleted": [], - "modified": [], - "failed": [], - } + stats = {"added": [], "deleted": [], "modified": [], "failed": []} if not targets: targets = [None] stats["deleted"] = _remove_unused_links(self) diff --git a/dvc/repo/collect.py b/dvc/repo/collect.py index 1f8a03a88..1d22cd92a 100644 --- a/dvc/repo/collect.py +++ b/dvc/repo/collect.py @@ -18,7 +18,7 @@ DvcPaths = List[DvcPath] def _collect_outs( - repo: "Repo", output_filter: FilterFn = None, deps: bool = False, + repo: "Repo", output_filter: FilterFn = None, deps: bool = False ) -> Outputs: outs = [ out @@ -49,11 +49,11 @@ def _collect_paths( if not recursive: if rev == "workspace" or rev == "": logger.warning( - "'%s' was not found in current workspace.", path_info, + "'%s' was not found in current workspace.", path_info ) else: logger.warning( - "'%s' was not found at: '%s'.", path_info, rev, + "'%s' was not found at: '%s'.", path_info, rev ) continue target_infos.append(path_info) diff --git a/dvc/repo/diff.py b/dvc/repo/diff.py index 75a8e39af..1b279e58c 100644 --- a/dvc/repo/diff.py +++ b/dvc/repo/diff.py @@ -134,7 +134,7 @@ def _output_paths(repo, repo_fs, targets): def _to_checksum(output): if on_working_fs: return ostage( - repo.odb.local, output.path_info, repo.odb.local.fs, "md5", + repo.odb.local, output.path_info, repo.odb.local.fs, "md5" ).hash_info.value return output.hash_info.value diff --git a/dvc/repo/experiments/__init__.py b/dvc/repo/experiments/__init__.py index 42c861557..a2c4e04e1 100644 --- a/dvc/repo/experiments/__init__.py +++ b/dvc/repo/experiments/__init__.py @@ -412,7 +412,7 @@ class Experiments: ) if queue: logger.info( - "Queued experiment '%s' for future execution.", stash_rev[:7], + "Queued experiment '%s' for future execution.", stash_rev[:7] ) return [stash_rev] if tmp_dir or queue: @@ -459,9 +459,7 @@ class Experiments: ) @scm_locked - def new( - self, *args, checkpoint_resume: Optional[str] = None, **kwargs, - ): + def new(self, *args, checkpoint_resume: Optional[str] = None, **kwargs): """Create a new experiment. Experiment will be reproduced and checked out into the user's @@ -475,7 +473,7 @@ class Experiments: return self._stash_exp(*args, **kwargs) def _resume_checkpoint( - self, *args, resume_rev: Optional[str] = None, **kwargs, + self, *args, resume_rev: Optional[str] = None, **kwargs ): """Resume an existing (checkpoint) experiment. @@ -707,7 +705,7 @@ class Experiments: ) elif not isinstance(exc, CheckpointKilledError): logger.error( - "Failed to reproduce experiment '%s'", rev[:7], + "Failed to reproduce experiment '%s'", rev[:7] ) except CancelledError: logger.error( @@ -737,7 +735,7 @@ class Experiments: raise ExperimentExistsError(ref_info.name) for ref in executor.fetch_exps( - self.scm, force=exec_result.force, on_diverged=on_diverged, + self.scm, force=exec_result.force, on_diverged=on_diverged ): exp_rev = self.scm.get_ref(ref) if exp_rev: diff --git a/dvc/repo/experiments/base.py b/dvc/repo/experiments/base.py index 9fefb38c0..a922e7f2e 100644 --- a/dvc/repo/experiments/base.py +++ b/dvc/repo/experiments/base.py @@ -100,7 +100,7 @@ class ExpRefInfo: namespace = EXPS_NAMESPACE def __init__( - self, baseline_sha: Optional[str] = None, name: Optional[str] = None, + self, baseline_sha: Optional[str] = None, name: Optional[str] = None ): self.baseline_sha = baseline_sha self.name: str = name if name else "" diff --git a/dvc/repo/experiments/executor/base.py b/dvc/repo/experiments/executor/base.py index 8ec3bf744..a980da0b7 100644 --- a/dvc/repo/experiments/executor/base.py +++ b/dvc/repo/experiments/executor/base.py @@ -182,9 +182,7 @@ class BaseExecutor(ABC): def on_diverged_ref(orig_ref: str, new_rev: str): if force: - logger.debug( - "Replacing existing experiment '%s'", orig_ref, - ) + logger.debug("Replacing existing experiment '%s'", orig_ref) return True checkpoint = self.scm.get_ref(EXEC_CHECKPOINT) is not None diff --git a/dvc/repo/experiments/executor/local.py b/dvc/repo/experiments/executor/local.py index f2b6ef358..fd4e4bf13 100644 --- a/dvc/repo/experiments/executor/local.py +++ b/dvc/repo/experiments/executor/local.py @@ -58,9 +58,7 @@ class TempDirExecutor(BaseLocalExecutor): super().__init__(*args, **kwargs) if cache_dir: self._config(cache_dir) - logger.debug( - "Init temp dir executor in dir '%s'", self._tmp_dir, - ) + logger.debug("Init temp dir executor in dir '%s'", self._tmp_dir) def _config(self, cache_dir): local_config = os.path.join(self.dvc_dir, "config.local") diff --git a/dvc/repo/experiments/pull.py b/dvc/repo/experiments/pull.py index 487738ea8..6a21fafcc 100644 --- a/dvc/repo/experiments/pull.py +++ b/dvc/repo/experiments/pull.py @@ -62,11 +62,7 @@ def _get_exp_ref(repo, git_remote, exp_name): return exp_refs[0] -def _pull_cache( - repo, exp_ref, dvc_remote=None, jobs=None, run_cache=False, -): +def _pull_cache(repo, exp_ref, dvc_remote=None, jobs=None, run_cache=False): revs = list(exp_commits(repo.scm, [exp_ref])) logger.debug("dvc fetch experiment '%s'", exp_ref) - repo.fetch( - jobs=jobs, remote=dvc_remote, run_cache=run_cache, revs=revs, - ) + repo.fetch(jobs=jobs, remote=dvc_remote, run_cache=run_cache, revs=revs) diff --git a/dvc/repo/experiments/push.py b/dvc/repo/experiments/push.py index 6f8ae4475..ca0867bd8 100644 --- a/dvc/repo/experiments/push.py +++ b/dvc/repo/experiments/push.py @@ -12,7 +12,7 @@ logger = logging.getLogger(__name__) @locked @scm_context def push( - repo, git_remote, exp_name, *args, force=False, push_cache=False, **kwargs, + repo, git_remote, exp_name, *args, force=False, push_cache=False, **kwargs ): exp_ref = _get_exp_ref(repo, exp_name) @@ -62,11 +62,7 @@ def _get_exp_ref(repo, exp_name): return exp_refs[0] -def _push_cache( - repo, exp_ref, dvc_remote=None, jobs=None, run_cache=False, -): +def _push_cache(repo, exp_ref, dvc_remote=None, jobs=None, run_cache=False): revs = list(exp_commits(repo.scm, [exp_ref])) logger.debug("dvc push experiment '%s'", exp_ref) - repo.push( - jobs=jobs, remote=dvc_remote, run_cache=run_cache, revs=revs, - ) + repo.push(jobs=jobs, remote=dvc_remote, run_cache=run_cache, revs=revs) diff --git a/dvc/repo/experiments/remove.py b/dvc/repo/experiments/remove.py index 279733b01..a919608bb 100644 --- a/dvc/repo/experiments/remove.py +++ b/dvc/repo/experiments/remove.py @@ -56,7 +56,7 @@ def _get_ref(ref_infos, name, cur_rev): f"Ambiguous name '{name}' refers to multiple " "experiments. Use full refname to remove one of " "the following:" - ), + ) ] msg.extend([f"\t{info}" for info in ref_infos]) raise InvalidArgumentError("\n".join(msg)) diff --git a/dvc/repo/experiments/show.py b/dvc/repo/experiments/show.py index 0b5a587e5..3da741ca1 100644 --- a/dvc/repo/experiments/show.py +++ b/dvc/repo/experiments/show.py @@ -131,7 +131,7 @@ def show( for ref in repo.scm.iter_refs(base=str(ref_info)) ] for exp_ref, _ in sorted( - commits, key=lambda x: x[1].commit_time, reverse=True, + commits, key=lambda x: x[1].commit_time, reverse=True ): ref_info = ExpRefInfo.from_ref(exp_ref) assert ref_info.baseline_sha == rev diff --git a/dvc/repo/fetch.py b/dvc/repo/fetch.py index a623221c9..b4891499c 100644 --- a/dvc/repo/fetch.py +++ b/dvc/repo/fetch.py @@ -60,7 +60,7 @@ def fetch( if run_cache: self.stage_cache.pull(remote) downloaded += self.cloud.pull( - used, jobs, remote=remote, show_checksums=show_checksums, + used, jobs, remote=remote, show_checksums=show_checksums ) except NoRemoteError: if not used.external and used["local"]: @@ -111,10 +111,8 @@ def _fetch_external(self, repo_url, repo_rev, files, jobs): cb(repo.cloud.pull(used, jobs)) except (NoOutputOrStageError, NoRemoteError): pass - obj = stage(odb, path_info, repo.repo_fs, "md5", jobs=jobs,) - save( - odb, obj, jobs=jobs, download_callback=cb, - ) + obj = stage(odb, path_info, repo.repo_fs, "md5", jobs=jobs) + save(odb, obj, jobs=jobs, download_callback=cb) except CloneError: failed += 1 logger.exception( diff --git a/dvc/repo/ls.py b/dvc/repo/ls.py index 049814e14..498d02bc6 100644 --- a/dvc/repo/ls.py +++ b/dvc/repo/ls.py @@ -4,9 +4,7 @@ from dvc.exceptions import PathMissingError from dvc.path_info import PathInfo -def ls( - url, path=None, rev=None, recursive=None, dvc_only=False, -): +def ls(url, path=None, rev=None, recursive=None, dvc_only=False): """Methods for getting files and outputs for the repo. Args: diff --git a/dvc/repo/move.py b/dvc/repo/move.py index 41d81aba5..0e0ec33d7 100644 --- a/dvc/repo/move.py +++ b/dvc/repo/move.py @@ -62,7 +62,7 @@ def move(self, from_path, to_path): ) to_path = os.path.relpath(to_path, new_wdir) new_stage = self.stage.create( - single_stage=True, fname=new_fname, wdir=new_wdir, outs=[to_path], + single_stage=True, fname=new_fname, wdir=new_wdir, outs=[to_path] ) os.unlink(stage.path) diff --git a/dvc/repo/plots/data.py b/dvc/repo/plots/data.py index 7ce1e5d60..7515baa78 100644 --- a/dvc/repo/plots/data.py +++ b/dvc/repo/plots/data.py @@ -189,7 +189,7 @@ class CSVPlotData(PlotData): if header: reader = csv.DictReader( - io.StringIO(self.content), delimiter=self.delimiter, + io.StringIO(self.content), delimiter=self.delimiter ) else: reader = csv.DictReader( diff --git a/dvc/repo/plots/template.py b/dvc/repo/plots/template.py index 63e2ffdd5..17435860b 100644 --- a/dvc/repo/plots/template.py +++ b/dvc/repo/plots/template.py @@ -386,7 +386,7 @@ class ScatterTemplate(Template): }, } ], - }, + } ], }, ], diff --git a/dvc/repo/stage.py b/dvc/repo/stage.py index 14e00eb29..eeaba4eaf 100644 --- a/dvc/repo/stage.py +++ b/dvc/repo/stage.py @@ -57,7 +57,7 @@ def _collect_with_deps(stages: StageList, graph: "DiGraph") -> StageSet: def _maybe_collect_from_dvc_yaml( - loader: "StageLoad", target, with_deps: bool, **load_kwargs, + loader: "StageLoad", target, with_deps: bool, **load_kwargs ) -> StageIter: from dvc.stage.exceptions import StageNotFound @@ -90,7 +90,7 @@ def _collect_specific_target( logger.debug(msg, target, PIPELINE_FILE) if not (recursive and loader.fs.isdir(target)): stages = _maybe_collect_from_dvc_yaml( - loader, target, with_deps, accept_group=accept_group, + loader, target, with_deps, accept_group=accept_group ) if stages: return stages, file, name @@ -190,7 +190,7 @@ class StageLoad: return stage def from_target( - self, target: str, accept_group: bool = False, glob: bool = False, + self, target: str, accept_group: bool = False, glob: bool = False ) -> StageList: """ Returns a list of stage from the provided target. @@ -198,7 +198,7 @@ class StageLoad: """ path, name = parse_target(target, isa_glob=glob) return self.load_all( - path=path, name=name, accept_group=accept_group, glob=glob, + path=path, name=name, accept_group=accept_group, glob=glob ) def get_target(self, target: str) -> "Stage": diff --git a/dvc/schema.py b/dvc/schema.py index bf7025ae6..7a2c690e3 100644 --- a/dvc/schema.py +++ b/dvc/schema.py @@ -61,10 +61,7 @@ PLOT_PROPS = { BaseOutput.PARAM_PLOT_TITLE: str, BaseOutput.PARAM_PLOT_HEADER: bool, } -PLOT_PROPS_SCHEMA = { - **OUT_PSTAGE_DETAILED_SCHEMA[str], - **PLOT_PROPS, -} +PLOT_PROPS_SCHEMA = {**OUT_PSTAGE_DETAILED_SCHEMA[str], **PLOT_PROPS} PLOT_PSTAGE_SCHEMA = {str: Any(PLOT_PROPS_SCHEMA, [PLOT_PROPS_SCHEMA])} LIVE_PROPS = { diff --git a/dvc/scm/base.py b/dvc/scm/base.py index b47b89c59..cf7083bb3 100644 --- a/dvc/scm/base.py +++ b/dvc/scm/base.py @@ -92,8 +92,7 @@ class Base: return [self.ignore(path) for path in p_list] def add(self, paths): - """Makes SCM start tracking every path from a specified list of paths. - """ + """Makes SCM track every path from a specified list of paths.""" def commit(self, msg): """Makes SCM create a commit.""" @@ -197,7 +196,7 @@ class Base: """Return boolean whether file belongs to scm""" def close(self): - """ Method to close the files """ + """Method to close the files""" def _reset(self) -> None: pass diff --git a/dvc/scm/git/backend/dulwich.py b/dvc/scm/git/backend/dulwich.py index d7f91b7fe..3abc8c8ba 100644 --- a/dvc/scm/git/backend/dulwich.py +++ b/dvc/scm/git/backend/dulwich.py @@ -405,7 +405,7 @@ class DulwichBackend(BaseGitBackend): # pylint:disable=abstract-method overwrite = False if on_diverged: overwrite = on_diverged( - os.fsdecode(ref), os.fsdecode(remote_sha), + os.fsdecode(ref), os.fsdecode(remote_sha) ) if not overwrite: continue diff --git a/dvc/scm/git/backend/gitpython.py b/dvc/scm/git/backend/gitpython.py index f7bf23a3e..fe009c317 100644 --- a/dvc/scm/git/backend/gitpython.py +++ b/dvc/scm/git/backend/gitpython.py @@ -274,7 +274,7 @@ class GitPythonBackend(BaseGitBackend): # pylint:disable=abstract-method return [ c.hexsha for c in self.repo.iter_commits( - rev=head, branches=True, tags=True, remotes=True, + rev=head, branches=True, tags=True, remotes=True ) ] diff --git a/dvc/scm/git/backend/pygit2.py b/dvc/scm/git/backend/pygit2.py index 4ea535115..9a5ddef30 100644 --- a/dvc/scm/git/backend/pygit2.py +++ b/dvc/scm/git/backend/pygit2.py @@ -475,7 +475,7 @@ class Pygit2Backend(BaseGitBackend): # pylint:disable=abstract-method with self.release_odb_handles(): self.repo.checkout_index( - index=index, paths=path_list, strategy=strategy, + index=index, paths=path_list, strategy=strategy ) if index.conflicts and (ours or theirs): diff --git a/dvc/scm/git/stash.py b/dvc/scm/git/stash.py index e3caa2147..af2516810 100644 --- a/dvc/scm/git/stash.py +++ b/dvc/scm/git/stash.py @@ -30,7 +30,7 @@ class Stash: return list(iter(self)) def push( - self, message: Optional[str] = None, include_untracked: bool = False, + self, message: Optional[str] = None, include_untracked: bool = False ) -> Optional[str]: if not self.scm.is_dirty(untracked_files=include_untracked): logger.debug("No changes to stash") diff --git a/dvc/stage/loader.py b/dvc/stage/loader.py index 761f8ca54..e2368f727 100644 --- a/dvc/stage/loader.py +++ b/dvc/stage/loader.py @@ -127,7 +127,7 @@ class StageLoader(Mapping): if self.lockfile_data and name not in self.lockfile_data: self.lockfile_needs_update() logger.trace( # type: ignore[attr-defined] - "No lock entry found for '%s:%s'", self.dvcfile.relpath, name, + "No lock entry found for '%s:%s'", self.dvcfile.relpath, name ) resolved_stage = resolved_data[name] diff --git a/dvc/stage/monitor.py b/dvc/stage/monitor.py index 409eb533c..77af843c3 100644 --- a/dvc/stage/monitor.py +++ b/dvc/stage/monitor.py @@ -101,7 +101,7 @@ class Monitor: self.done = threading.Event() self.tasks = tasks self.monitor_thread = threading.Thread( - target=Monitor._loop, args=(self.tasks, self.done,), + target=Monitor._loop, args=(self.tasks, self.done) ) def __enter__(self): diff --git a/dvc/stage/utils.py b/dvc/stage/utils.py index fbed95f28..c0976d403 100644 --- a/dvc/stage/utils.py +++ b/dvc/stage/utils.py @@ -28,8 +28,7 @@ def check_stage_path(repo, path, is_wdir=False): assert repo is not None error_msg = "{wdir_or_path} '{path}' {{}}".format( - wdir_or_path="stage working dir" if is_wdir else "file path", - path=path, + wdir_or_path="stage working dir" if is_wdir else "file path", path=path ) real_path = os.path.realpath(path) @@ -304,7 +303,7 @@ def _check_stage_exists( def validate_state( - repo: "Repo", new: Union["Stage", "PipelineStage"], force: bool = False, + repo: "Repo", new: Union["Stage", "PipelineStage"], force: bool = False ) -> None: """Validates that the new stage: diff --git a/dvc/ui/__init__.py b/dvc/ui/__init__.py index 80727d5f3..3bf428470 100644 --- a/dvc/ui/__init__.py +++ b/dvc/ui/__init__.py @@ -35,7 +35,7 @@ class Formatter: class Console: def __init__( - self, formatter: Formatter = None, enable: bool = False, + self, formatter: Formatter = None, enable: bool = False ) -> None: self.formatter: Formatter = formatter or Formatter() self._enabled: bool = enable @@ -164,7 +164,7 @@ class Console: return return t.plain_table( - self, data, headers, markdown=markdown, pager=pager, force=force, + self, data, headers, markdown=markdown, pager=pager, force=force ) diff --git a/dvc/utils/__init__.py b/dvc/utils/__init__.py index d8d9db9b9..b91a01144 100644 --- a/dvc/utils/__init__.py +++ b/dvc/utils/__init__.py @@ -42,7 +42,7 @@ def _fobj_md5(fobj, hash_md5, binary, progress_func=None): def file_md5(fname, fs): - """ get the (md5 hexdigest, md5 digest) of a file """ + """get the (md5 hexdigest, md5 digest) of a file""" from dvc.istextfile import istextfile from dvc.progress import Tqdm @@ -215,7 +215,7 @@ def fix_env(env=None): def tmp_fname(fname=""): - """ Temporary name for a partial download """ + """Temporary name for a partial download""" from shortuuid import uuid return os.fspath(fname) + "." + uuid() + ".tmp" @@ -232,10 +232,7 @@ def colorize(message, color=None, style=None): if not color: return message - styles = { - "dim": colorama.Style.DIM, - "bold": colorama.Style.BRIGHT, - } + styles = {"dim": colorama.Style.DIM, "bold": colorama.Style.BRIGHT} colors = { "green": colorama.Fore.GREEN, @@ -435,10 +432,7 @@ def parse_target( if not match: return target, None - path, name = ( - match.group("path"), - match.group("name"), - ) + path, name = (match.group("path"), match.group("name")) if name and key: name += f"{JOIN}{key}" diff --git a/dvc/utils/humanize.py b/dvc/utils/humanize.py index 5d188f4a2..d7c71722d 100644 --- a/dvc/utils/humanize.py +++ b/dvc/utils/humanize.py @@ -8,7 +8,7 @@ def join(words): return ( "{before} and {after}".format( - before=", ".join(words[:-1]), after=words[-1], + before=", ".join(words[:-1]), after=words[-1] ) if len(words) > 1 else words[0] diff --git a/dvc/utils/table.py b/dvc/utils/table.py index 1387d5503..880d84e2e 100644 --- a/dvc/utils/table.py +++ b/dvc/utils/table.py @@ -91,7 +91,7 @@ class Table(RichTable): return widths def _collapse_widths( # type: ignore[override] - self, widths: List[int], wrapable: List[bool], max_width: int, + self, widths: List[int], wrapable: List[bool], max_width: int ) -> List[int]: """Collapse columns right-to-left if possible to fit table into max_width. diff --git a/scripts/build.py b/scripts/build.py index db9cf1a4d..d4aaa81f8 100644 --- a/scripts/build.py +++ b/scripts/build.py @@ -43,7 +43,9 @@ version = dvc_version.__version__ ) check_call( - ["python", "build.py"], cwd=pyinstaller, stderr=STDOUT, + ["python", "build.py"], + cwd=pyinstaller, + stderr=STDOUT, ) if args.sign_application: @@ -60,11 +62,15 @@ if args.sign_application: if args.pkg == "exe": check_call( - ["python", "build.py"], cwd=innosetup, stderr=STDOUT, + ["python", "build.py"], + cwd=innosetup, + stderr=STDOUT, ) else: check_call( - ["python", "build.py", args.pkg], cwd=fpm, stderr=STDOUT, + ["python", "build.py", args.pkg], + cwd=fpm, + stderr=STDOUT, ) if args.sign_installer: diff --git a/scripts/fpm/notarize.py b/scripts/fpm/notarize.py index 4ab73fe4a..06c4c4c7c 100644 --- a/scripts/fpm/notarize.py +++ b/scripts/fpm/notarize.py @@ -60,5 +60,7 @@ config = { (path / "config.json").write_text(json.dumps(config)) check_call( - ["gon", "config.json"], cwd=path, stderr=STDOUT, + ["gon", "config.json"], + cwd=path, + stderr=STDOUT, ) diff --git a/scripts/fpm/sign.py b/scripts/fpm/sign.py index 17bfdf9a8..02f69df1a 100644 --- a/scripts/fpm/sign.py +++ b/scripts/fpm/sign.py @@ -50,5 +50,6 @@ check_call( ) check_call( - ["pkgutil", "--check-signature", os.fspath(pkg)], stderr=STDOUT, + ["pkgutil", "--check-signature", os.fspath(pkg)], + stderr=STDOUT, ) diff --git a/scripts/innosetup/build.py b/scripts/innosetup/build.py index 58457da1f..223ee840b 100644 --- a/scripts/innosetup/build.py +++ b/scripts/innosetup/build.py @@ -38,5 +38,7 @@ with (path / "config.ini").open("w") as fobj: cfg.write(fobj) check_call( - ["iscc", "setup.iss"], cwd=path, stderr=STDOUT, + ["iscc", "setup.iss"], + cwd=path, + stderr=STDOUT, ) diff --git a/tests/func/experiments/test_checkpoints.py b/tests/func/experiments/test_checkpoints.py index 22f5e0a58..6f1ebf7f0 100644 --- a/tests/func/experiments/test_checkpoints.py +++ b/tests/func/experiments/test_checkpoints.py @@ -85,7 +85,7 @@ def test_reset_checkpoint( tmp_dir, scm, dvc, checkpoint_stage, caplog, workspace ): dvc.experiments.run( - checkpoint_stage.addressing, name="foo", tmp_dir=not workspace, + checkpoint_stage.addressing, name="foo", tmp_dir=not workspace ) results = dvc.experiments.run( diff --git a/tests/func/experiments/test_diff.py b/tests/func/experiments/test_diff.py index b6444254e..e6ea0ea8e 100644 --- a/tests/func/experiments/test_diff.py +++ b/tests/func/experiments/test_diff.py @@ -2,10 +2,7 @@ from funcy import first def test_diff_empty(tmp_dir, scm, dvc, exp_stage): - assert dvc.experiments.diff() == { - "params": {}, - "metrics": {}, - } + assert dvc.experiments.diff() == {"params": {}, "metrics": {}} def test_diff_head(tmp_dir, scm, dvc, exp_stage): diff --git a/tests/func/experiments/test_experiments.py b/tests/func/experiments/test_experiments.py index 6b9dfa5a5..47451f4cb 100644 --- a/tests/func/experiments/test_experiments.py +++ b/tests/func/experiments/test_experiments.py @@ -449,9 +449,7 @@ def test_list(tmp_dir, scm, dvc, exp_stage): exp_c = first(results) ref_info_c = first(exp_refs_by_rev(scm, exp_c)) - assert dvc.experiments.ls() == { - baseline_c: [ref_info_c.name], - } + assert dvc.experiments.ls() == {baseline_c: [ref_info_c.name]} exp_list = dvc.experiments.ls(rev=ref_info_a.baseline_sha) assert {key: set(val) for key, val in exp_list.items()} == { diff --git a/tests/func/metrics/test_show.py b/tests/func/metrics/test_show.py index c9cd85c39..ca939beb1 100644 --- a/tests/func/metrics/test_show.py +++ b/tests/func/metrics/test_show.py @@ -17,7 +17,7 @@ from dvc.utils.serialize import dump_yaml, modify_yaml def test_show_simple(tmp_dir, dvc, run_copy_metrics): tmp_dir.gen("metrics_t.yaml", "1.1") run_copy_metrics( - "metrics_t.yaml", "metrics.yaml", metrics=["metrics.yaml"], + "metrics_t.yaml", "metrics.yaml", metrics=["metrics.yaml"] ) assert dvc.metrics.show() == {"": {"metrics.yaml": 1.1}} @@ -25,7 +25,7 @@ def test_show_simple(tmp_dir, dvc, run_copy_metrics): def test_show(tmp_dir, dvc, run_copy_metrics): tmp_dir.gen("metrics_t.yaml", "foo: 1.1") run_copy_metrics( - "metrics_t.yaml", "metrics.yaml", metrics=["metrics.yaml"], + "metrics_t.yaml", "metrics.yaml", metrics=["metrics.yaml"] ) assert dvc.metrics.show() == {"": {"metrics.yaml": {"foo": 1.1}}} @@ -92,12 +92,12 @@ def test_show_subrepo_with_preexisting_tags(tmp_dir, scm): def test_missing_cache(tmp_dir, dvc, run_copy_metrics): tmp_dir.gen("metrics_t.yaml", "1.1") run_copy_metrics( - "metrics_t.yaml", "metrics.yaml", metrics=["metrics.yaml"], + "metrics_t.yaml", "metrics.yaml", metrics=["metrics.yaml"] ) # This one should be skipped stage = run_copy_metrics( - "metrics_t.yaml", "metrics2.yaml", metrics=["metrics2.yaml"], + "metrics_t.yaml", "metrics2.yaml", metrics=["metrics2.yaml"] ) remove(stage.outs[0].fspath) remove(stage.outs[0].cache_path) diff --git a/tests/func/params/test_diff.py b/tests/func/params/test_diff.py index 10377bc8d..613ac2777 100644 --- a/tests/func/params/test_diff.py +++ b/tests/func/params/test_diff.py @@ -164,7 +164,7 @@ def test_vars_shows_on_params_diff(tmp_dir, scm, dvc): dump_yaml(params_file, param_data) assert dvc.params.diff() == { "test_params.yaml": { - "vars.model1.epoch": {"new": 20, "old": 15, "diff": 5}, + "vars.model1.epoch": {"new": 20, "old": 15, "diff": 5} } } @@ -173,7 +173,7 @@ def test_vars_shows_on_params_diff(tmp_dir, scm, dvc): with data_dir.chdir(): assert dvc.params.diff() == { relpath(params_file): { - "vars.model1.epoch": {"new": 20, "old": 15, "diff": 5}, + "vars.model1.epoch": {"new": 20, "old": 15, "diff": 5} } } @@ -217,5 +217,5 @@ def test_diff_targeted(tmp_dir, scm, dvc, run_copy): } assert dvc.params.diff(a_rev="HEAD~2", targets=["other_params.yaml"]) == { - "other_params.yaml": {"xyz": {"old": "val", "new": "val3"}}, + "other_params.yaml": {"xyz": {"old": "val", "new": "val3"}} } diff --git a/tests/func/parsing/test_errors.py b/tests/func/parsing/test_errors.py index 4cfc34801..35a0f8fcc 100644 --- a/tests/func/parsing/test_errors.py +++ b/tests/func/parsing/test_errors.py @@ -180,7 +180,7 @@ def test_foreach_data_key_does_not_exists(tmp_dir, dvc, key): @pytest.mark.parametrize( - "foreach_data", ["${foo}", "${dct.model1}", "${lst.0}", "foobar"], + "foreach_data", ["${foo}", "${dct.model1}", "${lst.0}", "foobar"] ) def test_foreach_data_expects_list_or_dict(tmp_dir, dvc, foreach_data): context = Context( @@ -208,7 +208,7 @@ def test_foreach_overwriting_item_in_list( ): context = Context(global_data) definition = make_foreach_def( - tmp_dir, "build", {"model1": 10, "model2": 5}, {}, context, + tmp_dir, "build", {"model1": 10, "model2": 5}, {}, context ) with caplog.at_level(logging.WARNING, logger="dvc.parsing"): definition.resolve_all() @@ -221,7 +221,7 @@ def test_foreach_overwriting_item_in_list( def test_foreach_do_syntax_errors(tmp_dir, dvc): definition = make_foreach_def( - tmp_dir, "build", ["foo", "bar"], {"cmd": "echo ${syntax.[error}"}, + tmp_dir, "build", ["foo", "bar"], {"cmd": "echo ${syntax.[error}"} ) with pytest.raises(ResolveError) as exc_info: diff --git a/tests/func/parsing/test_foreach.py b/tests/func/parsing/test_foreach.py index 2164016b5..a864beebd 100644 --- a/tests/func/parsing/test_foreach.py +++ b/tests/func/parsing/test_foreach.py @@ -130,10 +130,7 @@ def test_params_file_with_dict_tracked(tmp_dir, dvc): def test_params_file_tracked_for_composite_list(tmp_dir, dvc): - foreach_data = [ - {"thresh": "foo"}, - {"thresh": "bar"}, - ] + foreach_data = [{"thresh": "foo"}, {"thresh": "bar"}] params = {"models": foreach_data} dump_yaml("params.yaml", params) diff --git a/tests/func/parsing/test_interpolated_entry.py b/tests/func/parsing/test_interpolated_entry.py index cb72f366f..5c5072c17 100644 --- a/tests/func/parsing/test_interpolated_entry.py +++ b/tests/func/parsing/test_interpolated_entry.py @@ -90,8 +90,8 @@ def test_stage_with_wdir(tmp_dir, dvc): "params": ["value1"], "wdir": "data", "vars": [DEFAULT_PARAMS_FILE], - }, - }, + } + } } data_dir = tmp_dir / "data" @@ -132,8 +132,8 @@ def test_with_templated_wdir(tmp_dir, dvc): "params": ["value1"], "wdir": "${dict.ws}", "vars": [DEFAULT_PARAMS_FILE], - }, - }, + } + } } dump_yaml( tmp_dir / DEFAULT_PARAMS_FILE, {"dict": {"bar": "bar", "ws": "data"}} @@ -176,7 +176,7 @@ def test_resolve_local_tries_to_load_globally_used_files(tmp_dir, dvc): "cmd": "command --value ${bar}", "params": [{"params.json": ["foo"]}], "vars": ["params.json"], - }, + } }, } resolver = DataResolver(dvc, PathInfo(str(tmp_dir)), d) @@ -187,7 +187,7 @@ def test_resolve_local_tries_to_load_globally_used_files(tmp_dir, dvc): "build": { "cmd": "command --value bar", "params": [{"params.json": ["foo"]}], - }, + } } }, ) @@ -204,8 +204,8 @@ def test_resolve_local_tries_to_load_globally_used_params_yaml(tmp_dir, dvc): "cmd": "command --value ${bar}", "params": [{"params.yaml": ["foo"]}], "vars": ["params.yaml"], - }, - }, + } + } } resolver = DataResolver(dvc, PathInfo(str(tmp_dir)), d) assert_stage_equal( @@ -215,7 +215,7 @@ def test_resolve_local_tries_to_load_globally_used_params_yaml(tmp_dir, dvc): "build": { "cmd": "command --value bar", "params": [{"params.yaml": ["foo"]}], - }, + } } }, ) diff --git a/tests/func/parsing/test_resolver.py b/tests/func/parsing/test_resolver.py index baa18ebf9..30f4cb8d2 100644 --- a/tests/func/parsing/test_resolver.py +++ b/tests/func/parsing/test_resolver.py @@ -172,7 +172,7 @@ def test_vars_already_loaded_message(tmp_dir, dvc, local, vars_): @pytest.mark.parametrize( - "vars_, loc", [(DATA, "build.vars[0]"), ("params.json", "params.json")], + "vars_, loc", [(DATA, "build.vars[0]"), ("params.json", "params.json")] ) def test_local_overwrite_error(tmp_dir, dvc, vars_, loc): dump_yaml(DEFAULT_PARAMS_FILE, DATA) diff --git a/tests/func/plots/conftest.py b/tests/func/plots/conftest.py index ab9f8035e..f9d7d96a3 100644 --- a/tests/func/plots/conftest.py +++ b/tests/func/plots/conftest.py @@ -6,7 +6,5 @@ import pytest @pytest.fixture() def custom_template(tmp_dir, dvc): template = tmp_dir / "custom_template.json" - shutil.copy( - tmp_dir / ".dvc" / "plots" / "default.json", template, - ) + shutil.copy(tmp_dir / ".dvc" / "plots" / "default.json", template) return template diff --git a/tests/func/plots/test_modify.py b/tests/func/plots/test_modify.py index 06a434ac0..cf818dc11 100644 --- a/tests/func/plots/test_modify.py +++ b/tests/func/plots/test_modify.py @@ -67,19 +67,14 @@ def test_unset_nonexistent(tmp_dir, dvc, run_copy_metrics, custom_template): ) with pytest.raises(PropsNotFoundError): - dvc.plots.modify( - "metric.json", unset=["nonexistent"], - ) + dvc.plots.modify("metric.json", unset=["nonexistent"]) def test_dir_plots(tmp_dir, dvc, run_copy_metrics): subdir = tmp_dir / "subdir" subdir.mkdir() - metric = [ - {"first_val": 100, "val": 2}, - {"first_val": 200, "val": 3}, - ] + metric = [{"first_val": 100, "val": 2}, {"first_val": 200, "val": 3}] fname = "file.json" _write_json(tmp_dir, metric, fname) diff --git a/tests/func/plots/test_show.py b/tests/func/plots/test_show.py index 01e5738a8..326a43ef9 100644 --- a/tests/func/plots/test_show.py +++ b/tests/func/plots/test_show.py @@ -146,10 +146,7 @@ def test_plot_json_single_val(tmp_dir, scm, dvc, run_copy_metrics): def test_plot_json_multiple_val(tmp_dir, scm, dvc, run_copy_metrics): - metric = [ - {"first_val": 100, "val": 2}, - {"first_val": 200, "val": 3}, - ] + metric = [{"first_val": 100, "val": 2}, {"first_val": 200, "val": 3}] _write_json(tmp_dir, metric, "metric_t.json") run_copy_metrics( "metric_t.json", @@ -622,10 +619,7 @@ def test_multiple_plots(tmp_dir, scm, dvc, run_copy_metrics): @pytest.mark.parametrize("use_dvc", [True, False]) def test_show_non_plot(tmp_dir, scm, use_dvc): - metric = [ - {"first_val": 100, "val": 2}, - {"first_val": 200, "val": 3}, - ] + metric = [{"first_val": 100, "val": 2}, {"first_val": 200, "val": 3}] _write_json(tmp_dir, metric, "metric.json") if use_dvc: @@ -660,10 +654,7 @@ def test_show_non_plot(tmp_dir, scm, use_dvc): def test_show_non_plot_and_plot_with_params( tmp_dir, scm, dvc, run_copy_metrics ): - metric = [ - {"first_val": 100, "val": 2}, - {"first_val": 200, "val": 3}, - ] + metric = [{"first_val": 100, "val": 2}, {"first_val": 200, "val": 3}] _write_json(tmp_dir, metric, "metric.json") run_copy_metrics( "metric.json", "metric2.json", plots_no_cache=["metric2.json"] @@ -684,10 +675,7 @@ def test_show_non_plot_and_plot_with_params( def test_show_no_repo(tmp_dir): - metric = [ - {"first_val": 100, "val": 2}, - {"first_val": 200, "val": 3}, - ] + metric = [{"first_val": 100, "val": 2}, {"first_val": 200, "val": 3}] _write_json(tmp_dir, metric, "metric.json") dvc = Repo(uninitialized=True) @@ -699,10 +687,7 @@ def test_show_from_subdir(tmp_dir, dvc, caplog): subdir = tmp_dir / "subdir" subdir.mkdir() - metric = [ - {"first_val": 100, "val": 2}, - {"first_val": 200, "val": 3}, - ] + metric = [{"first_val": 100, "val": 2}, {"first_val": 200, "val": 3}] _write_json(subdir, metric, "metric.json") with subdir.chdir(), caplog.at_level(logging.INFO, "dvc"): @@ -766,10 +751,7 @@ def test_dir_plots(tmp_dir, dvc, run_copy_metrics): subdir = tmp_dir / "subdir" subdir.mkdir() - metric = [ - {"first_val": 100, "val": 2}, - {"first_val": 200, "val": 3}, - ] + metric = [{"first_val": 100, "val": 2}, {"first_val": 200, "val": 3}] fname = "file.json" _write_json(tmp_dir, metric, fname) @@ -798,10 +780,7 @@ def test_dir_plots(tmp_dir, dvc, run_copy_metrics): def test_show_dir_plots(tmp_dir, dvc, run_copy_metrics): subdir = tmp_dir / "subdir" subdir.mkdir() - metric = [ - {"first_val": 100, "val": 2}, - {"first_val": 200, "val": 3}, - ] + metric = [{"first_val": 100, "val": 2}, {"first_val": 200, "val": 3}] fname = "file.json" _write_json(tmp_dir, metric, fname) diff --git a/tests/func/test_add.py b/tests/func/test_add.py index bda8d7f22..14d86e5fd 100644 --- a/tests/func/test_add.py +++ b/tests/func/test_add.py @@ -59,7 +59,7 @@ def test_add(tmp_dir, dvc): "path": "foo", "size": 3, } - ], + ] } @@ -78,7 +78,7 @@ def test_add_executable(tmp_dir, dvc): "size": 3, "isexec": True, } - ], + ] } assert os.stat("foo").st_mode & stat.S_IEXEC @@ -1052,7 +1052,7 @@ def test_add_to_remote_absolute(tmp_dir, make_tmp_dir, dvc, local_remote): [ ("multiple targets", {"targets": ["foo", "bar", "baz"]}), ("--no-commit", {"targets": ["foo"], "no_commit": True}), - ("--recursive", {"targets": ["foo"], "recursive": True},), + ("--recursive", {"targets": ["foo"], "recursive": True}), ("--external", {"targets": ["foo"], "external": True}), ], ) @@ -1132,7 +1132,7 @@ def test_add_to_cache_not_exists(tmp_dir, dvc, local_cloud): [ ("multiple targets", {"targets": ["foo", "bar", "baz"]}), ("--no-commit", {"targets": ["foo"], "no_commit": True}), - ("--recursive", {"targets": ["foo"], "recursive": True},), + ("--recursive", {"targets": ["foo"], "recursive": True}), ], ) def test_add_to_cache_invalid_combinations(dvc, invalid_opt, kwargs): diff --git a/tests/func/test_api.py b/tests/func/test_api.py index 9f4c93707..f5b65d1ba 100644 --- a/tests/func/test_api.py +++ b/tests/func/test_api.py @@ -206,7 +206,7 @@ def test_open_rev(tmp_dir, scm, dvc): ids=["file", "inside-dir"], ) def test_api_missing_local_cache_exists_on_remote( - tmp_dir, scm, dvc, as_external, remote, files, to_read, + tmp_dir, scm, dvc, as_external, remote, files, to_read ): tmp_dir.dvc_gen(files, commit="DVC track files") dvc.push() diff --git a/tests/func/test_check_ignore.py b/tests/func/test_check_ignore.py index 7bf6e73da..b1e2d674c 100644 --- a/tests/func/test_check_ignore.py +++ b/tests/func/test_check_ignore.py @@ -94,7 +94,7 @@ def test_check_ignore_sub_repo(tmp_dir, dvc, capsys): assert main(["check-ignore", "-d", os.path.join("dir", "foo")]) == 0 out, _ = capsys.readouterr() assert ( - "in sub_repo:{}\t{}".format("dir", os.path.join("dir", "foo"),) in out + "in sub_repo:{}\t{}".format("dir", os.path.join("dir", "foo")) in out ) diff --git a/tests/func/test_checkout.py b/tests/func/test_checkout.py index 00f7e3256..d2e373fad 100644 --- a/tests/func/test_checkout.py +++ b/tests/func/test_checkout.py @@ -388,7 +388,7 @@ class TestCheckoutHook(TestDvc): @patch("sys.stdout.isatty", return_value=True) @patch("dvc.prompt.input", side_effect=EOFError) def test(self, _mock_input, _mock_isatty): - """ Test that dvc checkout handles EOFError gracefully, which is what + """Test that dvc checkout handles EOFError gracefully, which is what it will experience when running in a git hook. """ stages = self.dvc.add(self.DATA_DIR) diff --git a/tests/func/test_config.py b/tests/func/test_config.py index 96d820807..ec2a02af8 100644 --- a/tests/func/test_config.py +++ b/tests/func/test_config.py @@ -313,8 +313,7 @@ def test_config_show_origin_merged(tmp_dir, dvc, caplog): ) assert ( "{}\t{}\n".format( - os.path.join(".dvc", "config.local"), - "remote.myremote.timeout=100", + os.path.join(".dvc", "config.local"), "remote.myremote.timeout=100" ) in caplog.text ) diff --git a/tests/func/test_data_cloud.py b/tests/func/test_data_cloud.py index b8f53cb94..dfd0725ab 100644 --- a/tests/func/test_data_cloud.py +++ b/tests/func/test_data_cloud.py @@ -37,7 +37,7 @@ all_clouds = [ pytest.param( pytest.lazy_fixture("oss"), marks=pytest.mark.xfail( - reason="https://github.com/iterative/dvc/issues/4633", + reason="https://github.com/iterative/dvc/issues/4633" ), ) ] @@ -189,9 +189,7 @@ def test_cloud_cli(tmp_dir, dvc, remote): # NOTE: check if remote gc works correctly on directories assert main(["gc", "-cw", "-f"] + args) == 0 - shutil.move( - dvc.odb.local.cache_dir, dvc.odb.local.cache_dir + ".back", - ) + shutil.move(dvc.odb.local.cache_dir, dvc.odb.local.cache_dir + ".back") assert main(["fetch"] + args) == 0 diff --git a/tests/func/test_diff.py b/tests/func/test_diff.py index 7723e6ba5..56e684d94 100644 --- a/tests/func/test_diff.py +++ b/tests/func/test_diff.py @@ -175,9 +175,7 @@ def test_directories(tmp_dir, scm, dvc): assert dvc.diff(":/modify", ":/delete") == { "added": [], - "deleted": [ - {"path": os.path.join("dir", "2"), "hash": digest("two")}, - ], + "deleted": [{"path": os.path.join("dir", "2"), "hash": digest("two")}], "modified": [ { "path": os.path.join("dir", ""), @@ -223,7 +221,7 @@ def test_diff_no_cache(tmp_dir, scm, dvc): { "path": os.path.join("dir", ""), "hash": "f0f7a307d223921557c929f944bf5303.dir", - }, + } ] @@ -396,7 +394,7 @@ def test_targets_single_dir_with_file(tmp_dir, scm, dvc): { "path": os.path.join("dir_with", "file.txt"), "hash": digest("first"), - }, + } ], "deleted": [], "modified": [], @@ -416,7 +414,7 @@ def test_targets_single_file_in_dir_with_file(tmp_dir, scm, dvc): { "path": os.path.join("dir_with", "file.txt"), "hash": digest("first"), - }, + } ], "deleted": [], "modified": [], @@ -558,7 +556,7 @@ def test_rename_multiple_files_same_hashes(tmp_dir, scm, dvc): them in either of the `added` or the `deleted` section. """ tmp_dir.dvc_gen( - {"dir": {"foo": "foo", "subdir": {"foo": "foo"}}}, commit="commit #1", + {"dir": {"foo": "foo", "subdir": {"foo": "foo"}}}, commit="commit #1" ) remove(tmp_dir / "dir") # changing foo and subdir/foo to bar and subdir/bar respectively diff --git a/tests/func/test_dvcfile.py b/tests/func/test_dvcfile.py index 4d66592b9..9bbbaee76 100644 --- a/tests/func/test_dvcfile.py +++ b/tests/func/test_dvcfile.py @@ -376,9 +376,7 @@ def test_dvcfile_dump_preserves_comments(tmp_dir, dvc): ], ) def test_dvcfile_try_dumping_parametrized_stage(tmp_dir, dvc, data, name): - dump_yaml( - "dvc.yaml", {"stages": data, "vars": [{"foo": "foobar"}]}, - ) + dump_yaml("dvc.yaml", {"stages": data, "vars": [{"foo": "foobar"}]}) stage = dvc.stage.load_one(name=name) dvcfile = stage.dvcfile diff --git a/tests/func/test_external_repo.py b/tests/func/test_external_repo.py index 41f53b782..bd41e5205 100644 --- a/tests/func/test_external_repo.py +++ b/tests/func/test_external_repo.py @@ -94,7 +94,7 @@ def test_pull_subdir_file(tmp_dir, erepo_dir): dest = tmp_dir / "file" with external_repo(os.fspath(erepo_dir)) as repo: repo.repo_fs.download( - PathInfo(repo.root_dir) / "subdir" / "file", PathInfo(dest), + PathInfo(repo.root_dir) / "subdir" / "file", PathInfo(dest) ) assert dest.is_file() diff --git a/tests/func/test_gc.py b/tests/func/test_gc.py index 942858cfe..9a25bb7d3 100644 --- a/tests/func/test_gc.py +++ b/tests/func/test_gc.py @@ -286,15 +286,7 @@ def test_gc_cloud_without_any_specifier(tmp_dir, dvc, caplog): def test_gc_with_possible_args_positive(tmp_dir, dvc): - for flag in [ - "-w", - "-a", - "-T", - "--all-commits", - "-aT", - "-wa", - "-waT", - ]: + for flag in ["-w", "-a", "-T", "--all-commits", "-aT", "-wa", "-waT"]: assert main(["gc", "-vf", flag]) == 0 diff --git a/tests/func/test_get_url.py b/tests/func/test_get_url.py index 2951f2de9..4626ff13c 100644 --- a/tests/func/test_get_url.py +++ b/tests/func/test_get_url.py @@ -26,9 +26,7 @@ def test_get_dir(tmp_dir): @pytest.mark.parametrize("dname", [".", "dir", "dir/subdir"]) -def test_get_url_to_dir( - tmp_dir, tmp_path_factory, dname, -): +def test_get_url_to_dir(tmp_dir, tmp_path_factory, dname): tmp_dir.gen({"src": {"foo": "foo contents"}, "dir": {"subdir": {}}}) Repo.get_url(os.path.join("src", "foo"), dname) diff --git a/tests/func/test_ignore.py b/tests/func/test_ignore.py index 30e9446c7..3ef3088a1 100644 --- a/tests/func/test_ignore.py +++ b/tests/func/test_ignore.py @@ -281,9 +281,7 @@ def test_ignore_directory(tmp_dir, dvc): tmp_dir.gen({"dir": {DvcIgnore.DVCIGNORE_FILE: "fortz"}}) dvc._reset() result = dvc.dvcignore.walk_files(dvc.fs, tmp_dir / "dir") - assert set(result) == { - tmp_dir / "dir" / DvcIgnore.DVCIGNORE_FILE, - } + assert set(result) == {tmp_dir / "dir" / DvcIgnore.DVCIGNORE_FILE} def test_multi_ignore_file(tmp_dir, dvc, monkeypatch): @@ -310,7 +308,7 @@ def test_pattern_trie_fs(tmp_dir, dvc): "bottom": {}, } }, - }, + } }, "other": {DvcIgnore.DVCIGNORE_FILE: "1\n2\n3"}, } diff --git a/tests/func/test_import.py b/tests/func/test_import.py index 10696efb8..a65c3aac1 100644 --- a/tests/func/test_import.py +++ b/tests/func/test_import.py @@ -163,7 +163,7 @@ def test_import_non_cached(erepo_dir, tmp_dir, dvc, scm): with erepo_dir.chdir(): erepo_dir.dvc.run( - cmd=f"echo hello > {src}", outs_no_cache=[src], single_stage=True, + cmd=f"echo hello > {src}", outs_no_cache=[src], single_stage=True ) erepo_dir.scm_add( @@ -444,7 +444,7 @@ def test_import_subrepos(tmp_dir, erepo_dir, dvc, scm, is_dvc, files): key = next(iter(files)) path = str((subrepo / key).relative_to(erepo_dir)) - stage = dvc.imp(os.fspath(erepo_dir), path, out="out",) + stage = dvc.imp(os.fspath(erepo_dir), path, out="out") assert (tmp_dir / "out").read_text() == files[key] assert stage.deps[0].def_path == path @@ -540,7 +540,7 @@ def test_import_with_jobs(mocker, dvc, erepo_dir): "file2": "file2", "file3": "file3", "file4": "file4", - }, + } }, commit="init", ) diff --git a/tests/func/test_live.py b/tests/func/test_live.py index 54134c4aa..8975a8e70 100644 --- a/tests/func/test_live.py +++ b/tests/func/test_live.py @@ -212,28 +212,13 @@ def test_live_checkpoints_resume( checkpoint_resume = first(results) dvc.experiments.run( - stage.addressing, checkpoint_resume=checkpoint_resume, tmp_dir=False, + stage.addressing, checkpoint_resume=checkpoint_resume, tmp_dir=False ) results = dvc.experiments.show() - assert checkpoints_metric(results, "logs.json", "step") == [ - 3, - 2, - 1, - 0, - ] - assert checkpoints_metric(results, "logs.json", "metric1") == [ - 4, - 3, - 2, - 1, - ] - assert checkpoints_metric(results, "logs.json", "metric2") == [ - 8, - 6, - 4, - 2, - ] + assert checkpoints_metric(results, "logs.json", "step") == [3, 2, 1, 0] + assert checkpoints_metric(results, "logs.json", "metric1") == [4, 3, 2, 1] + assert checkpoints_metric(results, "logs.json", "metric2") == [8, 6, 4, 2] def test_dvc_generates_html_during_run(tmp_dir, dvc, mocker, live_stage): diff --git a/tests/func/test_lockfile.py b/tests/func/test_lockfile.py index c7d9eb6dd..eadc48eff 100644 --- a/tests/func/test_lockfile.py +++ b/tests/func/test_lockfile.py @@ -207,7 +207,7 @@ def test_migrates_v1_lockfile_to_v2_during_dump( @pytest.mark.parametrize( - "version_info", [{"schema": "1.1"}, {"schema": "2.1"}, {"schema": "3.0"}], + "version_info", [{"schema": "1.1"}, {"schema": "2.1"}, {"schema": "3.0"}] ) def test_lockfile_invalid_versions(tmp_dir, dvc, version_info): lockdata = {**version_info, "stages": {"foo": {"cmd": "echo foo"}}} diff --git a/tests/func/test_ls.py b/tests/func/test_ls.py index 812e4fbbc..61eb95e39 100644 --- a/tests/func/test_ls.py +++ b/tests/func/test_ls.py @@ -166,7 +166,7 @@ def test_ls_repo_with_path_subdir_dvc_only(tmp_dir, dvc, scm): path = os.path.join("data", "subcontent") files = Repo.ls(os.fspath(tmp_dir), path, dvc_only=True) - match_files(files, ((("data.xml",), True), (("statistics",), False),)) + match_files(files, ((("data.xml",), True), (("statistics",), False))) def test_ls_repo_with_path_subdir_dvc_only_recursive(tmp_dir, dvc, scm): @@ -176,7 +176,7 @@ def test_ls_repo_with_path_subdir_dvc_only_recursive(tmp_dir, dvc, scm): path = os.path.join("data", "subcontent") files = Repo.ls(os.fspath(tmp_dir), path, dvc_only=True, recursive=True) match_files( - files, ((("data.xml",), True), (("statistics", "data.csv"), True),) + files, ((("data.xml",), True), (("statistics", "data.csv"), True)) ) diff --git a/tests/func/test_merge_driver.py b/tests/func/test_merge_driver.py index 7149bc42b..873954779 100644 --- a/tests/func/test_merge_driver.py +++ b/tests/func/test_merge_driver.py @@ -33,12 +33,12 @@ def _gen(tmp_dir, struct, name): "subdir": {"foo": "foo", "bar": "bar", "baz": "baz"}, }, ), - ({}, {"foo": "foo"}, {"bar": "bar"}, {"foo": "foo", "bar": "bar"},), - ({}, {}, {"bar": "bar"}, {"bar": "bar"},), - ({}, {"foo": "foo"}, {}, {"foo": "foo"},), - (None, {"foo": "foo"}, {"bar": "bar"}, {"foo": "foo", "bar": "bar"},), - (None, None, {"bar": "bar"}, {"bar": "bar"},), - (None, {"foo": "foo"}, None, {"foo": "foo"},), + ({}, {"foo": "foo"}, {"bar": "bar"}, {"foo": "foo", "bar": "bar"}), + ({}, {}, {"bar": "bar"}, {"bar": "bar"}), + ({}, {"foo": "foo"}, {}, {"foo": "foo"}), + (None, {"foo": "foo"}, {"bar": "bar"}, {"foo": "foo", "bar": "bar"}), + (None, None, {"bar": "bar"}, {"bar": "bar"}), + (None, {"foo": "foo"}, None, {"foo": "foo"}), ], ) def test_merge(tmp_dir, dvc, ancestor, our, their, merged): diff --git a/tests/func/test_odb.py b/tests/func/test_odb.py index 102975fa7..464314a40 100644 --- a/tests/func/test_odb.py +++ b/tests/func/test_odb.py @@ -186,9 +186,7 @@ def test_default_cache_type(dvc): @pytest.mark.skipif(os.name == "nt", reason="Not supported for Windows.") -@pytest.mark.parametrize( - "group", [False, True], -) +@pytest.mark.parametrize("group", [False, True]) def test_shared_cache(tmp_dir, dvc, group): from dvc.utils.fs import umask diff --git a/tests/func/test_remote.py b/tests/func/test_remote.py index 1f057b49e..719a17c76 100644 --- a/tests/func/test_remote.py +++ b/tests/func/test_remote.py @@ -155,9 +155,7 @@ def test_dir_hash_should_be_key_order_agnostic(tmp_dir, dvc): tree = Tree.from_list( [{"relpath": "1", "md5": "1"}, {"relpath": "2", "md5": "2"}] ) - with patch( - "dvc.objects.stage._get_tree_obj", return_value=tree, - ): + with patch("dvc.objects.stage._get_tree_obj", return_value=tree): hash1 = stage( dvc.odb.local, path_info, dvc.odb.local.fs, "md5" ).hash_info @@ -165,9 +163,7 @@ def test_dir_hash_should_be_key_order_agnostic(tmp_dir, dvc): tree = Tree.from_list( [{"md5": "1", "relpath": "1"}, {"md5": "2", "relpath": "2"}] ) - with patch( - "dvc.objects.stage._get_tree_obj", return_value=tree, - ): + with patch("dvc.objects.stage._get_tree_obj", return_value=tree): hash2 = stage( dvc.odb.local, path_info, dvc.odb.local.fs, "md5" ).hash_info diff --git a/tests/func/test_remove.py b/tests/func/test_remove.py index 5f084ed62..ff8d33f21 100644 --- a/tests/func/test_remove.py +++ b/tests/func/test_remove.py @@ -72,9 +72,7 @@ def test_cmd_remove(tmp_dir, dvc): def test_cmd_remove_gitignore_single_stage(tmp_dir, scm, dvc, run_copy): - stage = dvc.run( - name="my", cmd='echo "hello" > out', deps=[], outs=["out"], - ) + stage = dvc.run(name="my", cmd='echo "hello" > out', deps=[], outs=["out"]) assert (tmp_dir / ".gitignore").exists() diff --git a/tests/func/test_repro.py b/tests/func/test_repro.py index b2c391ce0..b9616febd 100644 --- a/tests/func/test_repro.py +++ b/tests/func/test_repro.py @@ -652,7 +652,7 @@ class TestReproDataSource(TestReproChangedData): self.assertTrue(filecmp.cmp(self.FOO, self.BAR, shallow=False)) self.assertEqual( - stages[0].outs[0].hash_info.value, file_md5(self.BAR, self.dvc.fs), + stages[0].outs[0].hash_info.value, file_md5(self.BAR, self.dvc.fs) ) diff --git a/tests/func/test_run_multistage.py b/tests/func/test_run_multistage.py index 3894d018a..c5f855a0e 100644 --- a/tests/func/test_run_multistage.py +++ b/tests/func/test_run_multistage.py @@ -169,8 +169,8 @@ def test_run_dump_on_multistage(tmp_dir, dvc, run_head): "outs": [{"foo2": {"persist": True}}], "always_changed": True, "wdir": "dir", - }, - }, + } + } } run_head( @@ -195,7 +195,7 @@ def test_run_dump_on_multistage(tmp_dir, dvc, run_head): "metrics": [{"foobar-1": {"cache": False}}], }, **data["stages"], - }, + } } diff --git a/tests/func/test_run_single_stage.py b/tests/func/test_run_single_stage.py index 40afb377f..cf032091d 100644 --- a/tests/func/test_run_single_stage.py +++ b/tests/func/test_run_single_stage.py @@ -271,9 +271,7 @@ class TestRunBadWdir(TestDvc): os.mkdir(path) path = os.path.join(path, str(uuid.uuid4())) open(path, "a").close() - self.dvc.run( - cmd="command", wdir=path, single_stage=True, - ) + self.dvc.run(cmd="command", wdir=path, single_stage=True) class TestRunBadName(TestDvc): @@ -610,7 +608,7 @@ class TestCmdRunWorkingDirectory(TestDvc): self.assertNotIn(Stage.PARAM_WDIR, d.keys()) stage = self.dvc.run( - cmd=f"echo test > {self.BAR}", outs=[self.BAR], single_stage=True, + cmd=f"echo test > {self.BAR}", outs=[self.BAR], single_stage=True ) d = load_yaml(stage.relpath) self.assertNotIn(Stage.PARAM_WDIR, d.keys()) @@ -669,7 +667,7 @@ def test_rerun_deterministic_ignore_cache(tmp_dir, run_copy, mocker): def test_rerun_callback(dvc): def run_callback(force=False): return dvc.run( - cmd="echo content > out", force=force, single_stage=True, + cmd="echo content > out", force=force, single_stage=True ) assert run_callback() is not None @@ -819,7 +817,7 @@ class TestShouldRaiseOnOverlappingOutputPaths(TestDvc): self.assertIn("The output paths:\n", error_output) self.assertIn( - f"\n'{self.DATA_DIR}'('{data_dir_stage}')\n", error_output, + f"\n'{self.DATA_DIR}'('{data_dir_stage}')\n", error_output ) self.assertIn(f"\n'{self.DATA}'('{data_stage}')\n", error_output) self.assertIn( @@ -951,9 +949,7 @@ def test_should_raise_on_stage_output(tmp_dir, dvc, run_copy): run_copy("foo", "name.dvc", single_stage=True) -@pytest.mark.parametrize( - "metrics_type", ["metrics", "metrics_no_cache"], -) +@pytest.mark.parametrize("metrics_type", ["metrics", "metrics_no_cache"]) def test_metrics_dir(tmp_dir, dvc, caplog, run_copy_metrics, metrics_type): copyargs = {metrics_type: ["dir_metric"]} tmp_dir.gen({"dir": {"file": "content"}}) diff --git a/tests/func/test_scm.py b/tests/func/test_scm.py index 0229f25ee..bba0c17d8 100644 --- a/tests/func/test_scm.py +++ b/tests/func/test_scm.py @@ -253,7 +253,7 @@ reason = """libgit2 stash_save() is flaky on linux when run inside pytest pytest.param( None, marks=pytest.mark.xfail( - sys.platform == "linux", raises=AssertionError, reason=reason, + sys.platform == "linux", raises=AssertionError, reason=reason ), ), "refs/foo/stash", diff --git a/tests/func/test_stage_load.py b/tests/func/test_stage_load.py index d33a47b98..de3f6b89d 100644 --- a/tests/func/test_stage_load.py +++ b/tests/func/test_stage_load.py @@ -52,19 +52,12 @@ def test_collect(tmp_dir, scm, dvc, run_copy): "foobar" } assert collect_outs("copy-foo-foobar") == {"foobar"} - assert collect_outs("copy-foo-foobar", with_deps=True) == { - "foobar", - "foo", - } + assert collect_outs("copy-foo-foobar", with_deps=True) == {"foobar", "foo"} assert collect_outs("copy-foo-foobar", recursive=True) == {"foobar"} run_copy("foobar", "baz", name="copy-foobar-baz") assert collect_outs("dvc.yaml") == {"foobar", "baz"} - assert collect_outs("dvc.yaml", with_deps=True) == { - "foobar", - "baz", - "foo", - } + assert collect_outs("dvc.yaml", with_deps=True) == {"foobar", "baz", "foo"} def test_collect_dir_recursive(tmp_dir, dvc, run_head): @@ -260,12 +253,15 @@ def test_collect_granular_with_not_existing_output_or_stage_name(tmp_dir, dvc): def test_collect_granular_with_deps(tmp_dir, dvc, stages): - assert set( - map( - itemgetter(0), - dvc.stage.collect_granular("bar.dvc", with_deps=True), + assert ( + set( + map( + itemgetter(0), + dvc.stage.collect_granular("bar.dvc", with_deps=True), + ) ) - ) == {stages["copy-foo-bar"], stages["foo-generate"]} + == {stages["copy-foo-bar"], stages["foo-generate"]} + ) assert set( map( itemgetter(0), @@ -276,12 +272,15 @@ def test_collect_granular_with_deps(tmp_dir, dvc, stages): stages["copy-foo-bar"], stages["foo-generate"], } - assert set( - map( - itemgetter(0), - dvc.stage.collect_granular(PIPELINE_FILE, with_deps=True), + assert ( + set( + map( + itemgetter(0), + dvc.stage.collect_granular(PIPELINE_FILE, with_deps=True), + ) ) - ) == set(stages.values()) + == set(stages.values()) + ) def test_collect_granular_same_output_name_stage_name(tmp_dir, dvc, run_copy): diff --git a/tests/func/test_state.py b/tests/func/test_state.py index 166f94d85..ed2fa77b6 100644 --- a/tests/func/test_state.py +++ b/tests/func/test_state.py @@ -65,9 +65,15 @@ def test_get_unused_links(tmp_dir, dvc): assert set(dvc.state.get_unused_links([], dvc.fs)) == {"foo", "bar"} assert set(dvc.state.get_unused_links(links[:1], dvc.fs)) == {"bar"} assert set(dvc.state.get_unused_links(links, dvc.fs)) == set() - assert set( - dvc.state.get_unused_links( - (links[:1] + [os.path.join(dvc.root_dir, "not-existing-file")]), - dvc.fs, + assert ( + set( + dvc.state.get_unused_links( + ( + links[:1] + + [os.path.join(dvc.root_dir, "not-existing-file")] + ), + dvc.fs, + ) ) - ) == {"bar"} + == {"bar"} + ) diff --git a/tests/func/test_update.py b/tests/func/test_update.py index 51ef07281..0055f3cf9 100644 --- a/tests/func/test_update.py +++ b/tests/func/test_update.py @@ -7,9 +7,7 @@ from dvc.exceptions import InvalidArgumentError from tests.unit.fs.test_repo import make_subrepo -@pytest.mark.parametrize( - "cached", [True, False], -) +@pytest.mark.parametrize("cached", [True, False]) def test_update_import(tmp_dir, dvc, erepo_dir, cached): gen = erepo_dir.dvc_gen if cached else erepo_dir.scm_gen @@ -241,10 +239,7 @@ def test_update_recursive(tmp_dir, dvc, erepo_dir): tmp_dir.gen({"dir": {"subdir": {}}}) stage1 = dvc.imp( - os.fspath(erepo_dir), - "foo1", - os.path.join("dir", "foo1"), - rev="branch", + os.fspath(erepo_dir), "foo1", os.path.join("dir", "foo1"), rev="branch" ) stage2 = dvc.imp( os.fspath(erepo_dir), diff --git a/tests/remotes/__init__.py b/tests/remotes/__init__.py index a901bb781..bd98b9da5 100644 --- a/tests/remotes/__init__.py +++ b/tests/remotes/__init__.py @@ -87,7 +87,7 @@ def docker_services( from pytest_docker.plugin import DockerComposeExecutor, Services executor = DockerComposeExecutor( - docker_compose_file, docker_compose_project_name, + docker_compose_file, docker_compose_project_name ) # making sure we don't accidentally launch docker-compose in parallel, diff --git a/tests/remotes/azure.py b/tests/remotes/azure.py index c288302a5..8a4c4a32d 100644 --- a/tests/remotes/azure.py +++ b/tests/remotes/azure.py @@ -100,8 +100,5 @@ def azure_server(test_config, docker_compose, docker_services): def azure(azure_server): url = f"azure://{TEST_AZURE_CONTAINER}/{uuid.uuid4()}" ret = Azure(url) - ret.config = { - "url": url, - "connection_string": azure_server, - } + ret.config = {"url": url, "connection_string": azure_server} return ret diff --git a/tests/remotes/gdrive.py b/tests/remotes/gdrive.py index 17dff1acb..f4c452ba7 100644 --- a/tests/remotes/gdrive.py +++ b/tests/remotes/gdrive.py @@ -34,10 +34,7 @@ def _gdrive_retry(func): except (ValueError, LookupError): return False - return reason in [ - "userRateLimitExceeded", - "rateLimitExceeded", - ] + return reason in ["userRateLimitExceeded", "rateLimitExceeded"] # 16 tries, start at 0.5s, multiply by golden ratio, cap at 20s return retry( diff --git a/tests/remotes/gs.py b/tests/remotes/gs.py index 0418fc94e..2d9241301 100644 --- a/tests/remotes/gs.py +++ b/tests/remotes/gs.py @@ -39,10 +39,7 @@ class GCP(Base, CloudURLInfo): @cached_property def config(self): - return { - "url": self.url, - "credentialpath": TEST_GCP_CREDS_FILE, - } + return {"url": self.url, "credentialpath": TEST_GCP_CREDS_FILE} @staticmethod def _get_storagepath(): diff --git a/tests/remotes/s3.py b/tests/remotes/s3.py index d52cb0afe..d3fc9ab88 100644 --- a/tests/remotes/s3.py +++ b/tests/remotes/s3.py @@ -84,9 +84,7 @@ class S3(Base, CloudURLInfo): assert parents def write_bytes(self, contents): - self._s3.put_object( - Bucket=self.bucket, Key=self.path, Body=contents, - ) + self._s3.put_object(Bucket=self.bucket, Key=self.path, Body=contents) def read_bytes(self): data = self._s3.get_object(Bucket=self.bucket, Key=self.path) diff --git a/tests/remotes/ssh.py b/tests/remotes/ssh.py index 53d628af1..71a051a1d 100644 --- a/tests/remotes/ssh.py +++ b/tests/remotes/ssh.py @@ -46,10 +46,7 @@ class SSHMocked(Base, URLInfo): @cached_property def config(self): - return { - "url": self.url, - "keyfile": TEST_SSH_KEY_PATH, - } + return {"url": self.url, "keyfile": TEST_SSH_KEY_PATH} @contextmanager def _ssh(self): diff --git a/tests/remotes/webhdfs.py b/tests/remotes/webhdfs.py index 634fcce79..4b744ed49 100644 --- a/tests/remotes/webhdfs.py +++ b/tests/remotes/webhdfs.py @@ -143,11 +143,7 @@ class FakeClient: root = posixpath.join( hdfs_path, os.path.relpath(local_root, local_path) ) - yield ( - root, - dnames, - fnames, - ) + yield (root, dnames, fnames) def delete(self, hdfs_path): return self._path(hdfs_path).unlink() diff --git a/tests/unit/command/test_config.py b/tests/unit/command/test_config.py index 43f6ce78e..b89683833 100644 --- a/tests/unit/command/test_config.py +++ b/tests/unit/command/test_config.py @@ -24,7 +24,7 @@ def test_config_formatter(): @pytest.mark.parametrize( - "name", ["way.too.long", "no_option", "remote.way.too.long"], + "name", ["way.too.long", "no_option", "remote.way.too.long"] ) def test_config_bad_name(name): with pytest.raises(DvcParserError): diff --git a/tests/unit/command/test_dag.py b/tests/unit/command/test_dag.py index 42f1fcf8f..f351585fb 100644 --- a/tests/unit/command/test_dag.py +++ b/tests/unit/command/test_dag.py @@ -58,21 +58,13 @@ def test_build_target(repo): def test_build_target_with_outs(repo): G = _build(repo, target="3", outs=True) assert set(G.nodes()) == {"a", "b", "h", "i"} - assert set(G.edges()) == { - ("i", "a"), - ("i", "b"), - ("h", "a"), - ("h", "b"), - } + assert set(G.edges()) == {("i", "a"), ("i", "b"), ("h", "a"), ("h", "b")} def test_build_granular_target_with_outs(repo): G = _build(repo, target="h", outs=True) assert set(G.nodes()) == {"a", "b", "h"} - assert set(G.edges()) == { - ("h", "a"), - ("h", "b"), - } + assert set(G.edges()) == {("h", "a"), ("h", "b")} def test_build_full(repo): diff --git a/tests/unit/command/test_experiments.py b/tests/unit/command/test_experiments.py index af6805a2a..f06929f10 100644 --- a/tests/unit/command/test_experiments.py +++ b/tests/unit/command/test_experiments.py @@ -260,6 +260,4 @@ def test_experiments_remove(dvc, scm, mocker): assert cmd.run() == 0 - m.assert_called_once_with( - cmd.repo, exp_names=[], queue=True, - ) + m.assert_called_once_with(cmd.repo, exp_names=[], queue=True) diff --git a/tests/unit/command/test_live.py b/tests/unit/command/test_live.py index 071d1f5b3..1ad747ae3 100644 --- a/tests/unit/command/test_live.py +++ b/tests/unit/command/test_live.py @@ -22,9 +22,7 @@ def test_live_diff(dvc, mocker): assert cmd.run() == 0 - m.assert_called_once_with( - target="target", revs=["HEAD", "rev1"], - ) + m.assert_called_once_with(target="target", revs=["HEAD", "rev1"]) def test_live_show(dvc, mocker): diff --git a/tests/unit/command/test_params.py b/tests/unit/command/test_params.py index 0b3f0e197..87fd819a9 100644 --- a/tests/unit/command/test_params.py +++ b/tests/unit/command/test_params.py @@ -50,7 +50,7 @@ def test_params_diff_from_cli(dvc, mocker): assert cmd.run() == 0 params_diff.assert_called_once_with( - cmd.repo, a_rev=None, b_rev=None, all=False, targets=None, deps=False, + cmd.repo, a_rev=None, b_rev=None, all=False, targets=None, deps=False ) show_diff_mock.assert_called_once_with( {}, title="Param", markdown=False, no_path=False, show_changes=False diff --git a/tests/unit/command/test_plots.py b/tests/unit/command/test_plots.py index 510d699b1..6a88de8d2 100644 --- a/tests/unit/command/test_plots.py +++ b/tests/unit/command/test_plots.py @@ -87,7 +87,7 @@ def test_plots_show_vega(dvc, mocker): assert cmd.run() == 0 m.assert_called_once_with( - targets=["datafile"], props={"template": "template", "header": False}, + targets=["datafile"], props={"template": "template", "header": False} ) diff --git a/tests/unit/dependency/test_params.py b/tests/unit/dependency/test_params.py index 147af295e..48e8fc2f1 100644 --- a/tests/unit/dependency/test_params.py +++ b/tests/unit/dependency/test_params.py @@ -5,12 +5,7 @@ from dvc.dependency.param import BadParamFileError, MissingParamsError from dvc.stage import Stage from dvc.utils.serialize import dump_toml, dump_yaml, load_yaml -PARAMS = { - "foo": 1, - "bar": 53.135, - "baz": "str", - "qux": None, -} +PARAMS = {"foo": 1, "bar": 53.135, "baz": "str", "qux": None} DEFAULT_PARAMS_FILE = ParamsDependency.DEFAULT_PARAMS_FILE @@ -63,10 +58,7 @@ def test_loadd_from(dvc): def test_dumpd_with_info(dvc): dep = ParamsDependency(Stage(dvc), None, PARAMS) - assert dep.dumpd() == { - "path": DEFAULT_PARAMS_FILE, - "params": PARAMS, - } + assert dep.dumpd() == {"path": DEFAULT_PARAMS_FILE, "params": PARAMS} def test_dumpd_without_info(dvc): @@ -161,15 +153,13 @@ def test_read_params_py(tmp_dir, dvc): } tmp_dir.gen( - parameters_file, "class Train:\n foo = 'val1'\n bar = 'val2'\n", + parameters_file, "class Train:\n foo = 'val1'\n bar = 'val2'\n" ) dep = ParamsDependency(Stage(dvc), parameters_file, ["Train.foo"]) assert dep.read_params() == {"Train.foo": "val1"} dep = ParamsDependency(Stage(dvc), parameters_file, ["Train"]) - assert dep.read_params() == { - "Train": {"foo": "val1", "bar": "val2"}, - } + assert dep.read_params() == {"Train": {"foo": "val1", "bar": "val2"}} tmp_dir.gen( parameters_file, diff --git a/tests/unit/fs/test_dvc.py b/tests/unit/fs/test_dvc.py index 752018b60..d397c1722 100644 --- a/tests/unit/fs/test_dvc.py +++ b/tests/unit/fs/test_dvc.py @@ -230,14 +230,14 @@ def test_get_hash_granular(tmp_dir, dvc): subdir = PathInfo(tmp_dir) / "dir" / "subdir" assert fs.info(subdir).get("md5") is None assert stage(dvc.odb.local, subdir, fs, "md5").hash_info == HashInfo( - "md5", "af314506f1622d107e0ed3f14ec1a3b5.dir", + "md5", "af314506f1622d107e0ed3f14ec1a3b5.dir" ) assert ( fs.info(subdir / "data")["md5"] == "8d777f385d3dfec8815d20f7496026dc" ) assert stage( dvc.odb.local, subdir / "data", fs, "md5" - ).hash_info == HashInfo("md5", "8d777f385d3dfec8815d20f7496026dc",) + ).hash_info == HashInfo("md5", "8d777f385d3dfec8815d20f7496026dc") def test_get_hash_dirty_file(tmp_dir, dvc): diff --git a/tests/unit/fs/test_repo.py b/tests/unit/fs/test_repo.py index bc80196d1..60e81b4c4 100644 --- a/tests/unit/fs/test_repo.py +++ b/tests/unit/fs/test_repo.py @@ -219,9 +219,7 @@ def test_walk_dirty(tmp_dir, dvc): def test_walk_dirty_cached_dir(tmp_dir, scm, dvc): - tmp_dir.dvc_gen( - {"data": {"foo": "foo", "bar": "bar"}}, commit="add data", - ) + tmp_dir.dvc_gen({"data": {"foo": "foo", "bar": "bar"}}, commit="add data") (tmp_dir / "data" / "foo").unlink() fs = RepoFileSystem(repo=dvc) @@ -338,7 +336,7 @@ def test_subrepos(tmp_dir, scm, dvc): return f with mock.patch.object( - fs, "_get_repo", side_effect=assert_fs_belongs_to_repo(subrepo1.dvc), + fs, "_get_repo", side_effect=assert_fs_belongs_to_repo(subrepo1.dvc) ): assert fs.exists(subrepo1 / "foo") is True assert fs.exists(subrepo1 / "bar") is False @@ -352,7 +350,7 @@ def test_subrepos(tmp_dir, scm, dvc): assert fs.isdvc(subrepo1 / "foo") is True with mock.patch.object( - fs, "_get_repo", side_effect=assert_fs_belongs_to_repo(subrepo2.dvc), + fs, "_get_repo", side_effect=assert_fs_belongs_to_repo(subrepo2.dvc) ): assert fs.exists(subrepo2 / "lorem") is True assert fs.exists(subrepo2 / "ipsum") is False @@ -485,8 +483,8 @@ def test_get_hash_cached_file(tmp_dir, dvc, mocker): expected = "acbd18db4cc2f85cedef654fccc4a4d8" assert fs.info(PathInfo(tmp_dir) / "foo").get("md5") is None assert stage( - dvc.odb.local, PathInfo(tmp_dir) / "foo", fs, "md5", - ).hash_info == HashInfo("md5", expected,) + dvc.odb.local, PathInfo(tmp_dir) / "foo", fs, "md5" + ).hash_info == HashInfo("md5", expected) (tmp_dir / "foo").unlink() assert fs.info(PathInfo(tmp_dir) / "foo")["md5"] == expected @@ -499,14 +497,14 @@ def test_get_hash_cached_dir(tmp_dir, dvc, mocker): expected = "8761c4e9acad696bee718615e23e22db.dir" assert fs.info(PathInfo(tmp_dir) / "dir").get("md5") is None assert stage( - dvc.odb.local, PathInfo(tmp_dir) / "dir", fs, "md5", - ).hash_info == HashInfo("md5", "8761c4e9acad696bee718615e23e22db.dir",) + dvc.odb.local, PathInfo(tmp_dir) / "dir", fs, "md5" + ).hash_info == HashInfo("md5", "8761c4e9acad696bee718615e23e22db.dir") shutil.rmtree(tmp_dir / "dir") assert fs.info(PathInfo(tmp_dir) / "dir")["md5"] == expected assert stage( - dvc.odb.local, PathInfo(tmp_dir) / "dir", fs, "md5", - ).hash_info == HashInfo("md5", "8761c4e9acad696bee718615e23e22db.dir",) + dvc.odb.local, PathInfo(tmp_dir) / "dir", fs, "md5" + ).hash_info == HashInfo("md5", "8761c4e9acad696bee718615e23e22db.dir") def test_get_hash_cached_granular(tmp_dir, dvc, mocker): @@ -517,12 +515,12 @@ def test_get_hash_cached_granular(tmp_dir, dvc, mocker): subdir = PathInfo(tmp_dir) / "dir" / "subdir" assert fs.info(subdir).get("md5") is None assert stage(dvc.odb.local, subdir, fs, "md5").hash_info == HashInfo( - "md5", "af314506f1622d107e0ed3f14ec1a3b5.dir", + "md5", "af314506f1622d107e0ed3f14ec1a3b5.dir" ) assert fs.info(subdir / "data").get("md5") is None assert stage( dvc.odb.local, subdir / "data", fs, "md5" - ).hash_info == HashInfo("md5", "8d777f385d3dfec8815d20f7496026dc",) + ).hash_info == HashInfo("md5", "8d777f385d3dfec8815d20f7496026dc") (tmp_dir / "dir" / "subdir" / "data").unlink() assert ( fs.info(subdir / "data")["md5"] == "8d777f385d3dfec8815d20f7496026dc" diff --git a/tests/unit/fs/test_s3.py b/tests/unit/fs/test_s3.py index ec323753b..5749d89e4 100644 --- a/tests/unit/fs/test_s3.py +++ b/tests/unit/fs/test_s3.py @@ -34,9 +34,7 @@ def test_init(dvc): def test_verify_ssl_default_param(dvc): - config = { - "url": url, - } + config = {"url": url} fs = S3FileSystem(**config) assert fs.fs_args["client_kwargs"]["verify"] diff --git a/tests/unit/objects/db/test_local.py b/tests/unit/objects/db/test_local.py index bde91601e..1653f138b 100644 --- a/tests/unit/objects/db/test_local.py +++ b/tests/unit/objects/db/test_local.py @@ -12,8 +12,8 @@ from dvc.remote.index import RemoteIndexNoop def test_status_download_optimization(mocker, dvc): """When comparing the status to pull a remote cache, - And the desired files to fetch are already on the local cache, - Don't check the existence of the desired files on the remote cache + And the desired files to fetch are already on the local cache, + Don't check the existence of the desired files on the remote cache """ odb = LocalObjectDB(LocalFileSystem()) diff --git a/tests/unit/output/test_local.py b/tests/unit/output/test_local.py index 59c89c25b..d758fa42a 100644 --- a/tests/unit/output/test_local.py +++ b/tests/unit/output/test_local.py @@ -79,7 +79,7 @@ class TestGetFilesNumber(TestDvc): def test_return_multiple_for_dir(self): o = self._get_output() - o.hash_info = HashInfo("md5", "12345678.dir", nfiles=2,) + o.hash_info = HashInfo("md5", "12345678.dir", nfiles=2) self.assertEqual(2, o.get_files_number()) @patch.object(LocalOutput, "is_dir_checksum", False) diff --git a/tests/unit/output/test_output.py b/tests/unit/output/test_output.py index 0dfa7f003..a60201a7c 100644 --- a/tests/unit/output/test_output.py +++ b/tests/unit/output/test_output.py @@ -75,12 +75,10 @@ def test_get_used_cache(exists, expected_message, mocker, caplog): mocker.patch.object(stage, "addressing", "stage.dvc") mocker.patch.object(stage, "wdir", ".") mocker.patch.object( - stage.repo.fs.dvcignore, "is_ignored", return_value=False, + stage.repo.fs.dvcignore, "is_ignored", return_value=False ) mocker.patch.object( - stage.repo.fs.dvcignore, - "check_ignore", - return_value=_no_match("path"), + stage.repo.fs.dvcignore, "check_ignore", return_value=_no_match("path") ) output = BaseOutput(stage, "path") diff --git a/tests/unit/remote/test_base.py b/tests/unit/remote/test_base.py index d9ca539bc..bc0064adb 100644 --- a/tests/unit/remote/test_base.py +++ b/tests/unit/remote/test_base.py @@ -83,12 +83,8 @@ def test_hashes_exist(object_exists, traverse, dvc): ) -@mock.patch.object( - ObjectDB, "list_hashes", return_value=[], -) -@mock.patch.object( - ObjectDB, "_path_to_hash", side_effect=lambda x: x, -) +@mock.patch.object(ObjectDB, "list_hashes", return_value=[]) +@mock.patch.object(ObjectDB, "_path_to_hash", side_effect=lambda x: x) def test_list_hashes_traverse(_path_to_hash, list_hashes, dvc): odb = ObjectDB(BaseFileSystem()) odb.fs.path_info = PathInfo("foo") diff --git a/tests/unit/remote/test_http.py b/tests/unit/remote/test_http.py index c9f5d19eb..3b5bda1e0 100644 --- a/tests/unit/remote/test_http.py +++ b/tests/unit/remote/test_http.py @@ -87,10 +87,7 @@ def test_custom_auth_method(dvc): def test_ssl_verify_is_enabled_by_default(dvc): - config = { - "url": "http://example.com/", - "path_info": "file.html", - } + config = {"url": "http://example.com/", "path_info": "file.html"} fs = HTTPFileSystem(**config) diff --git a/tests/unit/remote/test_index.py b/tests/unit/remote/test_index.py index 0dfed0193..26d60991e 100644 --- a/tests/unit/remote/test_index.py +++ b/tests/unit/remote/test_index.py @@ -35,9 +35,7 @@ def test_roundtrip(dvc, index): def test_clear(dvc, index): - index.update( - ["1234.dir"], ["5678"], - ) + index.update(["1234.dir"], ["5678"]) index.clear() assert first(index.hashes()) is None diff --git a/tests/unit/scm/test_git.py b/tests/unit/scm/test_git.py index 6ba80d436..3303b21b6 100644 --- a/tests/unit/scm/test_git.py +++ b/tests/unit/scm/test_git.py @@ -56,9 +56,7 @@ def test_walk_onerror(tmp_dir, scm): def onerror(exc): raise exc - tmp_dir.scm_gen( - {"foo": "foo"}, commit="init", - ) + tmp_dir.scm_gen({"foo": "foo"}, commit="init") fs = scm.get_fs("HEAD") # path does not exist @@ -334,9 +332,7 @@ def test_commit_no_verify(tmp_dir, scm, git, hook): pytest.skip() hook_file = os.path.join(".git", "hooks", hook) - tmp_dir.gen( - hook_file, "#!/usr/bin/env python\nimport sys\nsys.exit(1)", - ) + tmp_dir.gen(hook_file, "#!/usr/bin/env python\nimport sys\nsys.exit(1)") os.chmod(hook_file, stat.S_IREAD | stat.S_IWRITE | stat.S_IEXEC) tmp_dir.gen("foo", "foo") @@ -400,7 +396,7 @@ def test_checkout_index(tmp_dir, scm, git): @pytest.mark.parametrize( - "strategy, expected", [("ours", "baz"), ("theirs", "bar")], + "strategy, expected", [("ours", "baz"), ("theirs", "bar")] ) def test_checkout_index_conflicts(tmp_dir, scm, git, strategy, expected): from dvc.scm.base import MergeConflictError @@ -495,9 +491,7 @@ def test_reset(tmp_dir, scm, git): if git.test_backend == "dulwich": pytest.skip() - tmp_dir.scm_gen( - {"foo": "foo", "dir": {"baz": "baz"}}, commit="init", - ) + tmp_dir.scm_gen({"foo": "foo", "dir": {"baz": "baz"}}, commit="init") tmp_dir.gen({"foo": "bar", "dir": {"baz": "bar"}}) scm.add(["foo", os.path.join("dir", "baz")]) diff --git a/tests/unit/stage/test_cache.py b/tests/unit/stage/test_cache.py index 03112e31e..99d9f124e 100644 --- a/tests/unit/stage/test_cache.py +++ b/tests/unit/stage/test_cache.py @@ -180,7 +180,7 @@ def test_shared_stage_cache(tmp_dir, dvc, run_copy): run_copy("foo", "bar", name="copy-foo-bar") - parent_cache_dir = os.path.join(dvc.stage_cache.cache_dir, "88",) + parent_cache_dir = os.path.join(dvc.stage_cache.cache_dir, "88") cache_dir = os.path.join( parent_cache_dir, "883395068439203a9de3d1e1649a16e9027bfd1ab5dab4f438d321c4a928b328", diff --git a/tests/unit/stage/test_run.py b/tests/unit/stage/test_run.py index 972d38b20..c464b8adc 100644 --- a/tests/unit/stage/test_run.py +++ b/tests/unit/stage/test_run.py @@ -18,7 +18,5 @@ def test_run_stage_dry(caplog, cmd, expected): stage = Stage(None, "stage.dvc", cmd=cmd) run_stage(stage, dry=True) - expected.insert( - 0, "Running stage 'stage.dvc':", - ) + expected.insert(0, "Running stage 'stage.dvc':") assert caplog.messages == expected diff --git a/tests/unit/test_compare.py b/tests/unit/test_compare.py index b9645d518..e5985da76 100644 --- a/tests/unit/test_compare.py +++ b/tests/unit/test_compare.py @@ -291,7 +291,7 @@ def test_metrics_show_with_no_revision(): def test_metrics_show_with_non_dict_values(): - td = metrics_table({"branch_1": {"metrics.json": 1}}, all_branches=True,) + td = metrics_table({"branch_1": {"metrics.json": 1}}, all_branches=True) assert td.as_dict() == [ {"Revision": "branch_1", "Path": "metrics.json", "": "1"} ] @@ -451,7 +451,7 @@ def test_metrics_show_default(capsys): "a.d.e": {"old": 3, "new": 4, "diff": 1}, "a.b.c": {"old": 1, "new": 2, "diff": 1}, } - }, + } ) out, _ = capsys.readouterr() assert out == textwrap.dedent( diff --git a/tests/unit/test_ignore.py b/tests/unit/test_ignore.py index e897d83b4..8ec2cb453 100644 --- a/tests/unit/test_ignore.py +++ b/tests/unit/test_ignore.py @@ -118,7 +118,7 @@ def mock_dvcignore(dvcignore_path, patterns): # same as pattern "foo". # "**/foo/bar" matches file or directory "bar" anywhere that is # directly under directory "foo". - (os.path.join("rel", "p", "p2", "to_ignore"), ["**/to_ignore"], True,), + (os.path.join("rel", "p", "p2", "to_ignore"), ["**/to_ignore"], True), ( os.path.join("rel", "p", "p2", "to_ignore"), ["**/p2/to_ignore"], @@ -132,8 +132,8 @@ def mock_dvcignore(dvcignore_path, patterns): # A trailing "/**" matches everything inside. # For example, "abc/**" matches all files inside directory "abc", # relative to the location of the .gitignore file, with infinite depth. - (os.path.join("rel", "p", "p2", "to_ignore"), ["rel/**"], True,), - (os.path.join("rel", "p", "p2", "to_ignore"), ["p/**"], False,), + (os.path.join("rel", "p", "p2", "to_ignore"), ["rel/**"], True), + (os.path.join("rel", "p", "p2", "to_ignore"), ["p/**"], False), ( os.path.join("rel", "path", "path2", "dont_ignore"), ["rel/**"], @@ -142,7 +142,7 @@ def mock_dvcignore(dvcignore_path, patterns): # A slash followed by two consecutive asterisks then a slash matches # zero or more directories. # For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on. - (os.path.join("rel", "p", "to_ignore"), ["rel/**/to_ignore"], True,), + (os.path.join("rel", "p", "to_ignore"), ["rel/**/to_ignore"], True), ( os.path.join("rel", "p", "p2", "to_ignore"), ["rel/**/to_ignore"], diff --git a/tests/unit/test_interpolate.py b/tests/unit/test_interpolate.py index 9e1f6d07c..530f63576 100644 --- a/tests/unit/test_interpolate.py +++ b/tests/unit/test_interpolate.py @@ -6,7 +6,7 @@ from dvc.parsing.context import Context, recurse_not_a_node @pytest.mark.parametrize( - "template, var", [("${value}", "value"), ("${ item }", "item")], + "template, var", [("${value}", "value"), ("${ item }", "item")] ) @pytest.mark.parametrize( "data", [True, 12, pi, None, False, 0, "0", "123", "Foobar", "", inf, 3e4] diff --git a/tests/unit/test_lockfile.py b/tests/unit/test_lockfile.py index bbf33d18a..32055f805 100644 --- a/tests/unit/test_lockfile.py +++ b/tests/unit/test_lockfile.py @@ -46,7 +46,7 @@ def test_stage_dump_with_deps_and_outs(tmp_dir, dvc): def test_stage_overwrites_if_already_exists(tmp_dir, dvc): - lockfile = Lockfile(dvc, "path.lock",) + lockfile = Lockfile(dvc, "path.lock") stage = PipelineStage(name="s2", repo=dvc, path="path", cmd="command2") lockfile.dump(stage) stage = PipelineStage(name="s2", repo=dvc, path="path", cmd="command3") diff --git a/tests/unit/ui/test_table.py b/tests/unit/ui/test_table.py index 7087c86ba..96a2160cf 100644 --- a/tests/unit/ui/test_table.py +++ b/tests/unit/ui/test_table.py @@ -62,7 +62,7 @@ def test_plain_pager(mocker: MockerFixture): def test_plain_headerless(capsys: CaptureFixture[str]): - ui.table([("foo", "bar"), ("foo1", "bar1"), ("foo2", "bar2")],) + ui.table([("foo", "bar"), ("foo1", "bar1"), ("foo2", "bar2")]) captured = capsys.readouterr() assert captured.out == textwrap.dedent( """\ @@ -88,7 +88,7 @@ def test_rich_simple(capsys: CaptureFixture[str]): def test_rich_headerless(capsys: CaptureFixture[str]): ui.table( - [("foo", "bar"), ("foo1", "bar1"), ("foo2", "bar2")], rich_table=True, + [("foo", "bar"), ("foo1", "bar1"), ("foo2", "bar2")], rich_table=True ) captured = capsys.readouterr() assert [