mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 00:14:41 +01:00
[pre-commit.ci] pre-commit autoupdate (#5180)
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/astral-sh/ruff-pre-commit: v0.0.278 → v0.0.280](https://github.com/astral-sh/ruff-pre-commit/compare/v0.0.278...v0.0.280) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix: ruff linter errors --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Noorhteen Raja NJ <jnoortheen@gmail.com>
This commit is contained in:
parent
0e229fcc8c
commit
7bd8f5da9f
9 changed files with 34 additions and 46 deletions
|
@ -14,7 +14,7 @@ repos:
|
|||
pass_filenames: false
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
# Ruff version.
|
||||
rev: 'v0.0.278'
|
||||
rev: 'v0.0.280'
|
||||
hooks:
|
||||
- id: ruff
|
||||
args: [., --fix, --exit-non-zero-on-fix]
|
||||
|
|
|
@ -874,15 +874,13 @@ def test_negative_exit_codes_fail():
|
|||
],
|
||||
)
|
||||
def test_ampersand_argument(cmd, exp):
|
||||
script = """
|
||||
script = f"""
|
||||
#!/usr/bin/env xonsh
|
||||
def _echo(args):
|
||||
print(' '.join(args))
|
||||
aliases['echo'] = _echo
|
||||
{}
|
||||
""".format(
|
||||
cmd
|
||||
)
|
||||
{cmd}
|
||||
"""
|
||||
out, _, _ = run_xonsh(script)
|
||||
assert out == exp
|
||||
|
||||
|
|
|
@ -35,12 +35,12 @@ class CommandsCache(cabc.Mapping):
|
|||
|
||||
def __init__(self, env, aliases=None) -> None:
|
||||
# cache commands in path by mtime
|
||||
self._paths_cache: "dict[str, _Commands]" = {}
|
||||
self._paths_cache: dict[str, _Commands] = {}
|
||||
|
||||
# wrap aliases and commands in one place
|
||||
self._cmds_cache: "dict[str, tuple[str, bool|None]]" = {}
|
||||
self._cmds_cache: dict[str, tuple[str, bool | None]] = {}
|
||||
|
||||
self._alias_checksum: "int|None" = None
|
||||
self._alias_checksum: int | None = None
|
||||
self.threadable_predictors = default_threadable_predictors()
|
||||
|
||||
# Path to the cache-file where all commands/aliases are cached for pre-loading"""
|
||||
|
|
|
@ -242,7 +242,7 @@ class Execer:
|
|||
if original_error is None:
|
||||
raise e
|
||||
else:
|
||||
raise original_error
|
||||
raise original_error from None
|
||||
except SyntaxError as e:
|
||||
if original_error is None:
|
||||
original_error = e
|
||||
|
@ -286,7 +286,7 @@ class Execer:
|
|||
prev_indent = len(lines[idx - 1]) - len(lines[idx - 1].lstrip())
|
||||
curr_indent = len(lines[idx]) - len(lines[idx].lstrip())
|
||||
if prev_indent == curr_indent:
|
||||
raise original_error
|
||||
raise original_error from None
|
||||
lexer = self.parser.lexer
|
||||
maxcol = (
|
||||
None
|
||||
|
@ -316,7 +316,7 @@ class Execer:
|
|||
continue
|
||||
else:
|
||||
# or for some other syntax error
|
||||
raise original_error
|
||||
raise original_error from None
|
||||
elif sbpline[last_error_col:].startswith(
|
||||
"![!["
|
||||
) or sbpline.lstrip().startswith("![!["):
|
||||
|
@ -327,7 +327,7 @@ class Execer:
|
|||
greedy = True
|
||||
continue
|
||||
else:
|
||||
raise original_error
|
||||
raise original_error from None
|
||||
# replace the line
|
||||
self._print_debug_wrapping(
|
||||
line, sbpline, last_error_line, last_error_col, maxcol=maxcol
|
||||
|
|
|
@ -41,8 +41,8 @@ def _xh_sqlite_create_history_table(cursor):
|
|||
"""
|
||||
if not getattr(XH_SQLITE_CACHE, XH_SQLITE_CREATED_SQL_TBL, False):
|
||||
cursor.execute(
|
||||
"""
|
||||
CREATE TABLE IF NOT EXISTS {}
|
||||
f"""
|
||||
CREATE TABLE IF NOT EXISTS {XH_SQLITE_TABLE_NAME}
|
||||
(inp TEXT,
|
||||
rtn INTEGER,
|
||||
tsb REAL,
|
||||
|
@ -53,9 +53,7 @@ def _xh_sqlite_create_history_table(cursor):
|
|||
frequency INTEGER default 1,
|
||||
cwd TEXT
|
||||
)
|
||||
""".format(
|
||||
XH_SQLITE_TABLE_NAME
|
||||
)
|
||||
"""
|
||||
)
|
||||
|
||||
# add frequency column if not exists for backward compatibility
|
||||
|
|
|
@ -24,16 +24,16 @@ class ModuleFinder:
|
|||
self.contextual = True
|
||||
|
||||
# unique but maintain order
|
||||
self._pkgs: "dict[str, None]" = OrderedDict()
|
||||
self._paths: "dict[str, None]" = OrderedDict()
|
||||
self._pkgs: dict[str, None] = OrderedDict()
|
||||
self._paths: dict[str, None] = OrderedDict()
|
||||
for pk in names:
|
||||
if os.sep in pk:
|
||||
self._paths[pk] = None
|
||||
else:
|
||||
self._pkgs[pk] = None
|
||||
|
||||
self._file_names_cache: "dict[str, str]" = {}
|
||||
self._path_st_mtimes: "dict[str, float]" = {}
|
||||
self._file_names_cache: dict[str, str] = {}
|
||||
self._path_st_mtimes: dict[str, float] = {}
|
||||
|
||||
def _get_new_paths(self):
|
||||
for path in self._paths:
|
||||
|
|
|
@ -85,7 +85,7 @@ class PromptFormatter:
|
|||
|
||||
# some quick tests
|
||||
if isinstance(fields, dict):
|
||||
pflds: "PromptFields[PromptField]" = PromptFields(XSH, init=False)
|
||||
pflds: PromptFields[PromptField] = PromptFields(XSH, init=False)
|
||||
pflds.update(fields)
|
||||
self.fields = pflds
|
||||
|
||||
|
@ -267,9 +267,9 @@ class PromptFields(tp.MutableMapping[str, "FieldType"]):
|
|||
"""Mapping of functions available for prompt-display."""
|
||||
|
||||
def __init__(self, xsh: "XonshSession", init=True):
|
||||
self._items: "dict[str, str | tp.Callable[..., str]]" = {}
|
||||
self._items: dict[str, str | tp.Callable[..., str]] = {}
|
||||
|
||||
self._cache: "dict[str, str|FieldType]" = {}
|
||||
self._cache: dict[str, str | FieldType] = {}
|
||||
"""for callbacks this will catch the value and should be cleared between prompts"""
|
||||
|
||||
self.xsh = xsh
|
||||
|
|
|
@ -33,7 +33,7 @@ class Routes:
|
|||
):
|
||||
self.url = url
|
||||
self.params = params
|
||||
self.env: "Env" = xsh.env
|
||||
self.env: Env = xsh.env
|
||||
self.xsh = xsh
|
||||
|
||||
def __init_subclass__(cls, **kwargs):
|
||||
|
|
|
@ -50,7 +50,7 @@ from xonsh.tools import (
|
|||
from xonsh.xontribs import Xontrib, find_xontrib, get_xontribs, xontribs_loaded
|
||||
|
||||
HR = "'`-.,_,.-*'`-.,_,.-*'`-.,_,.-*'`-.,_,.-*'`-.,_,.-*'`-.,_,.-*'`-.,_,.-*'"
|
||||
WIZARD_HEAD = """
|
||||
WIZARD_HEAD = f"""
|
||||
{{BOLD_WHITE}}Welcome to the xonsh configuration wizard!{{RESET}}
|
||||
{{YELLOW}}------------------------------------------{{RESET}}
|
||||
This will present a guided tour through setting up the xonsh static
|
||||
|
@ -69,13 +69,11 @@ variable setup. Each phase may be skipped in its entirety.
|
|||
|
||||
For the configuration to take effect, you will need to restart xonsh.
|
||||
|
||||
{hr}
|
||||
""".format(
|
||||
hr=HR
|
||||
)
|
||||
{HR}
|
||||
"""
|
||||
|
||||
WIZARD_FS = """
|
||||
{hr}
|
||||
WIZARD_FS = f"""
|
||||
{HR}
|
||||
|
||||
{{BOLD_WHITE}}Foreign Shell Setup{{RESET}}
|
||||
{{YELLOW}}-------------------{{RESET}}
|
||||
|
@ -87,12 +85,10 @@ aliases, and functions specified in the config files of these shells.
|
|||
Naturally, these shells must be available on the system to work.
|
||||
Being able to share configuration (and source) from foreign shells
|
||||
makes it easier to transition to and from xonsh.
|
||||
""".format(
|
||||
hr=HR
|
||||
)
|
||||
"""
|
||||
|
||||
WIZARD_ENV = """
|
||||
{hr}
|
||||
WIZARD_ENV = f"""
|
||||
{HR}
|
||||
|
||||
{{BOLD_WHITE}}Environment Variable Setup{{RESET}}
|
||||
{{YELLOW}}--------------------------{{RESET}}
|
||||
|
@ -108,14 +104,12 @@ values are presented as pretty repr strings of their Python types.
|
|||
|
||||
{{BOLD_GREEN}}Note:{{RESET}} Simply hitting enter for any environment variable
|
||||
will accept the default value for that entry.
|
||||
""".format(
|
||||
hr=HR
|
||||
)
|
||||
"""
|
||||
|
||||
WIZARD_ENV_QUESTION = "Would you like to set env vars now, " + wiz.YN
|
||||
|
||||
WIZARD_XONTRIB = """
|
||||
{hr}
|
||||
WIZARD_XONTRIB = f"""
|
||||
{HR}
|
||||
|
||||
{{BOLD_WHITE}}Xontribs{{RESET}}
|
||||
{{YELLOW}}--------{{RESET}}
|
||||
|
@ -128,9 +122,7 @@ This allows the xontrib to be used immediately in your xonshrc files.
|
|||
|
||||
The following describes all xontribs that have been registered with xonsh.
|
||||
These come from users, 3rd party developers, or xonsh itself!
|
||||
""".format(
|
||||
hr=HR
|
||||
)
|
||||
"""
|
||||
|
||||
WIZARD_XONTRIB_QUESTION = "Would you like to enable xontribs now, " + wiz.YN
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue