Skip to content

Commit

Permalink
Switch from flake8 and isort to ruff (#480)
Browse files Browse the repository at this point in the history
* Add ruff configuration

* Fix import order errors

* Replace flake8 with ruff in CI

* Remove flake8 and isort dependencies
  • Loading branch information
TimJentzsch committed May 10, 2023
1 parent cb67426 commit 0350966
Show file tree
Hide file tree
Showing 9 changed files with 276 additions and 337 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ jobs:
run: |
sudo apt-get install libjpeg8 libjpeg-dev libpng-dev libpq-dev git -y
poetry install
- name: Install latest pyflakes and pycodestyle version
run: |
poetry run pip install pyflakes
poetry run pip install pycodestyle
- name: Run Static Analysis
run: |
/usr/bin/git diff -u ${{ github.event.pull_request.base.sha }} | poetry run flake8 --diff
poetry run ruff .
20 changes: 3 additions & 17 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,9 @@
repos:
- repo: https://github.com/asottile/seed-isort-config
rev: v2.2.0
hooks:
- id: seed-isort-config
- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.10.1
hooks:
- id: isort
- repo: https://github.com/ambv/black
rev: 22.3.0
hooks:
- id: black
- repo: https://github.com/pycqa/flake8
rev: 4.0.1
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.265
hooks:
- id: flake8
additional_dependencies: [
"flake8-annotations==2.9.0",
"flake8-docstrings==1.6.0",
"flake8-import-order==0.18.1",
"flake8-variables-names==0.0.5"
]
- id: ruff
68 changes: 68 additions & 0 deletions .ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
select = [
"E", # pycodestyle (error)
"W", # pycodestyle (warning)
"D", # pydocstyle
"I", # isort
"ANN", # flake8-annotations
]
ignore = [
"ANN101", # missing-type-self
"ANN401", # any-type
"D100", # undocumented-public-module
"D101", # undocumented-public-class
"D105", # undocumented-magic-method
"D106", # undocumented-public-nested-class
"D203", # one-blank-line-before-class
"D212", # multi-line-summary-first-line
"D213", # multi-line-summary-second-line
"D404", # docstring-starts-with-this
"D407", # dashed-underline-after-section
"E501", # line-too-long
]

exclude = [
"build",
"dist",
"blossom/bootstrap/*",
"*/migrations/*",
"docker/*",
"./local_settings.py",
]

line-length = 88 # Same as black

[per-file-ignores]
"test_*" = ["D"] # Disable documentation lints for test files

[isort]
known-third-party = [
"better_exceptions",
"blossom_wrapper",
"click",
"django",
"django_filters",
"dotenv",
"dpath",
"drf_yasg",
"ipware",
"markdown",
"mimesis",
"opentelemetry",
"praw",
"prawcore",
"psaw",
"pytest",
"pytest_django",
"pytz",
"pyuwsgi",
"requests",
"rest_framework",
"rest_framework_api_key",
"revproxy",
"shiv",
"slack",
"social_core",
"social_django",
"stripe",
"toml"
]
3 changes: 1 addition & 2 deletions blossom/api/views/find.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
from urllib.parse import urlparse

from django.views.decorators.csrf import csrf_exempt
from drf_yasg.openapi import Parameter
from drf_yasg.openapi import Parameter, Schema
from drf_yasg.openapi import Response as DocResponse
from drf_yasg.openapi import Schema
from drf_yasg.utils import swagger_auto_schema
from rest_framework import status
from rest_framework.request import Request
Expand Down
3 changes: 1 addition & 2 deletions blossom/api/views/submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@
from django.utils.decorators import method_decorator
from django.views.decorators.csrf import csrf_exempt
from django_filters.rest_framework import DjangoFilterBackend
from drf_yasg.openapi import Parameter
from drf_yasg.openapi import Parameter, Schema
from drf_yasg.openapi import Response as DocResponse
from drf_yasg.openapi import Schema
from drf_yasg.utils import swagger_auto_schema
from rest_framework import status, viewsets
from rest_framework.decorators import action
Expand Down
3 changes: 1 addition & 2 deletions blossom/api/views/transcription.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
from django.utils import timezone
from django.views.decorators.csrf import csrf_exempt
from django_filters.rest_framework import DjangoFilterBackend
from drf_yasg.openapi import Parameter
from drf_yasg.openapi import Parameter, Schema
from drf_yasg.openapi import Response as DocResponse
from drf_yasg.openapi import Schema
from drf_yasg.utils import swagger_auto_schema
from rest_framework import status, viewsets
from rest_framework.decorators import action
Expand Down
3 changes: 1 addition & 2 deletions blossom/api/views/volunteer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
from django.utils.decorators import method_decorator
from django.views.decorators.csrf import csrf_exempt
from django_filters.rest_framework import DjangoFilterBackend
from drf_yasg.openapi import Parameter
from drf_yasg.openapi import Parameter, Schema
from drf_yasg.openapi import Response as DocResponse
from drf_yasg.openapi import Schema
from drf_yasg.utils import no_body, swagger_auto_schema
from rest_framework import status, viewsets
from rest_framework.decorators import action
Expand Down
Loading

0 comments on commit 0350966

Please sign in to comment.