chore: setup ruff (#89980)
gitea/combo/pipeline/head This commit looks good Details

This commit is contained in:
Corentin Sechet 2024-04-24 11:09:33 +02:00
parent acf81906f1
commit 44c57cde94
4 changed files with 34 additions and 2 deletions

View File

@ -72,7 +72,7 @@ class AppConfig(django.apps.AppConfig):
to_expire = Transaction.objects.filter(
start_date__lt=now - datetime.timedelta(hours=1), end_date__isnull=True
)
for transaction in to_expire:
for transaction in to_expire: # noqa: F402
logger.info('transaction %r is expired', transaction.order_id)
transaction.status = EXPIRED
transaction.save()

View File

@ -33,7 +33,7 @@ try:
TOKEN_VAR = TokenType.VAR
TOKEN_COMMENT = TokenType.COMMENT
except ImportError:
from django.template.base import TOKEN_BLOCK, TOKEN_VAR, TOKEN_COMMENT
from django.template.base import TOKEN_BLOCK, TOKEN_COMMENT, TOKEN_VAR
from django.template import Template, TemplateSyntaxError, defaultfilters
from django.template.defaultfilters import stringfilter

View File

@ -112,6 +112,12 @@ def pylint(session):
session.run(*pylint_command)
@nox.session
def ruff(session):
setup_venv(session, 'ruff')
session.run('ruff', 'check', *session.posargs)
@nox.session
def codestyle(session):
session.install('pre-commit')

26
ruff.toml Normal file
View File

@ -0,0 +1,26 @@
include = ["combo/**/*.py", "tests/**/*.py"]
line-length = 110
[lint]
select = [
"I", # isort
"PL", # pylint
"UP", # pyupgrade
"F", # pyflakes (ruff default)
]
ignore = [
"UP031", # Use format specifiers instead of percent format
"PLR2004", # Magic value used in comparison, consider replacing ... with a constant variable
"PLW2901", # Outer `for` loop variable `values` overwritten by inner `for` loop target
"PLR5501", # [*] Use `elif` instead of `else` then `if`, to reduce indentation
"UP032", # [*] Use f-string instead of `format` call
"F401", # [...] imported but unused; consider removing, adding to `__all__`, or using a redundant alias
]
[lint.pylint]
max-args=19
max-locals=15
max-returns=19
max-branches=36
max-statements=271