Dev: replace isort, black, flake8 with ruff (#1057)

This commit is contained in:
Reckless_Satoshi 2024-01-09 01:22:50 +00:00 committed by GitHub
parent 84ea69344e
commit ae27b18d30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 33 deletions

View File

@ -1,6 +1,3 @@
# TODO
# add a hook which automatically generates the OpenApi schema on API changes
# and places them in an appropriate location
exclude: '(api|chat|control)/migrations/.*' exclude: '(api|chat|control)/migrations/.*'
repos: repos:
- repo: 'https://github.com/pre-commit/pre-commit-hooks' - repo: 'https://github.com/pre-commit/pre-commit-hooks'
@ -50,27 +47,20 @@ repos:
files: ^mobile/ files: ^mobile/
types_or: [javascript, jsx, ts, tsx, css, markdown, json] # uses https://github.com/pre-commit/identify types_or: [javascript, jsx, ts, tsx, css, markdown, json] # uses https://github.com/pre-commit/identify
entry: bash -c 'cd mobile && npm run format' entry: bash -c 'cd mobile && npm run format'
- id: isort - repo: https://github.com/astral-sh/ruff-pre-commit
name: isort rev: v0.1.11
hooks:
- id: ruff
stages:
- commit
- merge-commit
language: system
args: [ --fix ]
types: [python]
- id: ruff-format
stages: stages:
- commit - commit
- merge-commit - merge-commit
language: system language: system
types: [python] types: [python]
entry: isort
- id: black
name: black
stages:
- commit
- merge-commit
language: system
types: [python]
entry: black
- id: flake8
name: flake8
stages:
- commit
- merge-commit
language: system
types: [python]
entry: flake8

View File

@ -11,7 +11,6 @@ from api.utils import get_session
class Command(BaseCommand): class Command(BaseCommand):
help = "Polls telegram /getUpdates method" help = "Polls telegram /getUpdates method"
rest = 3 # seconds between consecutive polls rest = 3 # seconds between consecutive polls

View File

@ -6,7 +6,6 @@ from django.utils import timezone
class Currency(models.Model): class Currency(models.Model):
with open("frontend/static/assets/currencies.json") as f: with open("frontend/static/assets/currencies.json") as f:
currency_dict = json.load(f) currency_dict = json.load(f)
currency_choices = [(int(val), label) for val, label in list(currency_dict.items())] currency_choices = [(int(val), label) for val, label in list(currency_dict.items())]

View File

@ -8,7 +8,6 @@ from control.models import AccountingDay, BalanceLog
@admin.register(AccountingDay) @admin.register(AccountingDay)
class AccountingDayAdmin(ImportExportModelAdmin): class AccountingDayAdmin(ImportExportModelAdmin):
list_display = ( list_display = (
"day", "day",
"contracted", "contracted",
@ -34,7 +33,6 @@ class AccountingDayAdmin(ImportExportModelAdmin):
@admin.register(BalanceLog) @admin.register(BalanceLog)
class BalanceLogAdmin(ImportExportModelAdmin): class BalanceLogAdmin(ImportExportModelAdmin):
list_display = ( list_display = (
"time", "time",
"total", "total",

View File

@ -1,5 +1,9 @@
[tool.isort] [tool.ruff]
profile = "black" # Exclude a variety of commonly ignored directories.
exclude = [
"*migrations/*",
"api/nick_generator/nick_generator.py",
]
[tool.coverage.run] [tool.coverage.run]
omit = [ omit = [