From bc4eee6f85be9787c3890edd000f57be276d2c65 Mon Sep 17 00:00:00 2001 From: Gil Forsyth Date: Fri, 7 Oct 2016 10:46:41 -0400 Subject: [PATCH] start of pep8 cleanups --- xonsh/prompt/vc_branch.py | 9 +++++---- xonsh/ptk/key_bindings.py | 16 +++++++++------- xonsh/ptk/shell.py | 4 ++-- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/xonsh/prompt/vc_branch.py b/xonsh/prompt/vc_branch.py index fe2f7117e..3a8d02b81 100644 --- a/xonsh/prompt/vc_branch.py +++ b/xonsh/prompt/vc_branch.py @@ -1,15 +1,15 @@ # -*- coding: utf-8 -*- """Prompt formatter for simple version control branchs""" -import builtins import os -import subprocess import sys -import threading, queue import time +import queue +import builtins import warnings +import threading +import subprocess -import xonsh.platform as xp import xonsh.tools as xt @@ -24,6 +24,7 @@ def _get_git_branch(q): branch = info.splitlines()[0].split()[-1] q.put(branch) + def get_git_branch(): """Attempts to find the current git branch. If this could not be determined (timeout, not in a git repo, etc.) then this returns None. diff --git a/xonsh/ptk/key_bindings.py b/xonsh/ptk/key_bindings.py index 0b94486df..923ab250d 100644 --- a/xonsh/ptk/key_bindings.py +++ b/xonsh/ptk/key_bindings.py @@ -53,8 +53,8 @@ def carriage_return(b, cli, *, autoindent=True): not current_line_blank): b.newline(copy_margin=autoindent) elif (doc.char_before_cursor == '\\' and - not (not builtins.__xonsh_env__.get('FORCE_POSIX_PATHS') - and ON_WINDOWS)): + not (not builtins.__xonsh_env__.get('FORCE_POSIX_PATHS') and + ON_WINDOWS)): b.newline(copy_margin=autoindent) elif (doc.find_next_word_beginning() is not None and (any(not _is_blank(i) @@ -90,8 +90,8 @@ class BeginningOfLine(Filter): def __call__(self, cli): before_cursor = cli.current_buffer.document.current_line_before_cursor - return bool(len(before_cursor) == 0 - and not cli.current_buffer.document.on_first_line) + return bool(len(before_cursor) == 0 and + not cli.current_buffer.document.on_first_line) class EndOfLine(Filter): @@ -112,8 +112,8 @@ class ShouldConfirmCompletion(Filter): Check if completion needs confirmation """ def __call__(self, cli): - return (builtins.__xonsh_env__.get('COMPLETIONS_CONFIRM') - and cli.current_buffer.complete_state) + return (builtins.__xonsh_env__.get('COMPLETIONS_CONFIRM') and + cli.current_buffer.complete_state) # Copied from prompt-toolkit's key_binding/bindings/basic.py @@ -246,7 +246,9 @@ def load_xonsh_bindings(key_bindings_manager): @handle(Keys.Left, filter=BeginningOfLine()) def wrap_cursor_back(event): - """Move cursor to end of previous line unless at beginning of document""" + """Move cursor to end of previous line unless at beginning of + document + """ b = event.cli.current_buffer b.cursor_up(count=1) relative_end_index = b.document.get_end_of_line_position() diff --git a/xonsh/ptk/shell.py b/xonsh/ptk/shell.py index 402f35f64..76c1c5fca 100644 --- a/xonsh/ptk/shell.py +++ b/xonsh/ptk/shell.py @@ -126,9 +126,9 @@ class PromptToolkitShell(BaseShell): else: line = self.precmd(line) self.default(line) - except KeyboardInterrupt as e: + except KeyboardInterrupt: self.reset_buffer() - except EOFError as e: + except EOFError: if builtins.__xonsh_env__.get("IGNOREEOF"): print('Use "exit" to leave the shell.', file=sys.stderr) else: