Skip to content

Commit

Permalink
Use ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
yakky committed Apr 20, 2023
1 parent 2e72a3d commit ee71cd1
Show file tree
Hide file tree
Showing 20 changed files with 37 additions and 65 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
strategy:
matrix:
python-version: ["3.11.x"]
toxenv: [pep8, isort, black, pypi-description, docs, towncrier]
toxenv: [ruff, isort, black, pypi-description, docs, towncrier]
steps:
- uses: actions/checkout@v3
with:
Expand Down
30 changes: 6 additions & 24 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ repos:
rev: v4.4.0
hooks:
- id: trailing-whitespace
exclude: "setup.cfg"
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
Expand All @@ -21,39 +22,21 @@ repos:
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 23.1.0
rev: 23.3.0
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.0.262'
hooks:
- id: flake8
additional_dependencies:
- flake8-broken-line
- flake8-bugbear
- flake8-builtins
- flake8-coding
- flake8-commas
- flake8-comprehensions
- flake8-eradicate
- flake8-quotes
- flake8-tidy-imports
- pep8-naming
- repo: https://github.com/econchick/interrogate
rev: 1.5.0
hooks:
- id: interrogate
args:
- "-cpyproject.toml"
- "--quiet"
- id: ruff
- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
hooks:
- id: pyupgrade
args:
- --py3-plus
- repo: https://github.com/adamchainz/django-upgrade
rev: "1.12.0"
rev: "1.13.0"
hooks:
- id: django-upgrade
args: [--target-version, "3.2"]
Expand All @@ -65,7 +48,6 @@ repos:
language: system
pass_filenames: false
always_run: true

ci:
skip:
- towncrier
3 changes: 2 additions & 1 deletion djangocms_blog/migrations/0002_post_sites.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ class Migration(migrations.Migration):
model_name="post",
name="sites",
field=models.ManyToManyField(
help_text="Select sites in which to show the post. If none is set it will bevisible in all the configured sites.",
help_text="Select sites in which to show the post. If none is set it will be "
"visible in all the configured sites.",
to="sites.Site",
null=True,
verbose_name="Site(s",
Expand Down
3 changes: 2 additions & 1 deletion djangocms_blog/migrations/0003_auto_20141201_2252.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ class Migration(migrations.Migration):
model_name="post",
name="sites",
field=models.ManyToManyField(
help_text="Select sites in which to show the post. If none is set it will be visible in all the configured sites.",
help_text="Select sites in which to show the post. If none is set it will "
"be visible in all the configured sites.",
to="sites.Site",
null=True,
verbose_name="Site(s)",
Expand Down
2 changes: 1 addition & 1 deletion djangocms_blog/migrations/0006_auto_20150214_1907.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import djangocms_text_ckeditor.fields
from django.db import migrations, models
from django.db import migrations


class Migration(migrations.Migration):
Expand Down
2 changes: 1 addition & 1 deletion djangocms_blog/migrations/0008_auto_20150814_0831.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import djangocms_text_ckeditor.fields
from django.db import migrations, models
from django.db import migrations


class Migration(migrations.Migration):
Expand Down
4 changes: 2 additions & 2 deletions djangocms_blog/migrations/0009_latestpostsplugin_tags_new.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import taggit_autosuggest.managers
from django.contrib.contenttypes.models import ContentType
from django.db import migrations, models
from django.db import migrations


def migrate_tags(apps, schema_editor):
Expand All @@ -18,7 +18,7 @@ def migrate_tags(apps, schema_editor):

def migrate_tags_reverse(apps, schema_editor):
LatestPostsPlugin = apps.get_model("djangocms_blog", "LatestPostsPlugin")
Tag = apps.get_model("taggit", "Tag")
apps.get_model("taggit", "Tag")
TaggedItem = apps.get_model("taggit", "TaggedItem")
plugin_content_type = ContentType.objects.get_for_model(LatestPostsPlugin)
for tagged in TaggedItem.objects.filter(content_type_id=plugin_content_type.pk):
Expand Down
3 changes: 2 additions & 1 deletion djangocms_blog/migrations/0010_auto_20150923_1151.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ class Migration(migrations.Migration):
name="sites",
field=models.ManyToManyField(
to="sites.Site",
help_text="Select sites in which to show the post. If none is set it will be visible in all the configured sites.",
help_text="Select sites in which to show the post. "
"If none is set it will be visible in all the configured sites.",
blank=True,
verbose_name="Site(s)",
),
Expand Down
2 changes: 1 addition & 1 deletion djangocms_blog/migrations/0012_auto_20151220_1734.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.db import migrations, models
from django.db import migrations


class Migration(migrations.Migration):
Expand Down
6 changes: 2 additions & 4 deletions djangocms_blog/migrations/0014_auto_20160215_1331.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from cms.models import Page
from cms.utils.i18n import get_language_list
from django.db import migrations, models
from django.db import migrations


def forwards(apps, schema_editor):
Expand All @@ -17,9 +17,7 @@ def forwards(apps, schema_editor):
if not BlogConfigTranslation.objects.exists():
for lang in get_language_list():
title = page.get_title(lang)
translation = BlogConfigTranslation.objects.create(
language_code=lang, master_id=config.pk, app_title=title
)
BlogConfigTranslation.objects.create(language_code=lang, master_id=config.pk, app_title=title)
if config:
for model in (Post, BlogCategory, GenericBlogPlugin, LatestPostsPlugin, AuthorEntriesPlugin):
for item in model.objects.filter(app_config__isnull=True):
Expand Down
4 changes: 1 addition & 3 deletions djangocms_blog/migrations/0017_thumbnail_move.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from django.db import migrations, models

from djangocms_blog.models import thumbnail_model
from django.db import migrations


class Migration(migrations.Migration):
Expand Down
2 changes: 1 addition & 1 deletion djangocms_blog/migrations/0019_thumbnail_move3.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.db import migrations, models
from django.db import migrations

from djangocms_blog.models import thumbnail_model

Expand Down
2 changes: 1 addition & 1 deletion djangocms_blog/migrations/0020_thumbnail_move4.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.db import migrations, models
from django.db import migrations

from djangocms_blog.models import thumbnail_model

Expand Down
2 changes: 1 addition & 1 deletion djangocms_blog/migrations/0021_post_liveblog.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import cms.models.fields
from django.db import migrations, models
from django.db import migrations


class Migration(migrations.Migration):
Expand Down
1 change: 0 additions & 1 deletion djangocms_blog/migrations/0022_auto_20160605_2305.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Generated by Django 1.9.7 on 2016-06-05 21:05

import django.db.models.deletion
from django.db import migrations, models


Expand Down
2 changes: 1 addition & 1 deletion djangocms_blog/migrations/0034_merge.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.db import migrations, models
from django.db import migrations


class Migration(migrations.Migration):
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ build-backend = "setuptools.build_meta"

[tool.black]
line-length = 119
target-version = ["py36"]
include = 'djangocms_blog/*py'
target-version = ["py310"]

[tool.towncrier]
package = "djangocms_blog"
Expand Down
2 changes: 1 addition & 1 deletion tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def clean(c):
@task
def lint(c):
"""Run linting tox environments."""
c.run("tox -epep8,isort,black,pypi-description")
c.run("tox -eruff,isort,black,pypi-description")


@task # NOQA
Expand Down
9 changes: 6 additions & 3 deletions tests/test_utils/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ class Migration(migrations.Migration):
validators=[
django.core.validators.RegexValidator(
"^[\\w.@+-]+$",
"Enter a valid username. This value may contain only letters, numbers and @/./+/-/_ characters.",
"Enter a valid username. This value may contain only letters, "
"numbers and @/./+/-/_ characters.",
"invalid",
)
],
Expand All @@ -57,15 +58,17 @@ class Migration(migrations.Migration):
"is_active",
models.BooleanField(
verbose_name="active",
help_text="Designates whether this user should be treated as active. Unselect this instead of deleting accounts.",
help_text="Designates whether this user should be treated as active. "
"Unselect this instead of deleting accounts.",
default=True,
),
),
("date_joined", models.DateTimeField(verbose_name="date joined", default=django.utils.timezone.now)),
(
"groups",
models.ManyToManyField(
help_text="The groups this user belongs to. A user will get all permissions granted to each of their groups.",
help_text="The groups this user belongs to. A user will get all "
"permissions granted to each of their groups.",
related_query_name="user",
related_name="user_set",
verbose_name="groups",
Expand Down
18 changes: 4 additions & 14 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ envlist =
docs
isort
isort_format
pep8
ruff
pypi-description
towncrier
py{311,310,39}-django{42,41}-cms{311}
Expand Down Expand Up @@ -36,23 +36,13 @@ passenv =
COMMAND
PYTEST_*

[testenv:pep8]
[testenv:ruff]
commands =
{envpython} -m flake8 djangocms_blog tests
{envpython} -m ruff check djangocms_blog tests {posargs}
{envpython} -minterrogate -c pyproject.toml djangocms_blog tests
deps =
interrogate
flake8
flake8-broken-line
flake8-bugbear
flake8-builtins
flake8-coding
flake8-commas
flake8-comprehensions
flake8-eradicate
flake8-quotes
flake8-tidy-imports
pep8-naming
ruff
skip_install = true

[testenv:isort]
Expand Down

0 comments on commit ee71cd1

Please sign in to comment.