Skip to content

Commit 86415e1

Browse files
🧑‍💻 Replace black/isort with ruff
1 parent c657d0b commit 86415e1

File tree

12 files changed

+51
-41
lines changed

12 files changed

+51
-41
lines changed

CONTRIBUTING.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ checks:
2323
* Pull requests must be accompanied by tests. We use ``pytest`` and prefer using this
2424
testing style over Django's ``django.test.TestCase``.
2525
* Ideally, documentation updates are included in a pull request.
26-
* Imports are sorted using ``isort``, while code is formatted using ``black``. There
27-
are tox environments and CI checks in place to check/enforce this.
26+
* Code formatting and linting is done with ``ruff``. There are tox environments and CI
27+
checks in place to check/enforce this.
2828
* Follow Django's code style where possible.
2929
* Keep commits atomic - one commit should only concern one topic. Bugfixes typically
3030
have one commit for the regression test and one commit with the fix.
@@ -100,8 +100,8 @@ or to build the full test matrix
100100

101101
.. code-block:: bash
102102
103-
black .
104-
isort .
103+
ruff format .
104+
ruff check --fix .
105105
106106
Should be sufficient. Consider using a pre-commit hook to automate this.
107107

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Manage cookie information and let visitors give or reject consent for them.
66
![License](https://img.shields.io/pypi/l/django-cookie-consent)
77
[![Build status][badge:GithubActions:CI]][GithubActions:CI]
88
[![Code Quality][badge:GithubActions:CQ]][GithubActions:CQ]
9-
[![Code style: black][badge:black]][black]
9+
[![Code style: ruff][badge:ruff]][ruff]
1010
[![Test coverage][badge:codecov]][codecov]
1111
[![Documentation][badge:docs]][docs]
1212

@@ -36,8 +36,8 @@ from the `docs` directory in this repository.
3636
[badge:GithubActions:CI]: https://github.com/django-commons/django-cookie-consent/workflows/Run%20CI/badge.svg
3737
[GithubActions:CQ]: https://github.com/django-commons/django-cookie-consent/actions?query=workflow%3A%22Code+quality+checks%22
3838
[badge:GithubActions:CQ]: https://github.com/django-commons/django-cookie-consent/workflows/Code%20quality%20checks/badge.svg
39-
[black]: https://github.com/psf/black
40-
[badge:black]: https://img.shields.io/badge/code%20style-black-000000.svg
39+
[ruff]: https://github.com/astral-sh/ruff
40+
[badge:ruff]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
4141
[codecov]: https://codecov.io/gh/django-commons/django-cookie-consent
4242
[badge:codecov]: https://codecov.io/gh/django-commons/django-cookie-consent/branch/master/graph/badge.svg
4343
[docs]: https://django-cookie-consent.readthedocs.io/en/latest/?badge=latest

cookie_consent/migrations/0001_initial.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ class Migration(migrations.Migration):
6868
validators=[
6969
django.core.validators.RegexValidator(
7070
re.compile("^[-_a-zA-Z0-9]+$"),
71-
"Enter a valid 'varname' consisting of letters, numbers, underscores or hyphens.",
71+
"Enter a valid 'varname' consisting of letters, "
72+
"numbers, underscores or hyphens.",
7273
"invalid",
7374
)
7475
],

cookie_consent/migrations/0003_alter_cookiegroup_varname.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88

99
class Migration(migrations.Migration):
10-
1110
dependencies = [
1211
("cookie_consent", "0002_auto__add_logitem"),
1312
]
@@ -22,7 +21,8 @@ class Migration(migrations.Migration):
2221
validators=[
2322
django.core.validators.RegexValidator(
2423
re.compile("^[-_a-zA-Z0-9]+$"),
25-
"Enter a valid 'varname' consisting of letters, numbers, underscores or hyphens.",
24+
"Enter a valid 'varname' consisting of letters, numbers, "
25+
"underscores or hyphens.",
2626
"invalid",
2727
)
2828
],

cookie_consent/migrations/0004_cookie_natural_key.py

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

55

66
class Migration(migrations.Migration):
7-
87
dependencies = [
98
("cookie_consent", "0003_alter_cookiegroup_varname"),
109
]

cookie_consent/templatetags/cookie_consent_tags.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,9 @@ def js_type_for_cookie_consent(request, varname, cookie=None):
133133
alert("Social cookie accepted");
134134
</script>
135135
"""
136-
# This approach doesn't work with page caches and/or strict Content-Security-Policies
137-
# (unless you use nonces, which again doesn't work with aggressive page caching).
136+
# This approach doesn't work with page caches and/or strict
137+
# Content-Security-Policies (unless you use nonces, which again doesn't work with
138+
# aggressive page caching).
138139
warnings.warn(
139140
"Template tags for use in/with JS are deprecated and will be removed "
140141
"in django-cookie-consent 1.0",

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
django.setup()
1616

17-
from cookie_consent import __version__ # isort:skip
17+
from cookie_consent import __version__ # noqa: E402
1818

1919
# -- General configuration -----------------------------------------------------
2020

pyproject.toml

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,12 @@ Changelog = "https://github.com/django-commons/django-cookie-consent/blob/master
4545
[project.optional-dependencies]
4646
tests = [
4747
"pytest",
48+
"pytest-cov",
4849
"pytest-django",
4950
"pytest-playwright",
5051
"hypothesis",
5152
"tox",
52-
"isort",
53-
"black",
54-
"flake8",
55-
]
56-
coverage = [
57-
"pytest-cov",
53+
"ruff",
5854
]
5955
docs = [
6056
"sphinx",
@@ -105,3 +101,30 @@ exclude_also = [
105101
"\\.\\.\\.",
106102
"\\bpass$",
107103
]
104+
105+
[tool.ruff.lint]
106+
extend-select = [
107+
# "UP", # pyupgrade
108+
# "DJ", # django
109+
# "LOG", # logging
110+
# "G",
111+
"I", # isort
112+
"E", # pycodestyle
113+
"F", # pyflakes
114+
# "PERF",# perflint
115+
# "B", # flake8-bugbear
116+
]
117+
118+
[tool.ruff.lint.isort]
119+
combine-as-imports = true
120+
section-order = [
121+
"future",
122+
"standard-library",
123+
"django",
124+
"third-party",
125+
"first-party",
126+
"local-folder",
127+
]
128+
129+
[tool.ruff.lint.isort.sections]
130+
"django" = ["django"]

setup.cfg

Lines changed: 0 additions & 4 deletions
This file was deleted.

tests/test_models.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ def test_bulk_delete(self):
5757
id=self.cookie_group.id
5858
).delete()
5959

60-
# Deleting a CookieGroup also deletes the associated Cookies, that's why we expect a count of 2.
60+
# Deleting a CookieGroup also deletes the associated Cookies, that's why we
61+
# expect a count of 2.
6162
self.assertEqual(deleted_objs_count, 2)
6263
self.assertCacheNotPopulated()
6364

0 commit comments

Comments
 (0)