Skip to content

Commit a7539d1

Browse files
Merge pull request #151 from django-commons/chore/switch-to-ruff
🧑‍💻 Replace black/isort with ruff
2 parents c657d0b + 4321263 commit a7539d1

27 files changed

+105
-98
lines changed

.github/workflows/code_quality.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ jobs:
1717
strategy:
1818
matrix:
1919
toxenv:
20-
- isort
21-
- black
22-
# - flake8
20+
- ruff
2321
- docs
2422
steps:
2523
- uses: actions/checkout@v4

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/admin.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
from django.contrib import admin
32

43
from .conf import settings

cookie_consent/cache.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
from django.core.cache import caches
32

43
from .conf import settings

cookie_consent/conf.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
from django.conf import settings # NOQA
32

43
from appconf import AppConf

cookie_consent/middleware.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
# -*- coding: utf-8 -*-
2-
from typing import Optional
3-
41
from .cache import all_cookie_groups
52
from .conf import settings
63
from .util import get_cookie_dict_from_request, is_cookie_consent_enabled
74

85

9-
def _should_delete_cookie(group_version: Optional[str]) -> bool:
6+
def _should_delete_cookie(group_version: str | None) -> bool:
107
# declined after it was accepted (and set) before
118
if group_version == settings.COOKIE_CONSENT_DECLINE:
129
return True

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
]

0 commit comments

Comments
 (0)