From 752aa6af5b00a423a295b99d585944c8d81555c8 Mon Sep 17 00:00:00 2001 From: DashBing Date: Mon, 21 Aug 2023 11:21:54 +0800 Subject: [PATCH] fix all thefuck/* --- thefuck/entrypoints/alias.py | 6 ++++-- thefuck/entrypoints/main.py | 6 ++++-- thefuck/entrypoints/not_configured.py | 16 +++++++++++----- thefuck/output_readers/rerun.py | 20 ++++++++++++++------ 4 files changed, 33 insertions(+), 15 deletions(-) diff --git a/thefuck/entrypoints/alias.py b/thefuck/entrypoints/alias.py index c7094d4..216d5f8 100644 --- a/thefuck/entrypoints/alias.py +++ b/thefuck/entrypoints/alias.py @@ -7,8 +7,10 @@ from ..utils import which def _get_alias(known_args): if six.PY2: - warn("The Fuck will drop Python 2 support soon, more details " - "https://github.com/nvbn/thefuck/issues/685") + warn( + "The Fuck will drop Python 2 support soon, more details " + "https://github.com/nvbn/thefuck/issues/685" + ) alias = shell.app_alias(known_args.alias) diff --git a/thefuck/entrypoints/main.py b/thefuck/entrypoints/main.py index 856a3d2..692d4b6 100644 --- a/thefuck/entrypoints/main.py +++ b/thefuck/entrypoints/main.py @@ -20,8 +20,10 @@ def main(): if known_args.help: parser.print_help() elif known_args.version: - logs.version(get_installation_version(), - sys.version.split()[0], shell.info()) + logs.version( + get_installation_version(), + sys.version.split()[0], shell.info() + ) # It's important to check if an alias is being requested before checking if # `TF_HISTORY` is in `os.environ`, otherwise it might mess with subshells. # Check https://github.com/nvbn/thefuck/issues/921 for reference diff --git a/thefuck/entrypoints/not_configured.py b/thefuck/entrypoints/not_configured.py index f5d7e85..001cc70 100644 --- a/thefuck/entrypoints/not_configured.py +++ b/thefuck/entrypoints/not_configured.py @@ -28,9 +28,13 @@ def _get_shell_pid(): def _get_not_configured_usage_tracker_path(): """Returns path of special file where we store latest shell pid.""" - return Path(gettempdir()).joinpath(u'thefuck.last_not_configured_run_{}'.format( - getpass.getuser(), - )) + return ( + Path(gettempdir()).joinpath( + u'thefuck.last_not_configured_run_{}'.format( + getpass.getuser(), + ) + ) + ) def _record_first_run(): @@ -68,8 +72,10 @@ def _is_second_run(): if not (isinstance(info, dict) and info.get('pid') == current_pid): return False - return (_get_previous_command() == 'fuck' or - time.time() - info.get('time', 0) < const.CONFIGURATION_TIMEOUT) + return ( + _get_previous_command() == 'fuck' or + time.time() - info.get('time', 0) < const.CONFIGURATION_TIMEOUT + ) def _is_already_configured(configuration_details): diff --git a/thefuck/output_readers/rerun.py b/thefuck/output_readers/rerun.py index b7ffe24..6be2d73 100644 --- a/thefuck/output_readers/rerun.py +++ b/thefuck/output_readers/rerun.py @@ -17,8 +17,11 @@ def _kill_process(proc): try: proc.kill() except AccessDenied: - logs.debug(u'Rerun: process PID {} ({}) could not be terminated'.format( - proc.pid, proc.exe())) + logs.debug( + u'Rerun: process PID {} ({}) could not be terminated'.format( + proc.pid, proc.exe() + ) + ) def _wait_output(popen, is_slow): @@ -33,8 +36,10 @@ def _wait_output(popen, is_slow): """ proc = Process(popen.pid) try: - proc.wait(settings.wait_slow_command if is_slow - else settings.wait_command) + proc.wait( + settings.wait_slow_command if is_slow + else settings.wait_command + ) return True except TimeoutExpired: for child in proc.children(recursive=True): @@ -59,8 +64,11 @@ def get_output(script, expanded): split_expand = shlex.split(expanded) is_slow = split_expand[0] in settings.slow_commands if split_expand else False - with logs.debug_time(u'Call: {}; with env: {}; is slow: {}'.format( - script, env, is_slow)): + with logs.debug_time( + u'Call: {}; with env: {}; is slow: {}'.format( + script, env, is_slow + ) + ): result = Popen(expanded, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, env=env) if _wait_output(result, is_slow):