From 66c0490d37581021e0cb4397d7bf0f4c110e0fa6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 30 Jan 2024 12:23:50 +0100 Subject: [PATCH] [pre-commit.ci] pre-commit autoupdate (#5271) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [pre-commit.ci] pre-commit autoupdate updates: - [github.com/psf/black: 23.12.1 → 24.1.1](https://github.com/psf/black/compare/23.12.1...24.1.1) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- tests/procs/test_specs.py | 1 + tests/test_aliases.py | 9 +++------ tests/test_ansi_colors.py | 1 + tests/test_ast.py | 1 + tests/test_base_shell.py | 1 + tests/test_builtins.py | 1 + tests/test_color_tools.py | 1 + tests/test_completion_context.py | 8 +++++--- tests/test_contexts.py | 1 + tests/test_dirstack_unc.py | 1 + tests/test_environ.py | 1 + tests/test_events.py | 1 + tests/test_execer.py | 1 + tests/test_foreign_shells.py | 1 + tests/test_history_json.py | 1 + tests/test_history_sqlite.py | 1 + tests/test_imphooks.py | 1 + tests/test_integrations.py | 1 + tests/test_jsonutils.py | 1 + tests/test_lazyasd.py | 1 + tests/test_lazyjson.py | 1 + tests/test_lexer.py | 1 + tests/test_main.py | 1 + tests/test_news.py | 1 + tests/test_parser.py | 1 + tests/test_ptk_highlight.py | 1 - tests/test_ptk_multiline.py | 1 + tests/test_pyghooks.py | 1 + tests/test_shell.py | 1 + tests/test_tools.py | 9 ++++++--- tests/test_wizard.py | 1 + tests/test_xonfig.py | 1 + tests/test_xontribs.py | 1 + xonsh/aliases.py | 4 ++-- xonsh/ansi_colors.py | 1 + xonsh/ast.py | 1 + xonsh/base_shell.py | 1 + xonsh/built_ins.py | 1 + xonsh/cli_utils.py | 4 +--- xonsh/codecache.py | 1 + xonsh/color_tools.py | 1 + xonsh/commands_cache.py | 1 + xonsh/completer.py | 1 + xonsh/completers/base.py | 1 + xonsh/completers/bash_completion.py | 1 + xonsh/completers/init.py | 1 + xonsh/completers/python.py | 1 + xonsh/completers/tools.py | 1 + xonsh/contexts.py | 1 + xonsh/diff_history.py | 1 + xonsh/dirstack.py | 1 + xonsh/environ.py | 9 ++++++--- xonsh/events.py | 1 + xonsh/execer.py | 1 + xonsh/foreign_shells.py | 1 + xonsh/history/base.py | 1 + xonsh/history/dummy.py | 1 + xonsh/history/json.py | 1 + xonsh/history/main.py | 1 + xonsh/history/sqlite.py | 1 + xonsh/imphooks.py | 1 + xonsh/inspectors.py | 1 + xonsh/jobs.py | 1 + xonsh/jsonutils.py | 1 + xonsh/lazyasd.py | 1 + xonsh/lazyimps.py | 1 + xonsh/lazyjson.py | 1 + xonsh/lexer.py | 7 ++----- xonsh/lib/os.py | 1 + xonsh/macutils.py | 1 + xonsh/main.py | 1 + xonsh/openpy.py | 1 + xonsh/parser.py | 1 + xonsh/parsers/base.py | 1 + xonsh/parsers/completion_context.py | 7 +++---- xonsh/parsers/fstring_adaptor.py | 1 + xonsh/parsers/v36.py | 1 + xonsh/parsers/v38.py | 1 + xonsh/platform.py | 1 + xonsh/pretty.py | 1 + xonsh/proc.py | 1 + xonsh/procs/pipelines.py | 1 + xonsh/procs/posix.py | 1 + xonsh/procs/proxies.py | 13 +++++++------ xonsh/procs/readers.py | 1 + xonsh/procs/specs.py | 1 + xonsh/prompt/env.py | 1 + xonsh/prompt/times.py | 1 + xonsh/prompt/vc.py | 1 + xonsh/ptk_shell/completer.py | 1 + xonsh/ptk_shell/shell.py | 1 + xonsh/pyghooks.py | 17 +++++++++++------ xonsh/pygments_cache.py | 1 + xonsh/pytest/tools.py | 1 + xonsh/readline_shell.py | 1 + xonsh/shell.py | 1 + xonsh/style_tools.py | 1 + xonsh/timings.py | 1 + xonsh/tools.py | 5 ++--- xonsh/tracer.py | 1 + xonsh/webconfig/file_writes.py | 1 + xonsh/webconfig/xonsh_data.py | 1 + xonsh/winutils.py | 1 + xonsh/wizard.py | 1 + xonsh/xonfig.py | 1 + xonsh/xontribs.py | 1 + xonsh/xoreutils/cat.py | 1 + xonsh/xoreutils/pwd.py | 1 + xonsh/xoreutils/tty.py | 1 + xonsh/xoreutils/ulimit.py | 1 + xonsh/xoreutils/uptime.py | 1 + xonsh/xoreutils/which.py | 1 + xontrib/coreutils.py | 1 + 114 files changed, 150 insertions(+), 46 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 09992b56a..de76a412f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,7 +7,7 @@ ci: repos: - repo: https://github.com/psf/black - rev: 23.12.1 + rev: 24.1.1 hooks: - id: black entry: black xonsh xontrib tests xompletions diff --git a/tests/procs/test_specs.py b/tests/procs/test_specs.py index 3ca4de536..dedff4ac3 100644 --- a/tests/procs/test_specs.py +++ b/tests/procs/test_specs.py @@ -1,4 +1,5 @@ """Tests the xonsh.procs.specs""" + import itertools import sys from subprocess import Popen diff --git a/tests/test_aliases.py b/tests/test_aliases.py index 3662e2b98..da2b1eac1 100644 --- a/tests/test_aliases.py +++ b/tests/test_aliases.py @@ -204,15 +204,12 @@ def test_register_decorator(xession): aliases = Aliases() @aliases.register - def debug(): - ... + def debug(): ... @aliases.register("name") - def with_options(): - ... + def with_options(): ... @aliases.register - def _private(): - ... + def _private(): ... assert set(aliases) == {"debug", "name", "private"} diff --git a/tests/test_ansi_colors.py b/tests/test_ansi_colors.py index be56c5ab0..0bb330403 100644 --- a/tests/test_ansi_colors.py +++ b/tests/test_ansi_colors.py @@ -1,4 +1,5 @@ """Tests ANSI color tools.""" + import pytest from xonsh.ansi_colors import ( diff --git a/tests/test_ast.py b/tests/test_ast.py index 611ea8d24..bee999729 100644 --- a/tests/test_ast.py +++ b/tests/test_ast.py @@ -1,4 +1,5 @@ """Xonsh AST tests.""" + import ast as pyast import pytest diff --git a/tests/test_base_shell.py b/tests/test_base_shell.py index a2f229e72..24dc29898 100644 --- a/tests/test_base_shell.py +++ b/tests/test_base_shell.py @@ -1,4 +1,5 @@ """(A down payment on) Testing for ``xonsh.base_shell.BaseShell`` and associated classes""" + import os import pytest diff --git a/tests/test_builtins.py b/tests/test_builtins.py index 57e866881..95d78fff9 100644 --- a/tests/test_builtins.py +++ b/tests/test_builtins.py @@ -1,4 +1,5 @@ """Tests the xonsh builtins.""" + import os import re import shutil diff --git a/tests/test_color_tools.py b/tests/test_color_tools.py index 864d24919..dcc8e8d51 100644 --- a/tests/test_color_tools.py +++ b/tests/test_color_tools.py @@ -1,4 +1,5 @@ """Tests color tools.""" + import pytest from xonsh.color_tools import iscolor diff --git a/tests/test_completion_context.py b/tests/test_completion_context.py index 31733aecf..9b77ab7cd 100644 --- a/tests/test_completion_context.py +++ b/tests/test_completion_context.py @@ -738,9 +738,11 @@ MULTIPLE_COMMAND_BORDER_EXAMPLES = tuple( ( ( f"ls{ws1}{X}{kwd}{ws2}echo", - CommandContext((CommandArg("ls"),), 1) - if ws1 - else CommandContext((), 0, prefix="ls"), + ( + CommandContext((CommandArg("ls"),), 1) + if ws1 + else CommandContext((), 0, prefix="ls") + ), ), ) for ws1, ws2, kwd in itertools.product( diff --git a/tests/test_contexts.py b/tests/test_contexts.py index fb3b063d0..578fbf2d3 100644 --- a/tests/test_contexts.py +++ b/tests/test_contexts.py @@ -1,4 +1,5 @@ """Tests xonsh contexts.""" + from textwrap import dedent from xonsh.contexts import Block, Functor diff --git a/tests/test_dirstack_unc.py b/tests/test_dirstack_unc.py index e854daca0..e1f181ccb 100644 --- a/tests/test_dirstack_unc.py +++ b/tests/test_dirstack_unc.py @@ -1,4 +1,5 @@ """Testing dirstack""" + import os import os.path import subprocess diff --git a/tests/test_environ.py b/tests/test_environ.py index 220bcec75..f5beebb3b 100644 --- a/tests/test_environ.py +++ b/tests/test_environ.py @@ -1,4 +1,5 @@ """Tests the xonsh environment.""" + import datetime import os import pathlib diff --git a/tests/test_events.py b/tests/test_events.py index 07384e2d2..6b1fa9250 100644 --- a/tests/test_events.py +++ b/tests/test_events.py @@ -1,4 +1,5 @@ """Event tests""" + import inspect import pytest diff --git a/tests/test_execer.py b/tests/test_execer.py index 90b0284d0..5e367559d 100644 --- a/tests/test_execer.py +++ b/tests/test_execer.py @@ -1,4 +1,5 @@ """Tests the xonsh lexer.""" + import os import pytest diff --git a/tests/test_foreign_shells.py b/tests/test_foreign_shells.py index 5c3b48fd3..c1f63b3e6 100644 --- a/tests/test_foreign_shells.py +++ b/tests/test_foreign_shells.py @@ -1,4 +1,5 @@ """Tests foreign shells.""" + import os import subprocess diff --git a/tests/test_history_json.py b/tests/test_history_json.py index d2e1337e8..ff05dd4ca 100644 --- a/tests/test_history_json.py +++ b/tests/test_history_json.py @@ -1,4 +1,5 @@ """Tests the json history backend.""" + # pylint: disable=protected-access import shlex diff --git a/tests/test_history_sqlite.py b/tests/test_history_sqlite.py index 2fbdbf6b1..fb5e25128 100644 --- a/tests/test_history_sqlite.py +++ b/tests/test_history_sqlite.py @@ -1,4 +1,5 @@ """Tests the xonsh history.""" + # pylint: disable=protected-access import itertools import os diff --git a/tests/test_imphooks.py b/tests/test_imphooks.py index 50118e20b..9f6a40920 100644 --- a/tests/test_imphooks.py +++ b/tests/test_imphooks.py @@ -1,4 +1,5 @@ """Testing xonsh import hooks""" + import os from importlib import import_module diff --git a/tests/test_integrations.py b/tests/test_integrations.py index 91d0e5d0f..84cdecbab 100644 --- a/tests/test_integrations.py +++ b/tests/test_integrations.py @@ -1,6 +1,7 @@ """Tests involving running Xonsh in subproc. This requires Xonsh installed in venv or otherwise available on PATH """ + import os import shutil import subprocess as sp diff --git a/tests/test_jsonutils.py b/tests/test_jsonutils.py index c85a462aa..bbbd8e48b 100644 --- a/tests/test_jsonutils.py +++ b/tests/test_jsonutils.py @@ -1,4 +1,5 @@ """Testing xonsh json hooks""" + import json import pytest diff --git a/tests/test_lazyasd.py b/tests/test_lazyasd.py index 8720fb243..c1594ee65 100644 --- a/tests/test_lazyasd.py +++ b/tests/test_lazyasd.py @@ -1,4 +1,5 @@ """Tests lazy and self destruictive objects.""" + from xonsh.lazyasd import LazyObject # diff --git a/tests/test_lazyjson.py b/tests/test_lazyjson.py index f29482f07..ec2d571c1 100644 --- a/tests/test_lazyjson.py +++ b/tests/test_lazyjson.py @@ -1,4 +1,5 @@ """Tests lazy json functionality.""" + from io import StringIO from xonsh.lazyjson import LazyJSON, LJNode, index, ljdump diff --git a/tests/test_lexer.py b/tests/test_lexer.py index 4c6b45611..3f3804d6b 100644 --- a/tests/test_lexer.py +++ b/tests/test_lexer.py @@ -1,4 +1,5 @@ """Tests the xonsh lexer.""" + import os import sys from collections.abc import Sequence diff --git a/tests/test_main.py b/tests/test_main.py index 773b0ce71..f82f577da 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -1,4 +1,5 @@ """Tests the xonsh main function.""" + import builtins import gc import os diff --git a/tests/test_news.py b/tests/test_news.py index 7a30a8483..e4bb2fdb1 100644 --- a/tests/test_news.py +++ b/tests/test_news.py @@ -1,4 +1,5 @@ """Testing that news entries are well formed.""" + import os import re diff --git a/tests/test_parser.py b/tests/test_parser.py index 05dac8f53..ae57dfa2a 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -1,4 +1,5 @@ """Tests the xonsh parser.""" + import ast import itertools import textwrap diff --git a/tests/test_ptk_highlight.py b/tests/test_ptk_highlight.py index f83d2d93d..6b1dd8dc8 100644 --- a/tests/test_ptk_highlight.py +++ b/tests/test_ptk_highlight.py @@ -1,6 +1,5 @@ """Test XonshLexer for pygments""" - import pytest from pygments.token import ( Error, diff --git a/tests/test_ptk_multiline.py b/tests/test_ptk_multiline.py index b05142f17..a42edd47d 100644 --- a/tests/test_ptk_multiline.py +++ b/tests/test_ptk_multiline.py @@ -1,4 +1,5 @@ """Tests sample inputs to PTK multiline and checks parser response""" + from collections import namedtuple from unittest.mock import MagicMock, patch diff --git a/tests/test_pyghooks.py b/tests/test_pyghooks.py index c2214c22d..2e0658479 100644 --- a/tests/test_pyghooks.py +++ b/tests/test_pyghooks.py @@ -1,4 +1,5 @@ """Tests pygments hooks.""" + import os import pathlib import stat diff --git a/tests/test_shell.py b/tests/test_shell.py index c5ed1b9ae..98a6a176d 100644 --- a/tests/test_shell.py +++ b/tests/test_shell.py @@ -1,4 +1,5 @@ """Testing for ``xonsh.shell.Shell``""" + import os from xonsh.history.dummy import DummyHistory diff --git a/tests/test_tools.py b/tests/test_tools.py index cce196104..f37edc0e6 100644 --- a/tests/test_tools.py +++ b/tests/test_tools.py @@ -1,4 +1,5 @@ """Tests xonsh tools.""" + import datetime as dt import os import pathlib @@ -1426,9 +1427,11 @@ def test_is_logfile_opt(inp, exp): pytest.param("/dev/null", "/dev/null", marks=skip_if_on_windows), pytest.param( "/dev/nonexistent_dev", - "/dev/nonexistent_dev" - if is_writable_file("/dev/nonexistent_dev") - else None, + ( + "/dev/nonexistent_dev" + if is_writable_file("/dev/nonexistent_dev") + else None + ), marks=skip_if_on_windows, ), ("~/log", os.path.expanduser("~/log")), diff --git a/tests/test_wizard.py b/tests/test_wizard.py index af86e696d..300883fd9 100644 --- a/tests/test_wizard.py +++ b/tests/test_wizard.py @@ -1,4 +1,5 @@ """Tests the xonsh lexer.""" + import os import pytest # noqa F401 diff --git a/tests/test_xonfig.py b/tests/test_xonfig.py index 1704a4068..be451a068 100644 --- a/tests/test_xonfig.py +++ b/tests/test_xonfig.py @@ -5,6 +5,7 @@ - xonfig jupyter_kernel """ + import io import re diff --git a/tests/test_xontribs.py b/tests/test_xontribs.py index 3e3197812..cdba54f46 100644 --- a/tests/test_xontribs.py +++ b/tests/test_xontribs.py @@ -1,4 +1,5 @@ """xontrib tests, such as they are""" + import sys import pytest diff --git a/xonsh/aliases.py b/xonsh/aliases.py index ab5b0449c..e75a5c79b 100644 --- a/xonsh/aliases.py +++ b/xonsh/aliases.py @@ -1,4 +1,5 @@ """Aliases for the xonsh shell.""" + import argparse import collections.abc as cabc import functools @@ -85,8 +86,7 @@ class Aliases(cabc.MutableMapping): @tp.overload def register( self, name: str, *, dash_case: bool = True - ) -> tp.Callable[[types.FunctionType], types.FunctionType]: - ... + ) -> tp.Callable[[types.FunctionType], types.FunctionType]: ... def register(self, func_or_name, name=None, dash_case=True): """Decorator to register the given function by name.""" diff --git a/xonsh/ansi_colors.py b/xonsh/ansi_colors.py index bc65a170d..d0b4c402e 100644 --- a/xonsh/ansi_colors.py +++ b/xonsh/ansi_colors.py @@ -1,4 +1,5 @@ """Tools for helping with ANSI color codes.""" + import re import sys import warnings diff --git a/xonsh/ast.py b/xonsh/ast.py index 9b7782c75..52c0ba4a2 100644 --- a/xonsh/ast.py +++ b/xonsh/ast.py @@ -1,4 +1,5 @@ """Abstract Syntax Tree handler""" + # These are imported into our module namespace for the benefit of parser.py. # pylint: disable=unused-import import itertools diff --git a/xonsh/base_shell.py b/xonsh/base_shell.py index 5ff192b3f..23659a342 100644 --- a/xonsh/base_shell.py +++ b/xonsh/base_shell.py @@ -1,4 +1,5 @@ """The base class for xonsh shell""" + import io import os import sys diff --git a/xonsh/built_ins.py b/xonsh/built_ins.py index 7b7aa5370..ba3b9b870 100644 --- a/xonsh/built_ins.py +++ b/xonsh/built_ins.py @@ -3,6 +3,7 @@ Note that this module is named 'built_ins' so as not to be confused with the special Python builtins module. """ + import atexit import builtins import collections.abc as cabc diff --git a/xonsh/cli_utils.py b/xonsh/cli_utils.py index 0fc650f12..45ffeb46c 100644 --- a/xonsh/cli_utils.py +++ b/xonsh/cli_utils.py @@ -442,9 +442,7 @@ class ArgparseCompleter: nargs = ( act.nargs if isinstance(act.nargs, int) - else args_len + 1 - if act.nargs in {ap.ONE_OR_MORE, ap.ZERO_OR_MORE} - else 1 + else args_len + 1 if act.nargs in {ap.ONE_OR_MORE, ap.ZERO_OR_MORE} else 1 ) if len(self.remaining_args) >= nargs: # consume n-number of args diff --git a/xonsh/codecache.py b/xonsh/codecache.py index 385596b2c..e5a5e95ef 100644 --- a/xonsh/codecache.py +++ b/xonsh/codecache.py @@ -1,4 +1,5 @@ """Tools for caching xonsh code.""" + import hashlib import marshal import os diff --git a/xonsh/color_tools.py b/xonsh/color_tools.py index 1acb3f97a..a0912b052 100644 --- a/xonsh/color_tools.py +++ b/xonsh/color_tools.py @@ -5,6 +5,7 @@ color codes. Parts of this file were originally forked from Micah Elliott http://MicahElliott.com Copyright (C) 2011 Micah Elliott. All rights reserved. WTFPL http://sam.zoy.org/wtfpl/ """ + import math import re diff --git a/xonsh/commands_cache.py b/xonsh/commands_cache.py index eecca32fc..f51b49a34 100644 --- a/xonsh/commands_cache.py +++ b/xonsh/commands_cache.py @@ -5,6 +5,7 @@ A background predictor is a function that accepts a single argument list and returns whether or not the process can be run in the background (returns True) or must be run the foreground (returns False). """ + import argparse import collections.abc as cabc import os diff --git a/xonsh/completer.py b/xonsh/completer.py index 7ab8af21e..918c88e1b 100644 --- a/xonsh/completer.py +++ b/xonsh/completer.py @@ -1,4 +1,5 @@ """A (tab-)completer for xonsh.""" + import collections.abc as cabc import sys import typing as tp diff --git a/xonsh/completers/base.py b/xonsh/completers/base.py index 354b3e57b..11f7931ce 100644 --- a/xonsh/completers/base.py +++ b/xonsh/completers/base.py @@ -1,4 +1,5 @@ """Base completer for xonsh.""" + import collections.abc as cabc from xonsh.completers.commands import complete_command diff --git a/xonsh/completers/bash_completion.py b/xonsh/completers/bash_completion.py index ff0ad50f2..910049dfb 100644 --- a/xonsh/completers/bash_completion.py +++ b/xonsh/completers/bash_completion.py @@ -1,6 +1,7 @@ """This module provides the implementation for the retrieving completion results from bash. """ + import functools # developer note: this file should not perform any action on import. diff --git a/xonsh/completers/init.py b/xonsh/completers/init.py index 57c8d2afa..6a8fe37e1 100644 --- a/xonsh/completers/init.py +++ b/xonsh/completers/init.py @@ -1,4 +1,5 @@ """Constructor for xonsh completer objects.""" + import collections from xonsh.completers._aliases import complete_aliases diff --git a/xonsh/completers/python.py b/xonsh/completers/python.py index 5f9e3d8e6..467d58876 100644 --- a/xonsh/completers/python.py +++ b/xonsh/completers/python.py @@ -1,4 +1,5 @@ """Completers for Python code""" + import builtins import collections.abc as cabc import inspect diff --git a/xonsh/completers/tools.py b/xonsh/completers/tools.py index c9e121246..f686f0adc 100644 --- a/xonsh/completers/tools.py +++ b/xonsh/completers/tools.py @@ -1,4 +1,5 @@ """Xonsh completer tools.""" + import inspect import os import shlex diff --git a/xonsh/contexts.py b/xonsh/contexts.py index 2f31fcdc8..d55f97767 100644 --- a/xonsh/contexts.py +++ b/xonsh/contexts.py @@ -1,4 +1,5 @@ """Context management tools for xonsh.""" + import sys import textwrap from collections.abc import Mapping diff --git a/xonsh/diff_history.py b/xonsh/diff_history.py index 78748190b..6093b5543 100644 --- a/xonsh/diff_history.py +++ b/xonsh/diff_history.py @@ -1,4 +1,5 @@ """Tools for diff'ing two xonsh history files in a meaningful fashion.""" + import datetime import difflib import itertools diff --git a/xonsh/dirstack.py b/xonsh/dirstack.py index 2853e1016..7b3238c28 100644 --- a/xonsh/dirstack.py +++ b/xonsh/dirstack.py @@ -1,6 +1,7 @@ """Directory stack and associated utilities for the xonsh shell. https://www.gnu.org/software/bash/manual/html_node/Directory-Stack-Builtins.html """ + import contextlib import glob import os diff --git a/xonsh/environ.py b/xonsh/environ.py index f4c411d8b..36144902d 100644 --- a/xonsh/environ.py +++ b/xonsh/environ.py @@ -1,4 +1,5 @@ """Environment for the xonsh shell.""" + import collections.abc as cabc import contextlib import inspect @@ -407,9 +408,11 @@ class LsColors(cabc.MutableMapping): + "=" + ";".join( [ - LsColors.target_value - if key in self._targets - else ansi_color_name_to_escape_code(v, cmap=style) + ( + LsColors.target_value + if key in self._targets + else ansi_color_name_to_escape_code(v, cmap=style) + ) for v in val ] ) diff --git a/xonsh/events.py b/xonsh/events.py index 7f6012c52..4b8d5e66a 100644 --- a/xonsh/events.py +++ b/xonsh/events.py @@ -7,6 +7,7 @@ The best way to "declare" an event is something like:: events.doc('on_spam', "Comes with eggs") """ + import abc import collections.abc import inspect diff --git a/xonsh/execer.py b/xonsh/execer.py index a471fab01..741f06212 100644 --- a/xonsh/execer.py +++ b/xonsh/execer.py @@ -1,4 +1,5 @@ """Implements the xonsh executer.""" + import builtins import collections.abc as cabc import inspect diff --git a/xonsh/foreign_shells.py b/xonsh/foreign_shells.py index 5f9377b4b..c85ee6c5a 100644 --- a/xonsh/foreign_shells.py +++ b/xonsh/foreign_shells.py @@ -1,4 +1,5 @@ """Tools to help interface with foreign shells, such as Bash.""" + import collections.abc as cabc import functools import os diff --git a/xonsh/history/base.py b/xonsh/history/base.py index d72413111..6000b6c27 100644 --- a/xonsh/history/base.py +++ b/xonsh/history/base.py @@ -1,4 +1,5 @@ """Base class of Xonsh History backends.""" + import functools import re import types diff --git a/xonsh/history/dummy.py b/xonsh/history/dummy.py index 5f87f6acb..150ca1c06 100644 --- a/xonsh/history/dummy.py +++ b/xonsh/history/dummy.py @@ -1,4 +1,5 @@ """Implements the xonsh history backend.""" + import collections from xonsh.history.base import History diff --git a/xonsh/history/json.py b/xonsh/history/json.py index 06201d2d6..a9f2f7c5e 100644 --- a/xonsh/history/json.py +++ b/xonsh/history/json.py @@ -1,4 +1,5 @@ """Implements JSON version of xonsh history backend.""" + import collections import collections.abc as cabc import os diff --git a/xonsh/history/main.py b/xonsh/history/main.py index a97f75076..df1b23adf 100644 --- a/xonsh/history/main.py +++ b/xonsh/history/main.py @@ -1,4 +1,5 @@ """Main entry points of the xonsh history.""" + import datetime import json import os diff --git a/xonsh/history/sqlite.py b/xonsh/history/sqlite.py index 33dd0b307..e17431b0e 100644 --- a/xonsh/history/sqlite.py +++ b/xonsh/history/sqlite.py @@ -1,4 +1,5 @@ """Implements the xonsh history backend via sqlite3.""" + import collections import json import os diff --git a/xonsh/imphooks.py b/xonsh/imphooks.py index 3d7cfa6d6..c61f577d8 100644 --- a/xonsh/imphooks.py +++ b/xonsh/imphooks.py @@ -2,6 +2,7 @@ This module registers the hooks it defines when it is imported. """ + import contextlib import importlib import os diff --git a/xonsh/inspectors.py b/xonsh/inspectors.py index 476e90476..d07895775 100644 --- a/xonsh/inspectors.py +++ b/xonsh/inspectors.py @@ -7,6 +7,7 @@ This file was forked from the IPython project: * Copyright (c) 2001, Janko Hauser * Copyright (c) 2001, Nathaniel Gray """ + import inspect import itertools import linecache diff --git a/xonsh/jobs.py b/xonsh/jobs.py index 94ccf524d..097346a1b 100644 --- a/xonsh/jobs.py +++ b/xonsh/jobs.py @@ -1,4 +1,5 @@ """Job control for the xonsh shell.""" + import collections import contextlib import ctypes diff --git a/xonsh/jsonutils.py b/xonsh/jsonutils.py index 0805d9641..6358e2b76 100644 --- a/xonsh/jsonutils.py +++ b/xonsh/jsonutils.py @@ -1,6 +1,7 @@ """Custom tools for managing JSON serialization / deserialization of xonsh objects. """ + import functools from xonsh.tools import EnvPath diff --git a/xonsh/lazyasd.py b/xonsh/lazyasd.py index 0e457301a..55f91cd50 100644 --- a/xonsh/lazyasd.py +++ b/xonsh/lazyasd.py @@ -1,4 +1,5 @@ """Lazy and self destructive containers for speeding up module import.""" + # Copyright 2015-2016, the xonsh developers. All rights reserved. import builtins import collections.abc as cabc diff --git a/xonsh/lazyimps.py b/xonsh/lazyimps.py index b9411495f..ab3388f11 100644 --- a/xonsh/lazyimps.py +++ b/xonsh/lazyimps.py @@ -1,4 +1,5 @@ """Lazy imports that may apply across the xonsh package.""" + import importlib import os diff --git a/xonsh/lazyjson.py b/xonsh/lazyjson.py index 06072e69f..582b6758e 100644 --- a/xonsh/lazyjson.py +++ b/xonsh/lazyjson.py @@ -1,4 +1,5 @@ """Implements a lazy JSON file class that wraps around json data.""" + import collections.abc as cabc import contextlib import io diff --git a/xonsh/lexer.py b/xonsh/lexer.py index 4510a8a4d..a9c904ab2 100644 --- a/xonsh/lexer.py +++ b/xonsh/lexer.py @@ -2,6 +2,7 @@ Written using a hybrid of ``tokenize`` and PLY. """ + import io # 'keyword' interferes with ast.keyword @@ -266,11 +267,7 @@ def _make_matcher_handler(tok, typ, pymode, ender, handlers): matcher = ( ")" if tok.endswith("(") - else "}" - if tok.endswith("{") - else "]" - if tok.endswith("[") - else None + else "}" if tok.endswith("{") else "]" if tok.endswith("[") else None ) def _inner_handler(state, token): diff --git a/xonsh/lib/os.py b/xonsh/lib/os.py index e6bb91219..33dbdfdc3 100644 --- a/xonsh/lib/os.py +++ b/xonsh/lib/os.py @@ -1,5 +1,6 @@ """Xonsh extension of the standard library os module, using xonsh for subprocess calls""" + import sys from xonsh.built_ins import subproc_uncaptured diff --git a/xonsh/macutils.py b/xonsh/macutils.py index e1491b9f7..47bf76c30 100644 --- a/xonsh/macutils.py +++ b/xonsh/macutils.py @@ -1,4 +1,5 @@ """Provides some Mac / Darwin based utility functions for xonsh.""" + from ctypes import byref, c_uint, create_string_buffer from xonsh.platform import LIBC diff --git a/xonsh/main.py b/xonsh/main.py index 4a641560b..efd8f6a68 100644 --- a/xonsh/main.py +++ b/xonsh/main.py @@ -1,4 +1,5 @@ """The main xonsh script.""" + import argparse import builtins import contextlib diff --git a/xonsh/openpy.py b/xonsh/openpy.py index 01b34651d..d62396dae 100644 --- a/xonsh/openpy.py +++ b/xonsh/openpy.py @@ -11,6 +11,7 @@ This file was forked from the IPython project: * Copyright (c) 2001, Janko Hauser * Copyright (c) 2001, Nathaniel Gray """ + import io import re diff --git a/xonsh/parser.py b/xonsh/parser.py index 783da21a6..3916b0d73 100644 --- a/xonsh/parser.py +++ b/xonsh/parser.py @@ -1,4 +1,5 @@ """Implements the xonsh parser.""" + from xonsh.lazyasd import lazyobject from xonsh.platform import PYTHON_VERSION_INFO diff --git a/xonsh/parsers/base.py b/xonsh/parsers/base.py index 1dcf1d16f..e5ede659c 100644 --- a/xonsh/parsers/base.py +++ b/xonsh/parsers/base.py @@ -1,4 +1,5 @@ """Implements the base xonsh parser.""" + import os import re import textwrap diff --git a/xonsh/parsers/completion_context.py b/xonsh/parsers/completion_context.py index aaed9cd94..dd5a132cb 100644 --- a/xonsh/parsers/completion_context.py +++ b/xonsh/parsers/completion_context.py @@ -1,6 +1,7 @@ """Implements the xonsh (tab-)completion context parser. This parser is meant to parse a (possibly incomplete) command line. """ + import enum import os import re @@ -208,8 +209,7 @@ class Spanned(Generic[T]): expansion_obj: Union[ "ExpandableObject", ExpansionOperation, Missing ] = Missing.MISSING, - ) -> "Spanned[T]": - ... + ) -> "Spanned[T]": ... @overload def replace( @@ -222,8 +222,7 @@ class Spanned(Generic[T]): expansion_obj: Union[ "ExpandableObject", ExpansionOperation, Missing ] = Missing.MISSING, - ) -> "Spanned[T2]": - ... + ) -> "Spanned[T2]": ... def replace( self, diff --git a/xonsh/parsers/fstring_adaptor.py b/xonsh/parsers/fstring_adaptor.py index 6ce7de5d0..c4fb1da32 100644 --- a/xonsh/parsers/fstring_adaptor.py +++ b/xonsh/parsers/fstring_adaptor.py @@ -1,4 +1,5 @@ """Implements helper class for parsing Xonsh syntax within f-strings.""" + import re from ast import parse as pyparse diff --git a/xonsh/parsers/v36.py b/xonsh/parsers/v36.py index 256cd0f91..7319ea3e2 100644 --- a/xonsh/parsers/v36.py +++ b/xonsh/parsers/v36.py @@ -1,4 +1,5 @@ """Implements the xonsh parser for Python v3.6.""" + import xonsh.ast as ast from xonsh.parsers.base import BaseParser, lopen_loc, store_ctx diff --git a/xonsh/parsers/v38.py b/xonsh/parsers/v38.py index d6b39c129..afec88c70 100644 --- a/xonsh/parsers/v38.py +++ b/xonsh/parsers/v38.py @@ -1,4 +1,5 @@ """Implements the xonsh parser for Python v3.8.""" + import xonsh.ast as ast from xonsh.parsers.base import store_ctx from xonsh.parsers.v36 import Parser as ThreeSixParser diff --git a/xonsh/platform.py b/xonsh/platform.py index 6cd80fcbf..9feb0a512 100644 --- a/xonsh/platform.py +++ b/xonsh/platform.py @@ -2,6 +2,7 @@ compatibility layers to make use of the 'best' implementation available on a platform. """ + import collections.abc as cabc import ctypes # noqa import functools diff --git a/xonsh/pretty.py b/xonsh/pretty.py index e097340ee..082d17ea0 100644 --- a/xonsh/pretty.py +++ b/xonsh/pretty.py @@ -77,6 +77,7 @@ without open / close parameters. You can also use this code:: Portions (c) 2009 by Robert Kern. :license: BSD License. """ + import collections import contextlib import datetime diff --git a/xonsh/proc.py b/xonsh/proc.py index d23d53ea1..e7a3ba9d6 100644 --- a/xonsh/proc.py +++ b/xonsh/proc.py @@ -1,4 +1,5 @@ """xonsh.proc is deprecated""" + from xonsh.lazyasd import lazyobject from xonsh.tools import print_warning diff --git a/xonsh/procs/pipelines.py b/xonsh/procs/pipelines.py index 16128e58b..bc8c8404d 100644 --- a/xonsh/procs/pipelines.py +++ b/xonsh/procs/pipelines.py @@ -1,4 +1,5 @@ """Command pipeline tools.""" + import io import os import re diff --git a/xonsh/procs/posix.py b/xonsh/procs/posix.py index 762e88e1c..043555155 100644 --- a/xonsh/procs/posix.py +++ b/xonsh/procs/posix.py @@ -1,4 +1,5 @@ """Interface for running subprocess-mode commands on posix systems.""" + import array import io import os diff --git a/xonsh/procs/proxies.py b/xonsh/procs/proxies.py index 2987a2823..ce0ec42fb 100644 --- a/xonsh/procs/proxies.py +++ b/xonsh/procs/proxies.py @@ -6,6 +6,7 @@ The contents of `subprocess.py` (and, thus, the reproduced methods) are Copyright (c) 2003-2005 by Peter Astrand and were licensed to the Python Software foundation under a Contributor Agreement. """ + import collections.abc as cabc import functools import inspect @@ -512,12 +513,12 @@ class ProcProxyThread(threading.Thread): if self.env and self.env.get("__ALIAS_NAME"): alias_stack += ":" + self.env["__ALIAS_NAME"] - with STDOUT_DISPATCHER.register(sp_stdout), STDERR_DISPATCHER.register( - sp_stderr - ), xt.redirect_stdout(STDOUT_DISPATCHER), xt.redirect_stderr( - STDERR_DISPATCHER - ), XSH.env.swap( - self.env, __ALIAS_STACK=alias_stack + with ( + STDOUT_DISPATCHER.register(sp_stdout), + STDERR_DISPATCHER.register(sp_stderr), + xt.redirect_stdout(STDOUT_DISPATCHER), + xt.redirect_stderr(STDERR_DISPATCHER), + XSH.env.swap(self.env, __ALIAS_STACK=alias_stack), ): r = self.f(self.args, sp_stdin, sp_stdout, sp_stderr, spec, spec.stack) except SystemExit as e: diff --git a/xonsh/procs/readers.py b/xonsh/procs/readers.py index 9d5d9ab7a..75eb570e9 100644 --- a/xonsh/procs/readers.py +++ b/xonsh/procs/readers.py @@ -1,4 +1,5 @@ """File handle readers and related tools.""" + import ctypes import io import os diff --git a/xonsh/procs/specs.py b/xonsh/procs/specs.py index 5da832bbb..9a0c639ff 100644 --- a/xonsh/procs/specs.py +++ b/xonsh/procs/specs.py @@ -1,4 +1,5 @@ """Subprocess specification and related utilities.""" + import contextlib import inspect import io diff --git a/xonsh/prompt/env.py b/xonsh/prompt/env.py index 2edfd17ca..30cf0cabe 100644 --- a/xonsh/prompt/env.py +++ b/xonsh/prompt/env.py @@ -1,4 +1,5 @@ """Prompt formatter for virtualenv and others""" + import functools import re from pathlib import Path diff --git a/xonsh/prompt/times.py b/xonsh/prompt/times.py index ff6ece84c..231392c5d 100644 --- a/xonsh/prompt/times.py +++ b/xonsh/prompt/times.py @@ -1,4 +1,5 @@ """date & time related prompt formatter""" + import time from xonsh.built_ins import XSH diff --git a/xonsh/prompt/vc.py b/xonsh/prompt/vc.py index 0f5dedcc4..f1b16fab7 100644 --- a/xonsh/prompt/vc.py +++ b/xonsh/prompt/vc.py @@ -1,4 +1,5 @@ """Prompt formatter for simple version control branches""" + # pylint:disable=no-member, invalid-name import contextlib import os diff --git a/xonsh/ptk_shell/completer.py b/xonsh/ptk_shell/completer.py index a3b458a7a..8f05adf27 100644 --- a/xonsh/ptk_shell/completer.py +++ b/xonsh/ptk_shell/completer.py @@ -1,4 +1,5 @@ """Completer implementation to use with prompt_toolkit.""" + import os from prompt_toolkit.application.current import get_app diff --git a/xonsh/ptk_shell/shell.py b/xonsh/ptk_shell/shell.py index 5f5880400..a14838bd0 100644 --- a/xonsh/ptk_shell/shell.py +++ b/xonsh/ptk_shell/shell.py @@ -1,4 +1,5 @@ """The prompt_toolkit based xonsh shell.""" + import os import re import sys diff --git a/xonsh/pyghooks.py b/xonsh/pyghooks.py index d0a82d000..a33f2bb50 100644 --- a/xonsh/pyghooks.py +++ b/xonsh/pyghooks.py @@ -1,4 +1,5 @@ """Hooks for pygments syntax highlighting.""" + import os import re import stat @@ -555,12 +556,16 @@ def register_custom_pygments_style( (Style,), { "styles": custom_styles, - "highlight_color": highlight_color - if highlight_color is not None - else base_style.highlight_color, - "background_color": background_color - if background_color is not None - else base_style.background_color, + "highlight_color": ( + highlight_color + if highlight_color is not None + else base_style.highlight_color + ), + "background_color": ( + background_color + if background_color is not None + else base_style.background_color + ), }, ) diff --git a/xonsh/pygments_cache.py b/xonsh/pygments_cache.py index 228673221..e667bc5d1 100644 --- a/xonsh/pygments_cache.py +++ b/xonsh/pygments_cache.py @@ -13,6 +13,7 @@ The cache file is created on first use, if it does not already exist. """ + import importlib import os import typing as tp diff --git a/xonsh/pytest/tools.py b/xonsh/pytest/tools.py index 314043b16..2413e4ca4 100644 --- a/xonsh/pytest/tools.py +++ b/xonsh/pytest/tools.py @@ -1,4 +1,5 @@ """Tests the xonsh lexer.""" + import ast import copy import os diff --git a/xonsh/readline_shell.py b/xonsh/readline_shell.py index fb5fa48b2..a5c4f39c8 100644 --- a/xonsh/readline_shell.py +++ b/xonsh/readline_shell.py @@ -9,6 +9,7 @@ are included from the IPython project. The IPython project is: * Copyright (c) 2001, Nathaniel Gray """ + import cmd import collections import importlib diff --git a/xonsh/shell.py b/xonsh/shell.py index 8d1b5a71c..f54c53509 100644 --- a/xonsh/shell.py +++ b/xonsh/shell.py @@ -1,4 +1,5 @@ """The xonsh shell""" + import difflib import sys import time diff --git a/xonsh/style_tools.py b/xonsh/style_tools.py index 43142c8b6..c49bc358b 100644 --- a/xonsh/style_tools.py +++ b/xonsh/style_tools.py @@ -1,4 +1,5 @@ """Xonsh color styling tools that simulate pygments, when it is unavailable.""" + from collections import defaultdict from xonsh.color_tools import RE_BACKGROUND, iscolor, warn_deprecated_no_color diff --git a/xonsh/timings.py b/xonsh/timings.py index c4bf86080..cdb7484a4 100644 --- a/xonsh/timings.py +++ b/xonsh/timings.py @@ -6,6 +6,7 @@ The following time_it alias and Timer was forked from the IPython project: * Copyright (c) 2001, Janko Hauser * Copyright (c) 2001, Nathaniel Gray """ + import gc import itertools import math diff --git a/xonsh/tools.py b/xonsh/tools.py index 392f2de4c..e8f819687 100644 --- a/xonsh/tools.py +++ b/xonsh/tools.py @@ -16,6 +16,7 @@ Implementations: * indent() """ + import ast import collections import collections.abc as cabc @@ -1790,9 +1791,7 @@ def to_completion_mode(x): y = ( "default" if y in ("", "d", "xonsh", "none", "def") - else "menu-complete" - if y in ("m", "menu", "menu-completion") - else y + else "menu-complete" if y in ("m", "menu", "menu-completion") else y ) if y not in CANONIC_COMPLETION_MODES: warnings.warn( diff --git a/xonsh/tracer.py b/xonsh/tracer.py index 5ffd0131d..e4ef020dc 100644 --- a/xonsh/tracer.py +++ b/xonsh/tracer.py @@ -1,4 +1,5 @@ """Implements a xonsh tracer.""" + import importlib import inspect import linecache diff --git a/xonsh/webconfig/file_writes.py b/xonsh/webconfig/file_writes.py index 59ddb4d16..d22a2b301 100644 --- a/xonsh/webconfig/file_writes.py +++ b/xonsh/webconfig/file_writes.py @@ -1,4 +1,5 @@ """functions to update rc files""" + import os import re import typing as tp diff --git a/xonsh/webconfig/xonsh_data.py b/xonsh/webconfig/xonsh_data.py index 9f1232fe1..acf3fcfea 100644 --- a/xonsh/webconfig/xonsh_data.py +++ b/xonsh/webconfig/xonsh_data.py @@ -1,4 +1,5 @@ """script for compiling elm source and dumping it to the js folder.""" + import functools import io import logging diff --git a/xonsh/winutils.py b/xonsh/winutils.py index 485513076..438b4324c 100644 --- a/xonsh/winutils.py +++ b/xonsh/winutils.py @@ -20,6 +20,7 @@ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ + import ctypes import os import subprocess diff --git a/xonsh/wizard.py b/xonsh/wizard.py index 2cacc0cd2..d085b7a98 100644 --- a/xonsh/wizard.py +++ b/xonsh/wizard.py @@ -1,5 +1,6 @@ """Tools for creating command-line and web-based wizards from a tree of nodes. """ + import ast import collections.abc as cabc import fnmatch diff --git a/xonsh/xonfig.py b/xonsh/xonfig.py index 9d011a219..ffa039a7f 100644 --- a/xonsh/xonfig.py +++ b/xonsh/xonfig.py @@ -1,4 +1,5 @@ """The xonsh configuration (xonfig) utility.""" + import ast import collections import contextlib diff --git a/xonsh/xontribs.py b/xonsh/xontribs.py index 9601edd5f..40ea0821d 100644 --- a/xonsh/xontribs.py +++ b/xonsh/xontribs.py @@ -1,4 +1,5 @@ """Tools for helping manage xontributions.""" + import contextlib import importlib import importlib.util diff --git a/xonsh/xoreutils/cat.py b/xonsh/xoreutils/cat.py index 5519aeed6..56de1eaa6 100644 --- a/xonsh/xoreutils/cat.py +++ b/xonsh/xoreutils/cat.py @@ -1,4 +1,5 @@ """Implements a cat command for xonsh.""" + import os import sys import time diff --git a/xonsh/xoreutils/pwd.py b/xonsh/xoreutils/pwd.py index 189773e91..b72a020d4 100644 --- a/xonsh/xoreutils/pwd.py +++ b/xonsh/xoreutils/pwd.py @@ -1,4 +1,5 @@ """A pwd implementation for xonsh.""" + import os from xonsh.built_ins import XSH diff --git a/xonsh/xoreutils/tty.py b/xonsh/xoreutils/tty.py index 4453eea0c..a67cdf67f 100644 --- a/xonsh/xoreutils/tty.py +++ b/xonsh/xoreutils/tty.py @@ -1,4 +1,5 @@ """A tty implementation for xonsh""" + import os import sys diff --git a/xonsh/xoreutils/ulimit.py b/xonsh/xoreutils/ulimit.py index 99eb41d3a..d5398cab2 100644 --- a/xonsh/xoreutils/ulimit.py +++ b/xonsh/xoreutils/ulimit.py @@ -1,4 +1,5 @@ """An ulimit implementation for xonsh.""" + import resource from xonsh.tools import print_exception diff --git a/xonsh/xoreutils/uptime.py b/xonsh/xoreutils/uptime.py index 7ff1df565..3af800598 100644 --- a/xonsh/xoreutils/uptime.py +++ b/xonsh/xoreutils/uptime.py @@ -10,6 +10,7 @@ to standard output. This file was forked from the uptime project: https://github.com/Cairnarvon/uptime Copyright (c) 2012, Koen Crolla, All rights reserved. """ + import contextlib import ctypes import functools diff --git a/xonsh/xoreutils/which.py b/xonsh/xoreutils/which.py index 728fe3282..5f4c42f12 100644 --- a/xonsh/xoreutils/which.py +++ b/xonsh/xoreutils/which.py @@ -1,4 +1,5 @@ """Implements the which xoreutil.""" + import argparse import functools import os diff --git a/xontrib/coreutils.py b/xontrib/coreutils.py index 7384b0e34..d84399e33 100644 --- a/xontrib/coreutils.py +++ b/xontrib/coreutils.py @@ -14,6 +14,7 @@ posix command line utility with the same name. This is because these tools avoid the need for a full subprocess call. Additionally, these tools are cross-platform. """ + from xonsh.built_ins import XonshSession from xonsh.platform import ON_POSIX from xonsh.xoreutils.cat import cat