Skip to content

Commit 19443df

Browse files
authored
build: add pre-commit hooks (#54)
Also switch to ruff.
1 parent 4d3aea8 commit 19443df

File tree

4 files changed

+63
-198
lines changed

4 files changed

+63
-198
lines changed

.pre-commit-config.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
repos:
2+
- repo: local
3+
hooks:
4+
- id: poetry-lock
5+
name: poetry lock
6+
entry: poetry lock
7+
language: system
8+
pass_filenames: false
9+
files: ^(.*/)?(poetry\.lock|pyproject\.toml)$
10+
- id: poetry-fix
11+
name: poetry fix
12+
entry: poetry run poe fix
13+
language: system
14+
require_serial: true
15+
types_or: [python, pyi, jupyter]

poetry.lock

Lines changed: 30 additions & 177 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -37,33 +37,29 @@ packages = [{include="git_draft", from="src"}]
3737
python = ">=3.12,<4"
3838

3939
[tool.poetry.group.dev.dependencies]
40-
black = "^25.1.0"
4140
coverage = "^7.4.4"
42-
flake8 = "^7.0.0"
43-
flake8-pyproject = "^1.2.3"
44-
isort = "^6.0.1"
45-
mypy = "^1.2.0"
41+
mypy = "^1.2.1"
4642
poethepoet = "^0.25.0"
47-
pytest = "^7.1.2"
43+
pytest = "^7.1.0"
44+
ruff = "^0.11.0"
4845

4946
# Poe
5047

5148
[tool.poe.tasks.fix]
5249
help = "format source code"
5350
sequence = [
54-
{cmd="isort ${args}"},
55-
{cmd="black ${args}"},
51+
{cmd="ruff format ${args}"},
52+
{cmd="ruff check --fix ${args}"},
5653
]
5754
args = [
5855
{name="args", help="target folders", positional=true, multiple=true, default="src tests"},
5956
]
6057

6158
[tool.poe.tasks.lint]
62-
help = "lint source code"
59+
help = "lint configuration and source code"
6360
sequence = [
64-
{cmd="isort --check ${args}"},
65-
{cmd="black --check --quiet ${args}"},
66-
{cmd="flake8 ${args}"},
61+
{cmd="poetry check"},
62+
{cmd="ruff check ${args}"},
6763
{cmd="mypy ${args}"},
6864
]
6965
args = [
@@ -92,16 +88,18 @@ relative_files = true
9288
include = ["src/**/*.py"]
9389
show_missing = true
9490

95-
[tool.flake8]
96-
ignore = ["E203", "E501", "E704", "W503"]
97-
98-
[tool.isort]
99-
profile = "black"
100-
force_sort_within_sections = true
101-
lines_after_imports = 2
102-
10391
[tool.mypy]
10492
disable_error_code = "import-untyped"
10593

10694
[tool.pytest.ini_options]
10795
log_level = "DEBUG"
96+
97+
[tool.ruff]
98+
line-length = 79
99+
100+
[tool.ruff.lint]
101+
select = ["E", "F", "I"]
102+
103+
[tool.ruff.lint.isort]
104+
force-sort-within-sections = true
105+
lines-after-imports = 2

src/git_draft/bots/openai.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ def _on_list_files(self, paths: Sequence[PurePosixPath]) -> str:
237237

238238

239239
class _ThreadsBot(Bot):
240-
241240
def __init__(self, client: openai.OpenAI, assistant_id: str) -> None:
242241
self._client = client
243242
self._assistant_id = assistant_id

0 commit comments

Comments
 (0)