fix remaining pep8 violations

This commit is contained in:
Gil Forsyth 2016-10-07 10:57:31 -04:00
parent f7090adfbf
commit 29af833ad8
13 changed files with 36 additions and 41 deletions

View file

@ -11,7 +11,6 @@ from xonsh.tools import XonshBlockError
from xonsh.jobs import tasks
from xonsh.events import events
from xonsh.platform import ON_WINDOWS
from xonsh.commands_cache import CommandsCache
from tools import DummyShell, sp, DummyCommandsCache, DummyEnv, DummyHistory

View file

@ -110,6 +110,7 @@ class DummyEnv(MutableMapping):
# Execer tools
#
def check_exec(input, **kwargs):
if not input.endswith('\n'):
input += '\n'
@ -137,7 +138,7 @@ def check_parse(input):
def nodes_equal(x, y):
__tracebackhide__ = True
assert type(x) == type(y) , "Ast nodes do not have the same type: '%s' != '%s' " % (type(x), type(y))
assert type(x) == type(y), "Ast nodes do not have the same type: '%s' != '%s' " % (type(x), type(y))
if isinstance(x, (ast.Expr, ast.FunctionDef, ast.ClassDef)):
assert x.lineno == y.lineno, "Ast nodes do not have the same line number : %s != %s" % (x.lineno, y.lineno)
assert x.col_offset == y.col_offset, "Ast nodes do not have the same column offset number : %s != %s" % (x.col_offset, y.col_offset)
@ -147,5 +148,5 @@ def nodes_equal(x, y):
assert type(xval) == type(yval), "Ast nodes fields differ : %s (of type %s) != %s (of type %s)" % (xname, type(xval), yname, type(yval))
for xchild, ychild in zip(ast.iter_child_nodes(x),
ast.iter_child_nodes(y)):
assert nodes_equal(xchild, ychild) , "Ast node children differs"
assert nodes_equal(xchild, ychild), "Ast node children differs"
return True

View file

@ -15,12 +15,11 @@ from xonsh.foreign_shells import foreign_shell_data
from xonsh.jobs import jobs, fg, bg, clean_jobs
from xonsh.history import history_main
from xonsh.platform import (ON_ANACONDA, ON_DARWIN, ON_WINDOWS, ON_FREEBSD,
ON_NETBSD, scandir)
ON_NETBSD)
from xonsh.proc import foreground
from xonsh.replay import replay_main
from xonsh.timings import timeit_alias
from xonsh.tools import (XonshError, argvquote, escape_windows_cmd_string,
to_bool)
from xonsh.tools import argvquote, escape_windows_cmd_string, to_bool
from xonsh.xontribs import xontribs_main
import xonsh.completers._aliases as xca
@ -322,7 +321,6 @@ def xexec(args, stdin=None):
'\n'.format(e.args[1], args[0]), 1)
class AWitchAWitch(argparse.Action):
SUPPRESS = '==SUPPRESS=='

View file

@ -14,7 +14,6 @@ import shlex
import signal
import atexit
import inspect
import tempfile
import builtins
import itertools
import subprocess
@ -28,7 +27,7 @@ from xonsh.inspectors import Inspector
from xonsh.aliases import Aliases, make_default_aliases
from xonsh.environ import Env, default_env, locate_binary
from xonsh.foreign_shells import load_foreign_aliases
from xonsh.jobs import add_job, wait_for_active_job
from xonsh.jobs import add_job
from xonsh.platform import ON_POSIX, ON_WINDOWS
from xonsh.proc import (
PopenThread, ProcProxy, ForegroundProcProxy,
@ -297,7 +296,7 @@ def _parse_redirects(r):
try:
dest = int(dest[1:])
if loc is None:
loc, dest = dest, ''
loc, dest = dest, '' # NOQA
else:
e = 'Unrecognized redirection command: {}'.format(r)
raise XonshError(e)
@ -644,7 +643,6 @@ class SubprocSpec:
def _update_last_spec(last, captured=False):
last.last_in_pipeline = True
env = builtins.__xonsh_env__
if not captured:
return
callable_alias = callable(last.alias)
@ -750,7 +748,6 @@ def run_subproc(cmds, captured=False):
Lastly, the captured argument affects only the last real command.
"""
env = builtins.__xonsh_env__
specs = cmds_to_specs(cmds, captured=captured)
procs = []
proc = pipeline_group = None
@ -759,7 +756,7 @@ def run_subproc(cmds, captured=False):
proc = spec.run(pipeline_group=pipeline_group)
procs.append(proc)
if ON_POSIX and pipeline_group is None and \
spec.cls is subprocess.Popen:
spec.cls is subprocess.Popen:
pipeline_group = proc.pid
if not spec.is_proxy:
add_job({
@ -767,14 +764,14 @@ def run_subproc(cmds, captured=False):
'pids': [i.pid for i in procs],
'obj': proc,
'bg': spec.background,
})
})
if _should_set_title(captured=captured):
# set title here to get currently executing command
pause_call_resume(proc, builtins.__xonsh_shell__.settitle)
# create command or return if backgrounding.
if spec.background:
return
#if not captured:
# if not captured:
# pass
if captured == 'hiddenobject':
command = HiddenCommandPipeline(specs, procs, starttime=starttime,

View file

@ -179,6 +179,7 @@ class CommandsCache(cabc.Mapping):
# Background Predictors
#
def predict_true(args):
"""Always say the process is backgroundable."""
return True
@ -214,16 +215,16 @@ def default_backgroundable_predictors():
The default is to predict true.
"""
return collections.defaultdict(lambda: predict_true,
sh=predict_shell,
zsh=predict_shell,
ksh=predict_shell,
csh=predict_shell,
tcsh=predict_shell,
bash=predict_shell,
fish=predict_shell,
xonsh=predict_shell,
ssh=predict_false,
startx=predict_false,
vi=predict_false,
vim=predict_false,
)
sh=predict_shell,
zsh=predict_shell,
ksh=predict_shell,
csh=predict_shell,
tcsh=predict_shell,
bash=predict_shell,
fish=predict_shell,
xonsh=predict_shell,
ssh=predict_false,
startx=predict_false,
vi=predict_false,
vim=predict_false,
)

View file

@ -6,7 +6,6 @@ from xonsh.completers.python import complete_python
from xonsh.completers.commands import complete_command
def complete_base(prefix, line, start, end, ctx):
"""If the line is empty, complete based on valid commands, python names,
and paths. If we are completing the first argument, complete based on

View file

@ -45,7 +45,7 @@ def _unc_check_enabled()->bool:
key2 = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r'software\microsoft\command processor')
wval, wtype = winreg.QueryValueEx(key2, 'DisableUNCCheck')
winreg.CloseKey(key2)
except OSError as e:
except OSError as e: # NOQA
pass
return False if wval else True

View file

@ -49,6 +49,7 @@ def HELP_TEMPLATE():
'default: {{CYAN}}{default}{{NO_COLOR}}\n'
'configurable: {{CYAN}}{configurable}{{NO_COLOR}}')
@lazyobject
def LOCALE_CATS():
lc = {'LC_CTYPE': locale.LC_CTYPE,
@ -651,7 +652,8 @@ def DEFAULT_DOCS():
'XONSH_LOGIN': VarDocs(
'``True`` if xonsh is running as a login shell, and ``False`` otherwise.',
configurable=False),
'XONSH_PROC_FREQUENCY': VarDocs('The process frquency is the time that '
'XONSH_PROC_FREQUENCY': VarDocs(
'The process frquency is the time that '
'xonsh process threads sleep for while running command pipelines. '
'The value has units of seconds [s].'),
'XONSH_SHOW_TRACEBACK': VarDocs(

View file

@ -24,4 +24,3 @@ class Parser(ThreeFiveParser):
comps += p5.get('comps', [])
comp.ifs += p5.get('if', [])
p[0] = p0

View file

@ -71,6 +71,7 @@ CAN_RESIZE_WINDOW = LazyBool(lambda: hasattr(signal, 'SIGWINCH'),
signal.SIGWINCH, else ``False``.
"""
@lazybool
def HAS_PYGMENTS():
"""``True`` if `pygments` is available, else ``False``."""

View file

@ -121,7 +121,7 @@ def _partial_format_prompt_main(template=DEFAULT_PROMPT, formatter_dict=None):
v = fmtter[field]
try:
val = v() if callable(v) else v
except Exception as err:
except Exception:
print('prompt: error: on field {!r}'
''.format(field), file=sys.stderr)
xt.print_exception()

View file

@ -4,7 +4,6 @@ import os
import re
import string
import builtins
import functools
from warnings import warn
from collections import ChainMap
from collections.abc import MutableMapping
@ -25,7 +24,6 @@ from xonsh.commands_cache import CommandsCache
from xonsh.lazyasd import LazyObject, LazyDict
from xonsh.tools import (ON_WINDOWS, intensify_colors_for_cmd_exe,
expand_gray_colors_for_cmd_exe)
load_module_in_background('pkg_resources', debug='XONSH_DEBUG',
replacements={'pygments.plugin': 'pkg_resources'})
@ -71,8 +69,8 @@ class XonshLexer(PythonLexer):
filenames = ['*.xsh', '*xonshrc']
def __init__(self, *args, **kwargs):
# If the lexor is loaded as a pygment plugin, we have to mock
# __xonsh_env__ and __xonsh_commands_cache__
# If the lexor is loaded as a pygment plugin, we have to mock
# __xonsh_env__ and __xonsh_commands_cache__
if not hasattr(builtins, '__xonsh_env__'):
setattr(builtins, '__xonsh_env__', {})
if ON_WINDOWS:
@ -80,7 +78,7 @@ class XonshLexer(PythonLexer):
builtins.__xonsh_env__['PATHEXT'] = pathext.split(os.pathsep)
if not hasattr(builtins, '__xonsh_commands_cache__'):
setattr(builtins, '__xonsh_commands_cache__', CommandsCache())
_ = builtins.__xonsh_commands_cache__.all_commands
_ = builtins.__xonsh_commands_cache__.all_commands # NOQA
super().__init__(*args, **kwargs)
tokens = {

View file

@ -736,9 +736,9 @@ def _tokenize(readline, encoding):
stashed = tok
continue
if token == 'def' and (stashed
and stashed.type == NAME
and stashed.string == 'async'):
if token == 'def' and (stashed and
stashed.type == NAME and
stashed.string == 'async'):
async_def = True
async_def_indent = indents[-1]