From 6491ade80685a586d37d60fab0c3758f6e1ea992 Mon Sep 17 00:00:00 2001 From: KotlinIsland Date: Fri, 4 Nov 2022 10:05:05 +1000 Subject: [PATCH] format with isort --- poethepoet/__init__.py | 1 + poethepoet/__main__.py | 1 - poethepoet/app.py | 5 +++-- poethepoet/completion/zsh.py | 1 + poethepoet/config.py | 6 +++-- poethepoet/context.py | 14 ++++-------- poethepoet/env/cache.py | 7 ++---- poethepoet/env/manager.py | 9 ++------ poethepoet/env/parse.py | 2 +- poethepoet/executor/base.py | 6 +++-- poethepoet/executor/poetry.py | 5 +++-- poethepoet/executor/simple.py | 1 + poethepoet/executor/virtualenv.py | 3 ++- poethepoet/helpers/python.py | 4 ++-- poethepoet/plugin.py | 13 ++++++----- poethepoet/task/args.py | 2 +- poethepoet/task/base.py | 10 ++++----- poethepoet/task/cmd.py | 14 ++++-------- poethepoet/task/graph.py | 3 ++- poethepoet/task/ref.py | 14 +++--------- poethepoet/task/script.py | 21 +++++------------- poethepoet/task/sequence.py | 5 +++-- poethepoet/task/shell.py | 5 +++-- poethepoet/ui.py | 6 +++-- poethepoet/virtualenv.py | 2 +- tests/conftest.py | 22 ++++++++++--------- .../poe_test_package/__init__.py | 1 - tests/fixtures/venv_project/scripts.py | 2 +- tests/test_cli.py | 3 ++- tests/test_envfile.py | 2 +- tests/test_executors.py | 3 ++- tests/test_poe_config.py | 2 +- tests/test_poetry_plugin.py | 3 ++- tests/test_shell_task.py | 3 ++- tests/unit/test_parse_env_file.py | 3 ++- 35 files changed, 94 insertions(+), 110 deletions(-) diff --git a/poethepoet/__init__.py b/poethepoet/__init__.py index d3e14a59..d5a0f16a 100644 --- a/poethepoet/__init__.py +++ b/poethepoet/__init__.py @@ -26,6 +26,7 @@ def main(): return from pathlib import Path + from .app import PoeThePoet app = PoeThePoet(cwd=Path(".").resolve(), output=sys.stdout) diff --git a/poethepoet/__main__.py b/poethepoet/__main__.py index 29cb88f3..2fa07aad 100644 --- a/poethepoet/__main__.py +++ b/poethepoet/__main__.py @@ -1,6 +1,5 @@ import sys - if __name__ == "__main__": from poethepoet import main diff --git a/poethepoet/app.py b/poethepoet/app.py index 2b5577c3..c27fcf21 100644 --- a/poethepoet/app.py +++ b/poethepoet/app.py @@ -1,7 +1,8 @@ import os -from pathlib import Path import sys -from typing import Any, Dict, IO, Mapping, Optional, Sequence, Tuple, Union +from pathlib import Path +from typing import IO, Any, Dict, Mapping, Optional, Sequence, Tuple, Union + from .config import PoeConfig from .context import RunContext from .exceptions import ExecutionError, PoeException diff --git a/poethepoet/completion/zsh.py b/poethepoet/completion/zsh.py index 1658f4ba..bb72072f 100644 --- a/poethepoet/completion/zsh.py +++ b/poethepoet/completion/zsh.py @@ -7,6 +7,7 @@ def get_zsh_completion_script() -> str: script for poe generated from the argparses config """ from pathlib import Path + from ..app import PoeThePoet # build and interogate the argument parser as the normal cli would diff --git a/poethepoet/config.py b/poethepoet/config.py index deea4a5c..9ba52117 100644 --- a/poethepoet/config.py +++ b/poethepoet/config.py @@ -1,7 +1,9 @@ import json from pathlib import Path -import tomli from typing import Any, Dict, Mapping, Optional, Sequence, Tuple, Union + +import tomli + from .exceptions import PoeException @@ -113,8 +115,8 @@ def load(self, target_dir: Optional[str] = None): self._load_includes(self._project_dir) def validate(self): - from .task import PoeTask from .executor import PoeExecutor + from .task import PoeTask # Validate keys supported_keys = {"tasks", *self.__options__} diff --git a/poethepoet/context.py b/poethepoet/context.py index fb9237e3..fd818b93 100644 --- a/poethepoet/context.py +++ b/poethepoet/context.py @@ -1,15 +1,9 @@ -from pathlib import Path import re -from typing import ( - Any, - Dict, - Mapping, - Optional, - Tuple, - TYPE_CHECKING, -) -from .executor import PoeExecutor +from pathlib import Path +from typing import TYPE_CHECKING, Any, Dict, Mapping, Optional, Tuple + from .env.manager import EnvVarsManager +from .executor import PoeExecutor if TYPE_CHECKING: from .config import PoeConfig diff --git a/poethepoet/env/cache.py b/poethepoet/env/cache.py index 01a1607c..5075e497 100644 --- a/poethepoet/env/cache.py +++ b/poethepoet/env/cache.py @@ -1,9 +1,6 @@ from pathlib import Path -from typing import ( - Dict, - Optional, - TYPE_CHECKING, -) +from typing import TYPE_CHECKING, Dict, Optional + from ..exceptions import ExecutionError from .parse import parse_env_file diff --git a/poethepoet/env/manager.py b/poethepoet/env/manager.py index 46200906..68bb4899 100644 --- a/poethepoet/env/manager.py +++ b/poethepoet/env/manager.py @@ -1,11 +1,6 @@ from pathlib import Path -from typing import ( - Dict, - Mapping, - Optional, - Union, - TYPE_CHECKING, -) +from typing import TYPE_CHECKING, Dict, Mapping, Optional, Union + from .cache import EnvFileCache from .template import apply_envvars_to_template diff --git a/poethepoet/env/parse.py b/poethepoet/env/parse.py index c813daa6..a02f2725 100644 --- a/poethepoet/env/parse.py +++ b/poethepoet/env/parse.py @@ -1,5 +1,5 @@ -from enum import Enum import re +from enum import Enum from typing import Iterable, Optional, Sequence diff --git a/poethepoet/executor/base.py b/poethepoet/executor/base.py index 14b525e4..bb86040b 100644 --- a/poethepoet/executor/base.py +++ b/poethepoet/executor/base.py @@ -1,8 +1,9 @@ import os import signal -from subprocess import Popen, PIPE import sys +from subprocess import PIPE, Popen from typing import ( + TYPE_CHECKING, Any, Dict, Mapping, @@ -11,15 +12,16 @@ Sequence, Tuple, Type, - TYPE_CHECKING, Union, ) + from ..env.manager import EnvVarsManager from ..exceptions import ExecutionError, PoeException from ..virtualenv import Virtualenv if TYPE_CHECKING: from pathlib import Path + from ..context import RunContext # TODO: maybe invert the control so the executor is given a task to run? diff --git a/poethepoet/executor/poetry.py b/poethepoet/executor/poetry.py index e11e7de9..2708e76d 100644 --- a/poethepoet/executor/poetry.py +++ b/poethepoet/executor/poetry.py @@ -1,9 +1,10 @@ -from subprocess import Popen, PIPE import os -from pathlib import Path import shutil import sys +from pathlib import Path +from subprocess import PIPE, Popen from typing import Dict, Optional, Sequence, Type + from ..virtualenv import Virtualenv from .base import PoeExecutor diff --git a/poethepoet/executor/simple.py b/poethepoet/executor/simple.py index cb92085d..e81309f8 100644 --- a/poethepoet/executor/simple.py +++ b/poethepoet/executor/simple.py @@ -1,4 +1,5 @@ from typing import Dict, Type + from .base import PoeExecutor diff --git a/poethepoet/executor/virtualenv.py b/poethepoet/executor/virtualenv.py index 164c6fcf..5e2519cc 100644 --- a/poethepoet/executor/virtualenv.py +++ b/poethepoet/executor/virtualenv.py @@ -1,7 +1,8 @@ from typing import Any, Dict, Optional, Sequence, Type -from .base import PoeExecutor + from ..exceptions import PoeException from ..virtualenv import Virtualenv +from .base import PoeExecutor class VirtualenvExecutor(PoeExecutor): diff --git a/poethepoet/helpers/python.py b/poethepoet/helpers/python.py index c6a22cb4..fe73d209 100644 --- a/poethepoet/helpers/python.py +++ b/poethepoet/helpers/python.py @@ -3,12 +3,12 @@ """ import ast -from itertools import chain import re import sys +from itertools import chain from typing import Container, Iterator, List, Tuple -from ..exceptions import ScriptParseError +from ..exceptions import ScriptParseError _BUILTINS_WHITELIST = { "abs", diff --git a/poethepoet/plugin.py b/poethepoet/plugin.py index 0181c91f..dd2f91cd 100644 --- a/poethepoet/plugin.py +++ b/poethepoet/plugin.py @@ -1,14 +1,15 @@ # pylint: disable=import-error +from pathlib import Path +from typing import Any, Dict, List + from cleo.commands.command import Command from cleo.events.console_command_event import ConsoleCommandEvent -from cleo.events.event_dispatcher import EventDispatcher from cleo.events.console_events import COMMAND, TERMINATE +from cleo.events.event_dispatcher import EventDispatcher from cleo.io.io import IO -from pathlib import Path -from poetry.console.application import Application, COMMANDS +from poetry.console.application import COMMANDS, Application from poetry.plugins.application_plugin import ApplicationPlugin -from typing import Any, Dict, List from .exceptions import PoePluginException @@ -79,7 +80,8 @@ def activate(self, application: Application) -> None: # pylint: disable=bare-except except: - import os, sys + import os + import sys debug = bool(int(os.environ.get("DEBUG_POE_PLUGIN", "0"))) print( @@ -146,6 +148,7 @@ def _get_config(cls, application: Application) -> Dict[str, Any]: # Fallback to loading the config again in case of future failure of the # above undocumented API import tomlkit + from .config import PoeConfig pyproject = tomlkit.loads( diff --git a/poethepoet/task/args.py b/poethepoet/task/args.py index 607c24e4..29934565 100644 --- a/poethepoet/task/args.py +++ b/poethepoet/task/args.py @@ -1,5 +1,6 @@ import argparse from typing import ( + TYPE_CHECKING, Any, Dict, List, @@ -9,7 +10,6 @@ Tuple, Type, Union, - TYPE_CHECKING, ) if TYPE_CHECKING: diff --git a/poethepoet/task/base.py b/poethepoet/task/base.py index 4db4fafa..987bc794 100644 --- a/poethepoet/task/base.py +++ b/poethepoet/task/base.py @@ -1,8 +1,9 @@ -from pathlib import Path import re import shlex import sys +from pathlib import Path from typing import ( + TYPE_CHECKING, Any, Dict, Iterator, @@ -12,18 +13,17 @@ Sequence, Tuple, Type, - TYPE_CHECKING, Union, ) -from .args import PoeTaskArgs +from ..env.manager import EnvVarsManager from ..exceptions import PoeException from ..helpers import is_valid_env_var -from ..env.manager import EnvVarsManager +from .args import PoeTaskArgs if TYPE_CHECKING: - from ..context import RunContext from ..config import PoeConfig + from ..context import RunContext from ..ui import PoeUi diff --git a/poethepoet/task/cmd.py b/poethepoet/task/cmd.py index b9a8bfad..a656be50 100644 --- a/poethepoet/task/cmd.py +++ b/poethepoet/task/cmd.py @@ -1,16 +1,10 @@ -from glob import glob import re import shlex -from typing import ( - Dict, - Sequence, - Type, - Tuple, - TYPE_CHECKING, - Union, -) -from .base import PoeTask +from glob import glob +from typing import TYPE_CHECKING, Dict, Sequence, Tuple, Type, Union + from ..env.manager import EnvVarsManager +from .base import PoeTask if TYPE_CHECKING: from ..config import PoeConfig diff --git a/poethepoet/task/graph.py b/poethepoet/task/graph.py index db11a81c..ef12dfa1 100644 --- a/poethepoet/task/graph.py +++ b/poethepoet/task/graph.py @@ -1,4 +1,5 @@ -from typing import Dict, Set, List, Tuple +from typing import Dict, List, Set, Tuple + from ..context import RunContext from ..exceptions import CyclicDependencyError from .base import PoeTask diff --git a/poethepoet/task/ref.py b/poethepoet/task/ref.py index 43d4ed51..de9e893b 100644 --- a/poethepoet/task/ref.py +++ b/poethepoet/task/ref.py @@ -1,16 +1,8 @@ import shlex -from typing import ( - Any, - Dict, - Optional, - Sequence, - Type, - Tuple, - TYPE_CHECKING, - Union, -) -from .base import PoeTask +from typing import TYPE_CHECKING, Any, Dict, Optional, Sequence, Tuple, Type, Union + from ..env.manager import EnvVarsManager +from .base import PoeTask if TYPE_CHECKING: from ..config import PoeConfig diff --git a/poethepoet/task/script.py b/poethepoet/task/script.py index 3b28e8d1..602a75b6 100644 --- a/poethepoet/task/script.py +++ b/poethepoet/task/script.py @@ -1,22 +1,11 @@ import ast import re -from typing import ( - Any, - Dict, - Optional, - Sequence, - Tuple, - Type, - TYPE_CHECKING, - Union, -) -from .base import PoeTask -from ..exceptions import ScriptParseError +from typing import TYPE_CHECKING, Any, Dict, Optional, Sequence, Tuple, Type, Union + from ..env.manager import EnvVarsManager -from ..helpers.python import ( - resolve_function_call, - parse_and_validate, -) +from ..exceptions import ScriptParseError +from ..helpers.python import parse_and_validate, resolve_function_call +from .base import PoeTask if TYPE_CHECKING: from ..config import PoeConfig diff --git a/poethepoet/task/sequence.py b/poethepoet/task/sequence.py index e5831f88..85e979f9 100644 --- a/poethepoet/task/sequence.py +++ b/poethepoet/task/sequence.py @@ -1,4 +1,5 @@ from typing import ( + TYPE_CHECKING, Any, Dict, List, @@ -6,12 +7,12 @@ Sequence, Tuple, Type, - TYPE_CHECKING, Union, ) -from .base import PoeTask, TaskContent + from ..env.manager import EnvVarsManager from ..exceptions import ExecutionError, PoeException +from .base import PoeTask, TaskContent if TYPE_CHECKING: from ..config import PoeConfig diff --git a/poethepoet/task/shell.py b/poethepoet/task/shell.py index 51fe1528..26a5332e 100644 --- a/poethepoet/task/shell.py +++ b/poethepoet/task/shell.py @@ -1,7 +1,8 @@ -from os import environ import re +from os import environ from shutil import which from typing import ( + TYPE_CHECKING, Any, Dict, List, @@ -9,9 +10,9 @@ Sequence, Tuple, Type, - TYPE_CHECKING, Union, ) + from ..env.manager import EnvVarsManager from ..exceptions import PoeException from .base import PoeTask diff --git a/poethepoet/ui.py b/poethepoet/ui.py index b7e01146..c344cc2b 100644 --- a/poethepoet/ui.py +++ b/poethepoet/ui.py @@ -1,10 +1,12 @@ import argparse import os -from pastel import Pastel import sys from typing import IO, List, Mapping, Optional, Sequence, Tuple, Union -from .exceptions import PoeException + +from pastel import Pastel + from .__version__ import __version__ +from .exceptions import PoeException def guess_ansi_support(file): diff --git a/poethepoet/virtualenv.py b/poethepoet/virtualenv.py index cac23622..f0bbf98d 100644 --- a/poethepoet/virtualenv.py +++ b/poethepoet/virtualenv.py @@ -1,6 +1,6 @@ import os -from pathlib import Path import sys +from pathlib import Path from typing import Dict, Mapping diff --git a/tests/conftest.py b/tests/conftest.py index f5767f6d..f3ff34ca 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,22 +1,24 @@ +import os +import re +import shutil +import sys +import time +import venv from collections import namedtuple from contextlib import contextmanager from io import StringIO -import os from pathlib import Path -from poethepoet.app import PoeThePoet -from poethepoet.virtualenv import Virtualenv -import pytest -import re -import shutil from subprocess import PIPE, Popen -import sys from tempfile import TemporaryDirectory -import time -import tomli from typing import Any, Dict, List, Mapping, Optional -import venv + +import pytest +import tomli import virtualenv +from poethepoet.app import PoeThePoet +from poethepoet.virtualenv import Virtualenv + PROJECT_ROOT = Path(__file__).resolve().parent.parent PROJECT_TOML = PROJECT_ROOT.joinpath("pyproject.toml") diff --git a/tests/fixtures/packages/poe_test_package/poe_test_package/__init__.py b/tests/fixtures/packages/poe_test_package/poe_test_package/__init__.py index a99e659a..312799f9 100644 --- a/tests/fixtures/packages/poe_test_package/poe_test_package/__init__.py +++ b/tests/fixtures/packages/poe_test_package/poe_test_package/__init__.py @@ -1,7 +1,6 @@ import os import sys - __version__ = "0.0.99" diff --git a/tests/fixtures/venv_project/scripts.py b/tests/fixtures/venv_project/scripts.py index 530122be..c7fa155b 100644 --- a/tests/fixtures/venv_project/scripts.py +++ b/tests/fixtures/venv_project/scripts.py @@ -5,6 +5,6 @@ def test_package_version(): def test_package_exec_version(): - from subprocess import Popen, PIPE + from subprocess import PIPE, Popen Popen(["test_print_version"]) diff --git a/tests/test_cli.py b/tests/test_cli.py index e0eaa25b..29c047ff 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -1,6 +1,7 @@ -from poethepoet import __version__ import re +from poethepoet import __version__ + def test_call_no_args(run_poe): result = run_poe() diff --git a/tests/test_envfile.py b/tests/test_envfile.py index 99ac61a2..786be54f 100644 --- a/tests/test_envfile.py +++ b/tests/test_envfile.py @@ -1,6 +1,6 @@ import os -from pathlib import Path import sys +from pathlib import Path def test_global_envfile_and_default(run_poe_subproc, is_windows): diff --git a/tests/test_executors.py b/tests/test_executors.py index b52ac1ec..a973eaec 100644 --- a/tests/test_executors.py +++ b/tests/test_executors.py @@ -1,6 +1,7 @@ +import sys from pathlib import Path + import pytest -import sys PY_V = f"{sys.version_info.major}.{sys.version_info.minor}" diff --git a/tests/test_poe_config.py b/tests/test_poe_config.py index e9346ff4..ac675ccd 100644 --- a/tests/test_poe_config.py +++ b/tests/test_poe_config.py @@ -1,6 +1,6 @@ import os -from pathlib import Path import tempfile +from pathlib import Path def test_setting_default_task_type(run_poe_subproc, projects, esc_prefix): diff --git a/tests/test_poetry_plugin.py b/tests/test_poetry_plugin.py index fd3ed85e..569d89a3 100644 --- a/tests/test_poetry_plugin.py +++ b/tests/test_poetry_plugin.py @@ -1,7 +1,8 @@ -import pytest import re from sys import version_info +import pytest + @pytest.fixture(scope="session") def setup_poetry_project(run_poetry, projects): diff --git a/tests/test_shell_task.py b/tests/test_shell_task.py index c462c24f..413d9eba 100644 --- a/tests/test_shell_task.py +++ b/tests/test_shell_task.py @@ -1,6 +1,7 @@ -import pytest import shutil +import pytest + def test_shell_task(run_poe_subproc): result = run_poe_subproc("count", project="shells") diff --git a/tests/unit/test_parse_env_file.py b/tests/unit/test_parse_env_file.py index 479959f1..d2a04b30 100644 --- a/tests/unit/test_parse_env_file.py +++ b/tests/unit/test_parse_env_file.py @@ -1,6 +1,7 @@ -from poethepoet.env.parse import parse_env_file import pytest +from poethepoet.env.parse import parse_env_file + valid_examples = [ ( """