Skip to content

Commit

Permalink
🎨 isort
Browse files Browse the repository at this point in the history
  • Loading branch information
RF-Tar-Railt committed Oct 16, 2023
1 parent a44cd33 commit 4aba3dd
Show file tree
Hide file tree
Showing 15 changed files with 45 additions and 26 deletions.
15 changes: 14 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,17 @@ exclude_lines = [
"def __str__",
"def __eq__",
"except ImportError:",
]
]

[tool.black]
line-length = 120
target-version = ["py38", "py39", "py310", "py311"]
include = '\.pyi?$'
extend-exclude = '''
'''

[tool.isort]
profile = "black"
line_length = 120
skip_gitignore = true
extra_standard_library = ["typing_extensions"]
19 changes: 12 additions & 7 deletions src/arclet/alconna/_internal/_analyser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,32 @@
from dataclasses import dataclass, field
from re import Match
from typing import TYPE_CHECKING, Any, Callable, Generic, Set
from typing_extensions import Self, TypeAlias

from tarina import lang
from typing_extensions import Self, TypeAlias

from ..action import Action
from ..args import Args
from ..arparma import Arparma
from ..base import Option, Subcommand
from ..completion import comp_ctx
from ..config import config
from ..exceptions import (
ArgumentMissing, FuzzyMatchSuccess, ParamsUnmatched, PauseTriggered, SpecialOptionTriggered
)
from ..exceptions import ArgumentMissing, FuzzyMatchSuccess, ParamsUnmatched, PauseTriggered, SpecialOptionTriggered
from ..manager import ShortcutArgs, command_manager
from ..model import HeadResult, OptionResult, Sentence, SubcommandResult
from ..output import output_manager
from ..typing import TDC
from ._handlers import (
analyse_args, analyse_header, analyse_param,
handle_completion, handle_help, handle_opt_default,
handle_shortcut, prompt, _handle_shortcut_data, _handle_shortcut_reg
_handle_shortcut_data,
_handle_shortcut_reg,
analyse_args,
analyse_header,
analyse_param,
handle_completion,
handle_help,
handle_opt_default,
handle_shortcut,
prompt,
)
from ._header import Header
from ._util import levenshtein
Expand Down
2 changes: 1 addition & 1 deletion src/arclet/alconna/_internal/_argv.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

from dataclasses import InitVar, dataclass, field
from typing import Any, Callable, ClassVar, Generic, Iterable
from typing_extensions import Self

from tarina import lang, split, split_once
from typing_extensions import Self

from ..args import Arg
from ..base import Option, Subcommand
Expand Down
6 changes: 2 additions & 4 deletions src/arclet/alconna/_internal/_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@
from ..base import Option, Subcommand
from ..completion import Prompt, comp_ctx
from ..config import config
from ..exceptions import (
ArgumentMissing, FuzzyMatchSuccess, ParamsUnmatched, PauseTriggered, SpecialOptionTriggered
)
from ..exceptions import ArgumentMissing, FuzzyMatchSuccess, ParamsUnmatched, PauseTriggered, SpecialOptionTriggered
from ..model import HeadResult, OptionResult, Sentence
from ..output import output_manager
from ..typing import KWBool
from ._header import Double, Header
from ._util import levenshtein, escape, unescape
from ._util import escape, levenshtein, unescape

if TYPE_CHECKING:
from ._analyser import Analyser, SubAnalyser
Expand Down
2 changes: 1 addition & 1 deletion src/arclet/alconna/_internal/_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
from nepattern.util import TPattern
from tarina import Empty, lang

from ._util import escape, unescape
from ..typing import TPrefixes
from ._util import escape, unescape


def handle_bracket(name: str, mapping: dict):
Expand Down
6 changes: 3 additions & 3 deletions src/arclet/alconna/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
from copy import deepcopy
from enum import Enum
from functools import partial
from typing import Any, Callable, Generic, Iterable, Sequence, TypeVar, Union, Type, List
from typing import Any, Callable, Generic, Iterable, List, Sequence, Type, TypeVar, Union
from typing_extensions import Self, TypeAlias

from nepattern import AllParam, AnyOne, BasePattern, MatchMode, RawStr, UnionPattern, all_patterns, type_parser
from tarina import Empty, get_signature, lang
from typing_extensions import Self, TypeAlias

from .exceptions import InvalidParam
from .typing import KeyWordVar, MultiVar, KWBool, UnpackVar
from .typing import KeyWordVar, KWBool, MultiVar, UnpackVar


def safe_dcls_kw(**kwargs):
Expand Down
2 changes: 1 addition & 1 deletion src/arclet/alconna/arparma.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
from functools import lru_cache
from types import MappingProxyType
from typing import Any, Callable, ClassVar, Generic, TypeVar, cast, overload
from typing_extensions import Self

from tarina import Empty, generic_isinstance, lang
from typing_extensions import Self

from .exceptions import BehaveCancelled, OutBoundsBehave
from .model import HeadResult, OptionResult, SubcommandResult
Expand Down
4 changes: 2 additions & 2 deletions src/arclet/alconna/base.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""Alconna 的基础内容相关"""
from __future__ import annotations

from functools import reduce
from dataclasses import replace
from functools import reduce
from typing import Any, Iterable, Sequence, overload
from typing_extensions import Self

from tarina import lang
from typing_extensions import Self

from .action import Action, store
from .args import Arg, Args
Expand Down
4 changes: 2 additions & 2 deletions src/arclet/alconna/builtin.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from __future__ import annotations

from dataclasses import dataclass, field
from typing import Any, Callable, overload, cast
from typing import Any, Callable, cast, overload

from .arparma import Arparma, ArparmaBehavior
from .core import Alconna
from .duplication import Duplication
from .stub import ArgsStub, OptionStub, SubcommandStub
from .exceptions import BehaveCancelled
from .stub import ArgsStub, OptionStub, SubcommandStub

__all__ = ["set_default", "generate_duplication"]

Expand Down
2 changes: 1 addition & 1 deletion src/arclet/alconna/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
from functools import partial
from pathlib import Path
from typing import Any, Callable, Generic, Sequence, TypeVar, overload
from typing_extensions import Self

from tarina import init_spec, lang
from typing_extensions import Self

from ._internal._analyser import Analyser, TCompile
from .args import Arg, Args
Expand Down
2 changes: 1 addition & 1 deletion src/arclet/alconna/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
from copy import copy
from datetime import datetime
from typing import TYPE_CHECKING, Any, Match, TypedDict, Union, overload
from typing_extensions import NotRequired
from weakref import WeakKeyDictionary, WeakValueDictionary

from tarina import LRU, lang
from typing_extensions import NotRequired

from .argv import Argv, __argv_type__
from .arparma import Arparma
Expand Down
1 change: 1 addition & 0 deletions src/arclet/alconna/model.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from dataclasses import dataclass

_repr_ = lambda self: "(" + " ".join([f"{k}={getattr(self, k, ...)!r}" for k in self.__slots__]) + ")"


Expand Down
2 changes: 2 additions & 0 deletions src/arclet/alconna/model.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from __future__ import annotations

from typing import Any

from nepattern import BasePattern

class Sentence:
Expand Down
2 changes: 1 addition & 1 deletion src/arclet/alconna/stub.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
from dataclasses import dataclass, field
from inspect import isclass
from typing import Any, Generic, TypeVar
from typing_extensions import Self

from nepattern import AllParam, AnyOne, BasePattern
from typing_extensions import Self

from .args import Args
from .base import Option, Subcommand
Expand Down
2 changes: 1 addition & 1 deletion src/arclet/alconna/typing.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Alconna 参数相关"""
from __future__ import annotations

from dataclasses import dataclass, field, is_dataclass, fields
from dataclasses import dataclass, field, fields, is_dataclass
from typing import Any, Dict, Iterator, List, Literal, Protocol, Tuple, TypeVar, Union, runtime_checkable

from nepattern import BasePattern, MatchMode, type_parser
Expand Down

0 comments on commit 4aba3dd

Please sign in to comment.