Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ruff #959

Merged
merged 1 commit into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ tests:
.PHONY: reformat
reformat:
ruff format .
ruff --fix .
ruff check . --fix

.PHONY: lint
lint:
ruff .
ruff check .

.PHONY: docs
docs: clean
Expand Down
2 changes: 1 addition & 1 deletion example/app/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class TestForm(forms.Form):
message = forms.CharField(required=False, help_text="<i>my_help_text</i>")
sender = forms.EmailField(label="Sender © unicode", help_text='E.g., "[email protected]"')
secret = forms.CharField(initial=42, widget=forms.HiddenInput)
weird = forms.CharField(help_text="strings are now utf-8 \u03BCnico\u0394é!")
weird = forms.CharField(help_text="strings are now utf-8 \u03bcnico\u0394é!")
cc_myself = forms.BooleanField(
required=False, help_text='cc stands for "carbon copy." You will get a copy in your mailbox.'
)
Expand Down
1 change: 1 addition & 0 deletions example/app/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
middleware here, or combine a Django application with an application of another
framework.
"""

import os

from django.core.wsgi import get_wsgi_application
Expand Down
16 changes: 8 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,33 +45,33 @@ Source = "https://github.com/zostera/django-bootstrap3"

[tool.ruff]
fix = false
fixable = [
line-length = 120
lint.fixable = [
"I001", # isort (sorting)
"F", # flake8
"D", # docformatter
"UP", # pyupgrade
]
ignore = [
lint.ignore = [
"D1", # D1: Missing docstring error codes (because not every function and class has a docstring)
"D203", # D203: 1 blank line required before class docstring (conflicts with D211 and should be disabled, see https://github.com/PyCQA/pydocstyle/pull/91)
"D212", # D212: Multi-line docstring summary should start at the first line
"D301", # D301: Use r”“” if any backslashes in a docstring (unclear how else to handle backslashes in docstrings)
]
line-length = 120
select = [
lint.select = [
"D", # pydocstyle
"E", # pycodestyle
"F", # flake8
"I", # isort
"UP", # pyupgrade
]
src = ["src"]
target-version = "py38"
unfixable = [
lint.unfixable = [
"F8", # names in flake8, such as defined but unused variables
]
src = ["src"]
target-version = "py38"

[tool.ruff.isort]
[tool.ruff.lint.isort]
known-first-party = ["bootstrap3", "app"]
known-third-party = ["django"]

Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-r requirements-test.txt
-r docs/requirements.txt
twine==4.0.2
twine==5.0.0
build==1.2.1
setuptools==69.5.1
setuptools_scm==8.0.4
2 changes: 1 addition & 1 deletion src/bootstrap3/__about__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import importlib.metadata

__version__ = importlib.metadata.version('django-bootstrap3')
__version__ = importlib.metadata.version("django-bootstrap3")
26 changes: 20 additions & 6 deletions src/bootstrap3/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,26 @@
from django.forms.widgets import CheckboxInput
from django.utils.safestring import mark_safe

from .bootstrap import get_bootstrap_setting, get_field_renderer, get_form_renderer, get_formset_renderer
from .bootstrap import (
get_bootstrap_setting,
get_field_renderer,
get_form_renderer,
get_formset_renderer,
)
from .components import render_icon
from .exceptions import BootstrapError
from .text import text_concat, text_value
from .utils import add_css_class, render_tag

FORM_GROUP_CLASS = "form-group"

WIDGETS_NO_REQUIRED = (AdminFileWidget, HiddenInput, FileInput, CheckboxInput, CheckboxSelectMultiple)
WIDGETS_NO_REQUIRED = (
AdminFileWidget,
HiddenInput,
FileInput,
CheckboxInput,
CheckboxSelectMultiple,
)


def render_formset(formset, **kwargs):
Expand Down Expand Up @@ -96,9 +107,8 @@ def render_button(
if button_type:
if button_type not in ("submit", "reset", "button", "link"):
raise BootstrapError(
'Parameter "button_type" should be "submit", "reset", "button", "link" or empty ("{}" given).'.format(
button_type
)
'Parameter "button_type" should be "submit", "reset", "button", "link" or empty '
+ f'("{button_type}" given).'
)
attrs["type"] = button_type
classes = add_css_class(classes, extra_classes)
Expand All @@ -117,7 +127,11 @@ def render_button(
attrs["value"] = value
if title:
attrs["title"] = title
return render_tag(tag, attrs=attrs, content=mark_safe(text_concat(icon_content, content, separator=" ")))
return render_tag(
tag,
attrs=attrs,
content=mark_safe(text_concat(icon_content, content, separator=" ")),
)


def render_field_and_label(field, label, field_class="", label_for=None, label_class="", layout="", **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion tests/app/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class TestForm(forms.Form):
message = forms.CharField(required=False, help_text="<i>my_help_text</i>")
sender = forms.EmailField(label="Sender © unicode", help_text='E.g., "[email protected]"')
secret = forms.CharField(initial=42, widget=forms.HiddenInput)
weird = forms.CharField(help_text="strings are now utf-8 \u03BCnico\u0394é!")
weird = forms.CharField(help_text="strings are now utf-8 \u03bcnico\u0394é!")
cc_myself = forms.BooleanField(
required=False, help_text='cc stands for "carbon copy." You will get a copy in your mailbox.'
)
Expand Down