Skip to content

Commit b123f54

Browse files
authored
Upgrade linting dependencies & switch to ruff (#64)
1 parent 33db2c4 commit b123f54

File tree

9 files changed

+40
-24
lines changed

9 files changed

+40
-24
lines changed

.github/workflows/main.yml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,13 @@ jobs:
2121
python-version: "3.10"
2222

2323
- name: "Install dependencies"
24-
run: python -m pip install pyupgrade==2.31.1 flake8==4.0.1 black==22.3.0 isort==5.10.1 mypy==1.10.1
24+
run: python -m pip install ruff==0.11.9 mypy==1.15.0
2525

26-
- name: "Run pyupgrade"
27-
run: pyupgrade --py38-plus **/*.py
26+
- name: "Run ruff"
27+
run: ruff check
2828

29-
- name: "Run flake8"
30-
run: flake8
31-
32-
- name: "Run isort"
33-
run: isort --check .
34-
35-
- name: "Run black"
36-
run: black --check .
29+
- name: "Run ruff format"
30+
run: ruff format
3731

3832
- name: "Run mypy"
3933
run: mypy

CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Bugfixes
2121
Maintenance
2222
-----------
2323

24+
* Update linters and switch to ruff. (`#64 <https://github.com/clokep/django-render-block/pull/64>`_)
2425
* Support Python 3.13. (`#62 <https://github.com/clokep/django-render-block/pull/62>`_)
2526
* Drop support for Python 3.8. (`#62 <https://github.com/clokep/django-render-block/pull/62>`_)
2627
* Support Django 5.2. (`#62 <https://github.com/clokep/django-render-block/pull/62>`_)

manage.py

100644100755
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env python
22
"""Django's command-line utility for administrative tasks."""
3+
34
import os
45
import sys
56

pyproject.toml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,33 @@
22
requires = ["setuptools>=38.6.0", "wheel"]
33
build-backend = "setuptools.build_meta"
44

5+
[tool.ruff.lint]
6+
select = [
7+
# pycodestyle
8+
"E",
9+
"W",
10+
# pyflakes
11+
"F",
12+
# flake8-bugbear
13+
"B0",
14+
# flake8-comprehensions
15+
"C4",
16+
# flake8-2020
17+
"YTT",
18+
# flake8-slots
19+
"SLOT",
20+
# flake8-debugger
21+
"T10",
22+
# flake8-pie
23+
"PIE",
24+
# flake8-executable
25+
"EXE",
26+
# isort
27+
"I",
28+
# pyupgrade
29+
"UP",
30+
]
31+
532
[tool.mypy]
633
warn_unused_configs = true
734
strict = false

render_block/base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from typing import Any, Mapping, Optional, Sequence, Union
1+
from collections.abc import Mapping, Sequence
2+
from typing import Any, Optional, Union
23

34
from django.http import HttpRequest, HttpResponse
45
from django.template import Context, loader

render_block/django.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,6 @@ def _render_template_block(block_name: str, context: Context) -> str:
8080

8181
if block_node is None:
8282
# The wanted block_name was not found.
83-
raise BlockNotFound("block with name '%s' does not exist" % block_name)
83+
raise BlockNotFound(f"block with name '{block_name}' does not exist")
8484

8585
return block_node.render(context) # type: ignore[no-any-return]

render_block/jinja2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def jinja2_render_block(
1717
try:
1818
gen = template.blocks[block_name](context)
1919
except KeyError:
20-
raise BlockNotFound("block with name '%s' does not exist" % block_name)
20+
raise BlockNotFound(f"block with name '{block_name}' does not exist")
2121

2222
# The result from above is a generator which yields unicode strings.
23-
return "".join([s for s in gen])
23+
return "".join(s for s in gen)

setup.cfg

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,3 @@ python_requires = >=3.8
4242
[options.extras_require]
4343
dev =
4444
Jinja2>=2.8
45-
46-
[flake8]
47-
extend-ignore = E203
48-
max-line-length = 88
49-
50-
[isort]
51-
profile = black
52-
default_section = THIRDPARTY

tests/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
},
2525
]
2626

27-
MIDDLEWARE_CLASSES: tuple = tuple()
27+
MIDDLEWARE_CLASSES: tuple = ()
2828

2929
EMAIL_BACKEND = "django.core.mail.backends.locmem.EmailBackend"
3030

0 commit comments

Comments
 (0)