From d1910da9a89f4bf65cd65f9006f50ac5e1c9bdf3 Mon Sep 17 00:00:00 2001 From: Purnendu Chakraborty Date: Thu, 23 May 2024 15:11:56 -0400 Subject: [PATCH] Removed unused imports etc. --- src/mepo/command/changed-files.py | 3 --- src/mepo/command/checkout-if-exists.py | 1 - src/mepo/command/commit.py | 8 +++++--- src/mepo/command/compare.py | 2 +- src/mepo/command/develop.py | 2 +- src/mepo/command/diff.py | 3 --- src/mepo/command/init.py | 2 +- src/mepo/command/reset.py | 8 ++++---- src/mepo/command/restore-state.py | 2 -- src/mepo/command/tag_create.py | 8 +++++--- src/mepo/command/unstage.py | 1 - src/mepo/component.py | 3 --- src/mepo/state.py | 4 ---- 13 files changed, 17 insertions(+), 30 deletions(-) diff --git a/src/mepo/command/changed-files.py b/src/mepo/command/changed-files.py index bc8d38c3..4d2593ad 100644 --- a/src/mepo/command/changed-files.py +++ b/src/mepo/command/changed-files.py @@ -1,10 +1,7 @@ import os -from shutil import get_terminal_size from ..state import MepoState -from ..component import MepoVersion -from ..utilities import colors from ..utilities import verify from ..utilities.version import version_to_string from ..utilities.version import sanitize_version_string diff --git a/src/mepo/command/checkout-if-exists.py b/src/mepo/command/checkout-if-exists.py index ec162587..bb596284 100644 --- a/src/mepo/command/checkout-if-exists.py +++ b/src/mepo/command/checkout-if-exists.py @@ -1,5 +1,4 @@ from ..state import MepoState -from ..utilities import verify from ..git import GitRepository from ..utilities import colors diff --git a/src/mepo/command/commit.py b/src/mepo/command/commit.py index 3175eadd..d56768a6 100644 --- a/src/mepo/command/commit.py +++ b/src/mepo/command/commit.py @@ -1,3 +1,7 @@ +import os +import tempfile +import subprocess + from ..state import MepoState from ..utilities import verify from ..git import GitRepository @@ -5,9 +9,6 @@ from .stage import stage_files -# Popping up an EDITOR is based on https://stackoverflow.com/a/39989442 -import os, tempfile, subprocess - def run(args): allcomps = MepoState.read_state() @@ -17,6 +18,7 @@ def run(args): tf_file = None # Pop up an editor if a message is not provided + # Popping up an EDITOR is based on https://stackoverflow.com/a/39989442 if not args.message: EDITOR = get_git_editor() initial_message = b"" # set up the file diff --git a/src/mepo/command/compare.py b/src/mepo/command/compare.py index b4f737d1..84fe6dae 100644 --- a/src/mepo/command/compare.py +++ b/src/mepo/command/compare.py @@ -15,7 +15,7 @@ def run(args): allcomps = MepoState.read_state() if not any_differing_repos(allcomps): - print(f"No repositories have changed") + print("No repositories have changed") else: max_namelen, max_origlen = calculate_header_lengths(allcomps, args.all) print_header(max_namelen, max_origlen) diff --git a/src/mepo/command/develop.py b/src/mepo/command/develop.py index eb611274..e679955e 100644 --- a/src/mepo/command/develop.py +++ b/src/mepo/command/develop.py @@ -21,4 +21,4 @@ def run(args): ) ) git.checkout(comp.develop) - output = git.pull() + _ = git.pull() diff --git a/src/mepo/command/diff.py b/src/mepo/command/diff.py index 118d98f3..e32de83e 100644 --- a/src/mepo/command/diff.py +++ b/src/mepo/command/diff.py @@ -1,6 +1,3 @@ -import sys -import time -import multiprocessing as mp import os from shutil import get_terminal_size diff --git a/src/mepo/command/init.py b/src/mepo/command/init.py index b28eb7f9..83d15e3d 100644 --- a/src/mepo/command/init.py +++ b/src/mepo/command/init.py @@ -17,7 +17,7 @@ def run(args): else: style = None - allcomps = MepoState.initialize(args.registry, style) + _ = MepoState.initialize(args.registry, style) if not style: print(f"Initializing mepo using {args.registry}") diff --git a/src/mepo/command/reset.py b/src/mepo/command/reset.py index 1f360250..87cfce6d 100644 --- a/src/mepo/command/reset.py +++ b/src/mepo/command/reset.py @@ -32,7 +32,7 @@ def run(args): # will ask them to confirm that they want to reset the project if not args.force and not args.dry_run: print( - f"Are you sure you want to reset the project? If so, type 'yes' and press enter.", + "Are you sure you want to reset the project? If so, type 'yes' and press enter.", end=" ", ) answer = input() @@ -58,12 +58,12 @@ def run(args): print(f"dry-run only. Not removing {relpath}") # Next, we need to remove the .mepo directory - print(f"Removing mepo state", end="...") + print("Removing mepo state", end="...") if not args.dry_run: shutil.rmtree(MepoState.get_dir()) print("done.") else: - print(f"dry-run only. Not removing mepo state") + print("dry-run only. Not removing mepo state") # If they pass in the --reclone flag, then we will re-clone all the subrepos if args.reclone: @@ -88,7 +88,7 @@ def run(args): mepo_clone_run(clone_args) print("Recloning done.") else: - print(f"Dry-run only. Not re-cloning all subrepos") + print("Dry-run only. Not re-cloning all subrepos") def _get_relative_path(local_path): diff --git a/src/mepo/command/restore-state.py b/src/mepo/command/restore-state.py index e4bd34e1..c08aac1f 100644 --- a/src/mepo/command/restore-state.py +++ b/src/mepo/command/restore-state.py @@ -1,5 +1,3 @@ -import sys -import time import multiprocessing as mp from ..state import MepoState diff --git a/src/mepo/command/tag_create.py b/src/mepo/command/tag_create.py index 427cc5e2..b54ffc83 100644 --- a/src/mepo/command/tag_create.py +++ b/src/mepo/command/tag_create.py @@ -1,11 +1,12 @@ +import os +import tempfile +import subprocess + from ..state import MepoState from ..utilities import verify from ..git import GitRepository from ..git import get_editor as get_git_editor -# Popping up an EDITOR is based on https://stackoverflow.com/a/39989442 -import os, tempfile, subprocess - def run(args): allcomps = MepoState.read_state() @@ -22,6 +23,7 @@ def run(args): if create_annotated_tag: # Pop up an editor if a message is not provided + # Popping up an EDITOR is based on https://stackoverflow.com/a/39989442 if not args.message: EDITOR = get_git_editor() initial_message = b"" # set up the file diff --git a/src/mepo/command/unstage.py b/src/mepo/command/unstage.py index f8ffd91b..9bc661c3 100644 --- a/src/mepo/command/unstage.py +++ b/src/mepo/command/unstage.py @@ -1,5 +1,4 @@ from ..state import MepoState -from ..utilities import shellcmd from ..utilities import verify from ..git import GitRepository diff --git a/src/mepo/component.py b/src/mepo/component.py index b1772278..ef732ba1 100644 --- a/src/mepo/component.py +++ b/src/mepo/component.py @@ -1,12 +1,9 @@ import os import shlex -import textwrap -from collections import namedtuple from urllib.parse import urlparse from .utilities import shellcmd -from .utilities import mepoconfig from .utilities.version import MepoVersion # This will be used to store the "final nodes" from each subrepo diff --git a/src/mepo/state.py b/src/mepo/state.py index 827c10e5..7768f60d 100644 --- a/src/mepo/state.py +++ b/src/mepo/state.py @@ -5,16 +5,12 @@ import stat import pickle -from pathlib import Path - from .registry import Registry from .component import MepoComponent -from .utilities import shellcmd from .utilities import colors from .utilities.exceptions import StateDoesNotExistError from .utilities.exceptions import StateAlreadyInitializedError from .utilities.chdir import chdir as mepo_chdir -from .utilities.version import MepoVersion class MepoState(object):