Skip to content

Commit

Permalink
feat: ruff integration (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasvinclav authored Jan 10, 2023
1 parent 22918d4 commit 3aca1d4
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 48 deletions.
41 changes: 7 additions & 34 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
rev: v4.3.0
hooks:
- id: check-case-conflict
- id: check-json
Expand All @@ -9,44 +9,17 @@ repos:
- id: check-toml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/asottile/pyupgrade
rev: v2.29.0
hooks:
- id: pyupgrade
args: [--py37-plus]
- repo: https://github.com/psf/black
rev: 22.10.0
rev: 22.12.0
hooks:
- id: black
- repo: https://github.com/asottile/blacken-docs
rev: v1.11.0
hooks:
- id: blacken-docs
additional_dependencies:
- black==21.9b0
- repo: https://github.com/pycqa/isort
rev: 5.9.3
hooks:
- id: isort
args: ["--profile", "black"]
- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
hooks:
- id: flake8
args:
- "--max-line-length=120"
additional_dependencies:
- flake8-bugbear
- flake8-comprehensions
- flake8-tidy-imports
- flake8-typing-imports
- repo: https://github.com/hadialqattan/pycln
rev: v2.0.4
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.217
hooks:
- id: pycln
args: [--config=pyproject.toml]
- id: ruff
args: ["--force-exclude"]
- repo: https://github.com/compilerla/conventional-pre-commit
rev: v1.4.0
rev: v2.1.1
hooks:
- id: conventional-pre-commit
stages: [commit-msg]
Expand Down
25 changes: 16 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,22 @@ classifiers = [
[tool.black]
target-version = ["py38", "py39"]

[tool.isort]
profile = "black"

[[tool.mypy.overrides]]
module = "tests.*"
allow_untyped_defs = true

[tool.pycln]
all = true
[tool.ruff]
fix = true
line-length = 88
select = [
"E", # pycodestyle errors
"W", # pycodestyle warnings
"F", # pyflakes
"I", # isort
"C", # flake8-comprehensions
"B", # flake8-bugbear
]
ignore = [
"E501", # line too long, handled by black
"B905", # zip() without strict=True
"C901", # too complex
]

[tool.poetry.dependencies]
python = ">=3.8"
Expand Down
5 changes: 2 additions & 3 deletions src/unfold/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
from django.utils.safestring import mark_safe
from django.utils.text import capfirst
from django.utils.translation import gettext_lazy as _

from unfold.utils import display_for_field

from .exceptions import UnfoldException
Expand Down Expand Up @@ -487,10 +486,10 @@ def save_model(self, request, obj, form, change):
def _get_instance_method(self, method_name):
try:
method = getattr(self, method_name)
except AttributeError:
except AttributeError as e:
raise UnfoldException(
f"Method {method_name} specified does not exist on current object"
)
) from e

if not callable(method):
raise UnfoldException(f"{method_name} is not callable")
Expand Down
1 change: 0 additions & 1 deletion src/unfold/contrib/forms/widgets.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from django.forms import Widget

from unfold.widgets import PROSE_CLASSES

WYSIWYG_CLASSES = [
Expand Down
4 changes: 3 additions & 1 deletion src/unfold/forms.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from django import forms
from django.contrib.admin.forms import AdminAuthenticationForm
from django.contrib.admin.forms import (
AdminAuthenticationForm,
)
from django.contrib.admin.forms import (
AdminPasswordChangeForm as BaseAdminOwnPasswordChangeForm,
)
Expand Down

0 comments on commit 3aca1d4

Please sign in to comment.