Switch to flakehell & wemake python styleguide

This commit is contained in:
Gabriel Augendre 2021-12-29 14:54:21 +01:00
parent 81d8d9eb71
commit ceb159a343
6 changed files with 32 additions and 21 deletions

12
.flake8
View file

@ -1,12 +0,0 @@
[flake8]
ignore =
# long lines
E501,
# deprecated rule: https://www.flake8rules.com/rules/W503.html
W503,
# conflict with black on PEP8 interpretation
E203,
# class attribute is shadowing a python builtin
A003,
max-complexity = 10

View file

@ -43,10 +43,10 @@ repos:
rev: v1.4.11
hooks:
- id: djhtml
- repo: https://github.com/pycqa/flake8
rev: 4.0.1
- repo: https://github.com/mcarans/flakehell
rev: 1b84f4dd6c16232b5c0c6206511427676ab55f5b
hooks:
- id: flake8
- id: flakehell
additional_dependencies:
- flake8-annotations-complexity
- flake8-builtins
@ -56,6 +56,7 @@ repos:
- flake8-noqa
- flake8-pytest-style
- flake8-pyi
- wemake-python-styleguide
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.5.1
hooks:

View file

@ -81,6 +81,30 @@ ignore_missing_imports = true
[tool.django-stubs]
django_settings_module = "blog.settings"
[tool.flakehell]
max_complexity = 10
format = "grouped"
[tool.flakehell.plugins]
"flake8-*" = [
"+*",
# long lines
"-E501",
# conflict with black on PEP8 interpretation
"-E203",
# deprecated rule: https://www.flake8rules.com/rules/W503.html
"-W503",
]
flake8-builtins = ["-A003"] # class attribute is shadowing a python builtin
flake8-quotes = ["-Q000"] # found double quotes, conflict with black
flake8-commas = ["-C812"] # missing trailing comma, conflict with black
flake8-docstrings = ["-D1??"] # missing docstring
flake8-rst-docstrings = ["-*"]
[tool.flakehell.exceptions."**/migrations/*"]
[tool.flakehell.exceptions."**/tests/*"]
flake8-bandit = ["-S101"] # Use of assert detected.
[build-system]
requires = ["poetry-core>=1.0.0"]

View file

@ -34,9 +34,7 @@ class CompleteFeed(BaseFeed):
class TagFeed(BaseFeed):
def get_object( # type: ignore[override]
self, request: WSGIRequest, *args, **kwargs
) -> Tag:
def get_object(self, request: WSGIRequest, *args, **kwargs) -> Tag: # type: ignore[override]
return Tag.objects.get(slug=kwargs.get("slug"))
def title(self, tag: Tag) -> str:

View file

@ -41,7 +41,7 @@ class AttachmentAdmin(admin.ModelAdmin):
def processed_file_url(self, instance):
if instance.processed_file:
return format_html(
'{} <a class="copy-button" data-to-copy="{}" href="#">&#128203;</a>',
'{0} <a class="copy-button" data-to-copy="{1}" href="#">&#128203;</a>',
instance.processed_file.url,
instance.processed_file.url,
)
@ -50,7 +50,7 @@ class AttachmentAdmin(admin.ModelAdmin):
def original_file_url(self, instance):
if instance.original_file:
return format_html(
'{} <a class="copy-button" data-to-copy="{}" href="#">&#128203;</a>',
'{0} <a class="copy-button" data-to-copy="{1}" href="#">&#128203;</a>',
instance.original_file.url,
instance.original_file.url,
)

View file

@ -5,7 +5,7 @@ import sys
def main():
"""Run administrative tasks."""
"""Run administrative tasks.""" # noqa: DAR401
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "blog.settings")
try:
from django.core.management import execute_from_command_line