Skip to content

Commit becd123

Browse files
authored
refactor: sort imports (#43)
Also add revert test.
1 parent 5d46f72 commit becd123

File tree

16 files changed

+53
-18
lines changed

16 files changed

+53
-18
lines changed

poetry.lock

Lines changed: 17 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ black = "^25.1.0"
4040
coverage = "^7.4.4"
4141
flake8 = "^7.0.0"
4242
flake8-pyproject = "^1.2.3"
43+
isort = "^6.0.1"
4344
mypy = "^1.2.0"
4445
poethepoet = "^0.25.0"
4546
pytest = "^7.1.2"
@@ -48,14 +49,18 @@ pytest = "^7.1.2"
4849

4950
[tool.poe.tasks.fix]
5051
help = "format source code"
51-
cmd = "black ${args}"
52+
sequence = [
53+
{cmd="isort ${args}"},
54+
{cmd="black ${args}"},
55+
]
5256
args = [
5357
{name="args", help="target folders", positional=true, multiple=true, default="src tests"},
5458
]
5559

5660
[tool.poe.tasks.lint]
5761
help = "lint source code"
5862
sequence = [
63+
{cmd="isort --check ${args}"},
5964
{cmd="black --check --quiet ${args}"},
6065
{cmd="flake8 ${args}"},
6166
{cmd="mypy ${args}"},
@@ -89,6 +94,10 @@ show_missing = true
8994
[tool.flake8]
9095
ignore = ["E203", "E501", "E704", "W503"]
9196

97+
[tool.isort]
98+
profile = "black"
99+
force_sort_within_sections = true
100+
92101
[tool.mypy]
93102
disable_error_code = "import-untyped"
94103

src/git_draft/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import sys
99

1010
from .bots import Operation, load_bot
11-
from .common import Config, PROGRAM, UnreachableError, ensure_state_home
11+
from .common import PROGRAM, Config, UnreachableError, ensure_state_home
1212
from .drafter import Drafter
1313
from .editor import open_editor
1414
from .prompt import TemplatedPrompt

src/git_draft/bots/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from pathlib import Path, PurePosixPath
66
from typing import Callable, Sequence
77

8-
from ..common import ensure_state_home, JSONObject
8+
from ..common import JSONObject, ensure_state_home
99

1010

1111
class Toolbox:

src/git_draft/bots/openai.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414

1515
import json
1616
import logging
17-
import openai
1817
import os
1918
from pathlib import PurePosixPath
2019
from typing import Any, Mapping, Self, Sequence, TypedDict, override
2120

21+
import openai
22+
2223
from ..common import JSONObject, reindent
2324
from .common import Action, Bot, Goal, Toolbox
2425

25-
2626
_logger = logging.getLogger(__name__)
2727

2828

src/git_draft/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
import textwrap
1212
import tomllib
1313
from typing import Any, Mapping, Self, Sequence
14-
import xdg_base_dirs
1514

15+
import xdg_base_dirs
1616

1717
PROGRAM = "git-draft"
1818

src/git_draft/drafter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from __future__ import annotations
22

33
import dataclasses
4-
import git
54
import json
65
import logging
76
from pathlib import PurePosixPath
@@ -11,12 +10,13 @@
1110
import time
1211
from typing import Match, Sequence, override
1312

13+
import git
14+
1415
from .bots import Bot, Goal, OperationHook, Toolbox
1516
from .common import random_id
1617
from .prompt import PromptRenderer, TemplatedPrompt
1718
from .store import Store, sql
1819

19-
2020
_logger = logging.getLogger(__name__)
2121

2222

src/git_draft/editor.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import sys
77
import tempfile
88

9-
109
_default_editors = ["vim", "emacs", "nano"]
1110

1211

src/git_draft/prompt.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
"""Prompt templating support"""
22

33
import dataclasses
4+
from typing import Mapping, Self
5+
46
import git
57
import jinja2
6-
from typing import Mapping, Self
78

89
from .common import Config, package_root
910

10-
1111
_prompt_root = package_root / "prompts"
1212

1313

src/git_draft/store.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
from .common import ensure_state_home, package_root
1010

11-
1211
sqlite3.register_adapter(datetime, lambda d: d.isoformat())
1312
sqlite3.register_converter(
1413
"timestamp", lambda v: datetime.fromisoformat(v.decode())

0 commit comments

Comments
 (0)