Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate
Browse files Browse the repository at this point in the history
updates:
- [github.com/psf/black: 22.12.0 → 23.1.0](psf/black@22.12.0...23.1.0)
- [github.com/pycqa/isort: 5.11.4 → 5.12.0](PyCQA/isort@5.11.4...5.12.0)
  • Loading branch information
pre-commit-ci[bot] authored and jnoortheen committed Feb 14, 2023
1 parent 3cc6b29 commit ba8ae97
Show file tree
Hide file tree
Showing 23 changed files with 31 additions and 70 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ ci:

repos:
- repo: https://github.com/psf/black
rev: 22.12.0
rev: 23.1.0
hooks:
- id: black
entry: black xonsh xontrib tests xompletions
pass_filenames: false
- repo: https://github.com/pycqa/isort
rev: 5.11.4
rev: 5.12.0
hooks:
- id: isort
entry: isort xonsh xontrib tests xompletions
Expand All @@ -34,7 +34,7 @@ repos:
docs/.+
)$
- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v0.991' # Use the sha / tag you want to point at
rev: 'v1.0.0' # Use the sha / tag you want to point at
hooks:
- id: mypy
name: mypy xonsh
Expand Down
1 change: 0 additions & 1 deletion tests/aliases/test_xexec.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ def test_missing_command(mockexecvpe):


def test_command_not_found(monkeypatch):

dummy_error_msg = (
"This is dummy error message, file not found or something like that"
)
Expand Down
1 change: 0 additions & 1 deletion tests/procs/test_specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ def test_capture_always(
],
)
def test_run_subproc_background(captured, exp_is_none):

cmds = (["echo", "hello"], "&")
return_val = run_subproc(cmds, captured)
assert (return_val is None) == exp_is_none
Expand Down
3 changes: 2 additions & 1 deletion tests/test_dirstack_unc.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ def test_uncpushd_push_to_same_share(xession, shares_setup):
@pytest.mark.skipif(not ON_WINDOWS, reason="Windows-only UNC functionality")
def test_uncpushd_push_other_push_same(xession, shares_setup):
"""push to a, then to b. verify drive letter is TEMP_DRIVE[2], skipping already used TEMP_DRIVE[1]
Then push to a again. Pop (check b unmapped and a still mapped), pop, pop (check a is unmapped)"""
Then push to a again. Pop (check b unmapped and a still mapped), pop, pop (check a is unmapped)
"""
if shares_setup is None:
return
xession.env.update(dict(CDPATH=PARENT, PWD=HERE))
Expand Down
2 changes: 1 addition & 1 deletion tests/test_environ.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ def test_delitem():
env = Env(VAR="a value")
assert env["VAR"] == "a value"
del env["VAR"]
with pytest.raises(Exception):
with pytest.raises(KeyError):
env["VAR"]


Expand Down
1 change: 0 additions & 1 deletion tests/test_execer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
@pytest.fixture
def check_eval(xonsh_execer, xonsh_session, monkeypatch):
def factory(input):

env = {
"AUTO_CD": False,
"XONSH_ENCODING": "utf-8",
Expand Down
1 change: 0 additions & 1 deletion tests/test_history_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,6 @@ def history_files_list(gen_count) -> (float, int, str, int):
],
)
def test__xhj_gc_xx_to_rmfiles(fn, hsize, in_files, exp_size, exp_files, xession):

act_size, act_files = fn(hsize, in_files)

assert act_files == exp_files
Expand Down
4 changes: 2 additions & 2 deletions tests/test_ptk_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ def test_prompt_toolkit_version_checks(
monkeypatch,
xession,
):

mocked_warn = ""

def mock_warning(msg):
Expand Down Expand Up @@ -133,7 +132,8 @@ def test_ptk_prompt(line, exp, ptk_shell, capsys):
)
def test_ptk_default_append_history(cmd, exp_append_history, ptk_shell, monkeypatch):
"""Test that running an empty line or a comment does not append to history.
This test is necessary because the prompt-toolkit shell uses a custom _push() method that is different from the base shell's push() method."""
This test is necessary because the prompt-toolkit shell uses a custom _push() method that is different from the base shell's push() method.
"""
inp, out, shell = ptk_shell
append_history_calls = []

Expand Down
1 change: 0 additions & 1 deletion tests/test_pyghooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ def colorizable_files():

with TemporaryDirectory() as tempdir:
for k, v in _cf.items():

if v is None:
continue
if v.startswith("/"):
Expand Down
4 changes: 2 additions & 2 deletions xonsh/completers/completer.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ def add_one_completer(name, func, loc="end"):
for k, v in items[first_exclusive:]:
new[k] = v
elif loc == "end":
for (k, v) in XSH.completers.items():
for k, v in XSH.completers.items():
new[k] = v
new[name] = func
else:
direction, rel = loc[0], loc[1:]
found = False
for (k, v) in XSH.completers.items():
for k, v in XSH.completers.items():
if rel == k and direction == "<":
new[name] = func
found = True
Expand Down
3 changes: 2 additions & 1 deletion xonsh/completers/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ def is_contextual_completer(func):

def contextual_command_completer(func: tp.Callable[[CommandContext], CompleterResult]):
"""like ``contextual_completer``,
but will only run when completing a command and will directly receive the ``CommandContext`` object"""
but will only run when completing a command and will directly receive the ``CommandContext`` object
"""

@contextual_completer
@wraps(func)
Expand Down
2 changes: 1 addition & 1 deletion xonsh/dirstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ def dirs_fn(
if verbose:
out = ""
pad = len(str(len(o) - 1))
for (ix, e) in enumerate(o):
for ix, e in enumerate(o):
blanks = " " * (pad - len(str(ix)))
out += f"\n{blanks}{ix} {e}"
out = out[1:]
Expand Down
2 changes: 1 addition & 1 deletion xonsh/history/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def pull(show_commands=False, _stdout=None):
if lines_added:
print(f"Added {lines_added} records!", file=_stdout)
else:
print(f"No records found!", file=_stdout)
print("No records found!", file=_stdout)

@staticmethod
def flush(_stdout):
Expand Down
2 changes: 1 addition & 1 deletion xonsh/history/sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def xh_sqlite_delete_items(size_to_keep, filename=None):


def xh_sqlite_pull(filename, last_pull_time, current_sessionid):
sql = f"SELECT inp FROM xonsh_history WHERE tsb > ? AND sessionid != ? ORDER BY tsb"
sql = "SELECT inp FROM xonsh_history WHERE tsb > ? AND sessionid != ? ORDER BY tsb"
params = [last_pull_time, current_sessionid]
with _xh_sqlite_get_conn(filename=filename) as conn:
c = conn.cursor()
Expand Down
2 changes: 1 addition & 1 deletion xonsh/lexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def token_map():
"@$": "ATDOLLAR",
"&": "AMPERSAND",
}
for (op, typ) in _op_map.items():
for op, typ in _op_map.items():
tm[(OP, op)] = typ
tm[IOREDIRECT] = "IOREDIRECT"
tm[STRING] = "STRING"
Expand Down
1 change: 0 additions & 1 deletion xonsh/parsers/v310.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ def p_literal_expr_number_or_string_literal_list(self, p):

match p[1]:
case ast.JoinedStr():

raise AssertionError("patterns may not match formatted string literals")
# TODO: raise SyntaxError instead
# (doing so currently somehow causes an IndexError in tools.py:get_logical_line)
Expand Down
1 change: 0 additions & 1 deletion xonsh/pretty.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,6 @@ def __init__(
deferred_pprinters=None,
max_seq_length=MAX_SEQ_LENGTH,
):

PrettyPrinter.__init__(
self, output, max_width, newline, max_seq_length=max_seq_length
)
Expand Down
7 changes: 3 additions & 4 deletions xonsh/pyghooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1343,7 +1343,6 @@ def _monkey_patch_pygments_codes():

@lazyobject
def XonshTerminal256Formatter():

if (
ptk_version_info()
and ptk_version_info() > (2, 0)
Expand Down Expand Up @@ -1595,7 +1594,7 @@ def color_file(file_path: str, path_stat: os.stat_result) -> tp.Tuple[_TokenType
def _command_is_valid(cmd):
try:
cmd_abspath = os.path.abspath(os.path.expanduser(cmd))
except (OSError):
except OSError:
return False
return (cmd in XSH.commands_cache and not iskeyword(cmd)) or (
os.path.isfile(cmd_abspath) and os.access(cmd_abspath, os.X_OK)
Expand All @@ -1607,7 +1606,7 @@ def _command_is_autocd(cmd):
return False
try:
cmd_abspath = os.path.abspath(os.path.expanduser(cmd))
except (OSError):
except OSError:
return False
return os.path.isdir(cmd_abspath)

Expand All @@ -1628,7 +1627,7 @@ def subproc_arg_callback(_, match):
path = os.path.expanduser(text)
path_stat = os.lstat(path) # lstat() will raise FNF if not a real file
yieldVal, _ = color_file(path, path_stat)
except (OSError):
except OSError:
pass

yield (match.start(), yieldVal, text)
Expand Down
1 change: 0 additions & 1 deletion xonsh/pytest/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ def shell(self):


class DummyHistory:

last_cmd_rtn = 0
last_cmd_out = ""

Expand Down
50 changes: 11 additions & 39 deletions xonsh/webconfig/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ def get_nav_links(self):

title = page.nav_title() if callable(page.nav_title) else page.nav_title
if title:
yield t.nav_item(*klass)[
t.nav_link(href=page.path)[title],
]
yield t.nav_item(*klass)[t.nav_link(href=page.path)[title],]

def get_err_msgs(self):
if not self.err_msgs:
Expand Down Expand Up @@ -103,9 +101,7 @@ def to_card(self, name: str, display: str):

def get_cols(self):
for name, display in self.colors.items():
yield t.col_sm()[
self.to_card(name, display),
]
yield t.col_sm()[self.to_card(name, display),]

def _get_selected_header(self):
selected = self.params.get("selected")
Expand All @@ -131,9 +127,7 @@ def get_selected(self):
t.card_body()[self.get_display(display)],
]

return t.row()[
t.col()[card],
]
return t.row()[t.col()[card],]

def get(self):
# banner
Expand Down Expand Up @@ -210,23 +204,13 @@ def get_selected(self):
],
self.get_display(display),
],
t.card_footer("py-1")[
t.btn_primary("py-1", type="submit")[
"Set",
],
],
]
return t.row()[
t.col()[t.form(method="post")[card]],
t.card_footer("py-1")[t.btn_primary("py-1", type="submit")["Set",],],
]
return t.row()[t.col()[t.form(method="post")[card]],]

def get_cols(self):
for name, prompt in self.prompts.items():
yield t.row()[
t.col()[
self.to_card(name, prompt["display"]),
]
]
yield t.row()[t.col()[self.to_card(name, prompt["display"]),]]

def get(self):
# banner
Expand Down Expand Up @@ -269,27 +253,19 @@ def xontrib_card(self, name, data):
if self.is_loaded(name):
act_label = "Remove"
action = t.inline_form(method="post")[
t.btn_primary("ml-2", "p-1", type="submit", name=name)[
act_label,
],
t.btn_primary("ml-2", "p-1", type="submit", name=name)[act_label,],
]
else:
title = title("stretched-link") # add class
action = ""
return t.card()[
t.card_header()[title, action],
t.card_body()[
self.get_display(data["display"]),
],
t.card_body()[self.get_display(data["display"]),],
]

def get(self):
for name, data in self.xontribs.items():
yield t.row()[
t.col()[
self.xontrib_card(name, data),
]
]
yield t.row()[t.col()[self.xontrib_card(name, data),]]
yield t.br()

def post(self, data: "cgi.FieldStorage"):
Expand Down Expand Up @@ -368,9 +344,7 @@ def get_rows(self):

yield t.tr()[
t.td("text-right")[str(name)],
t.td()[
t.p()[repr(alias)],
],
t.td()[t.p()[repr(alias)],],
]

def get_table(self):
Expand Down Expand Up @@ -418,9 +392,7 @@ def get_rows(self):

yield t.tr()[
t.td("text-right")[str(name)],
t.td()[
t.p()[repr(display)],
],
t.td()[t.p()[repr(display)],],
]

def get_table(self):
Expand Down
4 changes: 1 addition & 3 deletions xonsh/webconfig/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,7 @@ def _to_str():


if __name__ == "__main__":
nav = nav_item()[
nav_link(href="/")["Colors"],
]
nav = nav_item()[nav_link(href="/")["Colors"],]
gen = to_str(nav, debug=True)
print(gen)
assert gen.splitlines() == [
Expand Down
1 change: 0 additions & 1 deletion xontrib/abbrevs.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ def set_cursor_position(buffer, expanded: str) -> None:


def custom_keybindings(bindings, **kw):

from prompt_toolkit.filters import EmacsInsertMode, ViInsertMode

from xonsh.ptk_shell.key_bindings import carriage_return
Expand Down
1 change: 0 additions & 1 deletion xontrib/bashisms.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ def _set(args):


def _shopt(args):

supported_shopt = ["DOTGLOB"]

args_len = len(args)
Expand Down

0 comments on commit ba8ae97

Please sign in to comment.