Skip to content

Commit e8b26df

Browse files
authored
refactor: migrate lint tool from isort+black to ruff (#5)
* refactor: migrate lint tool from isort+black to ruff * refactor: only install tomlkit for python version less than 3.11 * refactor: add I and SIM to ruff extend rules * Remove conflict lines * docs: update changelog
1 parent 8a52d08 commit e8b26df

File tree

5 files changed

+80
-164
lines changed

5 files changed

+80
-164
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44

55
### 0.2.0
66

7-
- Drop support for Python3.8
7+
- Only install tomlkit for Python version less than 3.11 ([#5])
8+
- Migrate lint tool from isort+black to ruff ([#5])
9+
- Drop support for Python3.8 ([#4])
10+
11+
[#5]: https://github.com/tortoise/tortoise-cli/pull/5
12+
[#4]: https://github.com/tortoise/tortoise-cli/pull/4
813

914
## 0.1
1015

Makefile

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
checkfiles = tortoise_cli/ tests/ examples/ conftest.py
2-
black_opts = -l 100 -t py39
32
py_warn = PYTHONDEVMODE=1
43

54
up:
@@ -8,20 +7,22 @@ up:
87
deps:
98
@poetry install --all-groups
109

11-
style: deps
12-
isort -src $(checkfiles)
13-
black $(black_opts) $(checkfiles)
10+
style: deps _style
11+
_style:
12+
ruff format $(checkfiles)
13+
ruff check --fix $(checkfiles)
1414

15-
check: deps
16-
black --check $(black_opts) $(checkfiles) || (echo "Please run 'make style' to auto-fix style issues" && false)
17-
flake8 $(checkfiles)
15+
check: deps _check
16+
_check:
17+
ruff format --check $(checkfiles) || (echo "Please run 'make style' to auto-fix style issues" && false)
18+
ruff check $(checkfiles)
1819
mypy $(checkfiles)
1920

20-
21-
test: deps
21+
test: deps _test
22+
_test:
2223
$(py_warn) pytest
2324

2425
build: deps
2526
@poetry build
2627

27-
ci: check test
28+
ci: check _test

poetry.lock

Lines changed: 34 additions & 138 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 & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ dependencies = [
1212
"tortoise-orm",
1313
"click",
1414
"ptpython",
15-
"tomlkit",
15+
"tomlkit (>=0.11.4,<1.0.0); python_version < '3.11'",
1616
]
1717

1818
[project.urls]
@@ -26,15 +26,13 @@ packages = [
2626
]
2727

2828
[tool.poetry.group.test.dependencies]
29-
pytest = "*"
30-
pytest-xdist = "*"
31-
pytest-sugar = "*"
29+
pytest = "^8.4.0"
30+
pytest-xdist = "^3.7.0"
31+
pytest-sugar = "^1.0.0"
3232

3333
[tool.poetry.group.dev.dependencies]
34-
isort = "*"
35-
flake8 = "*"
36-
black = "*"
37-
mypy = "*"
34+
ruff = "^0.11.13"
35+
mypy = "^1.16.0"
3836

3937
[build-system]
4038
requires = ["poetry-core>=2.0.0"]
@@ -50,3 +48,15 @@ tortoise_orm = "examples.TORTOISE_ORM"
5048
pretty = true
5149
check_untyped_defs = true
5250
ignore_missing_imports = true
51+
52+
[tool.ruff]
53+
line-length = 100
54+
[tool.ruff.lint]
55+
ignore = ["E501"]
56+
extend-select = [
57+
"I", # https://docs.astral.sh/ruff/rules/#isort-i
58+
"SIM", # https://docs.astral.sh/ruff/rules/#flake8-simplify-sim
59+
"FA", # https://docs.astral.sh/ruff/rules/#flake8-future-annotations-fa
60+
"UP", # https://docs.astral.sh/ruff/rules/#pyupgrade-up
61+
"RUF100", # https://docs.astral.sh/ruff/rules/#ruff-specific-rules-ruf
62+
]

0 commit comments

Comments
 (0)