Skip to content

Commit

Permalink
Update versions for our pre-commit linters (#6)
Browse files Browse the repository at this point in the history
* Update pre-commit version

* Automated changes from black.
  • Loading branch information
jonathangreen authored Feb 9, 2024
1 parent 8cd13b4 commit 9fffa9e
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 33 deletions.
16 changes: 8 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -17,14 +17,14 @@ repos:
- id: mixed-line-ending

- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
rev: v3.15.0
hooks:
- id: pyupgrade
args:
- --py38-plus

- repo: https://github.com/myint/autoflake
rev: v2.0.0
rev: v2.2.1
hooks:
- id: autoflake
args:
Expand All @@ -33,32 +33,32 @@ repos:
- --ignore-init-module-imports

- repo: https://github.com/psf/black
rev: 22.10.0
rev: 24.1.1
hooks:
- id: black
name: Run black

- repo: https://github.com/PyCQA/isort
rev: 5.11.5
rev: 5.13.2
hooks:
- id: isort
name: Run isort

- repo: https://github.com/sirosen/check-jsonschema
rev: 0.19.2
rev: 0.28.0
hooks:
- id: check-github-workflows
- id: check-github-actions

- repo: https://github.com/pappasam/toml-sort
rev: v0.22.1
rev: v0.23.1
hooks:
- id: toml-sort
args: []
files: pyproject.toml

- repo: https://github.com/jackdewinter/pymarkdown
rev: v0.9.8
rev: v0.9.17
hooks:
- id: pymarkdown
args:
Expand Down
6 changes: 3 additions & 3 deletions tests/admin/test_library_admin_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ def _add_library_states_data(
"library_email_domains-INITIAL_FORMS": 0,
"library_email_domains-MIN_NUM_FORMS": 0,
"library_email_domains-MAX_NUM_FORMS": 1000,
"library_email_domains-__prefix__-library": library.id
if library
else "",
"library_email_domains-__prefix__-library": (
library.id if library else ""
),
}
)

Expand Down
8 changes: 5 additions & 3 deletions tests/views/test_card_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,11 @@ def test_card_request_bad_data(self):
self.assertFormError(
resp.context["form"],
field,
errors + ["First name is mandatory"]
if field == "first_name"
else errors,
(
errors + ["First name is mandatory"]
if field == "first_name"
else errors
),
)

def test_card_request_no_patron_address(self):
Expand Down
3 changes: 2 additions & 1 deletion tests/views/test_verification_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ def test_no_password_form(self):
def test_password_set_post(self):
"""Is the password set on a post to the verification form
This sounds funny, but the password set form is on the email verification page
because a user may be created without a password, and will subsequently require a password to log in"""
because a user may be created without a password, and will subsequently require a password to log in
"""
user = self._default_user
token = Tokens.generate(
TokenTypes.EMAIL_VERIFICATION, expires_in_days=1, email=user.email
Expand Down
3 changes: 2 additions & 1 deletion virtual_library_card/geoloc.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ class PostProcess:
@classmethod
def mapquest_reverse_geocode(cls, data: dict) -> None:
"""Some mapquest data is different than what we expect the hierarchy to be.
Eg. US territories are treated as countries on their own, they should be under the US Country."""
Eg. US territories are treated as countries on their own, they should be under the US Country.
"""
if (
len(data.get("results", [])) < 1
or len(locations := data["results"][0].get("locations", [])) < 1
Expand Down
1 change: 1 addition & 0 deletions virtual_library_card/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""

from django.conf import settings
from django.conf.urls.static import static
from django.urls import include, path
Expand Down
12 changes: 6 additions & 6 deletions virtuallibrarycard/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,9 +395,9 @@ def change_view(
"""Overridden to add the password reset url extra context"""
user = LibraryCard.objects.get(id=object_id).user
if user:
extra_context[
"reset_password_url"
] = f"../../../customuser/{user.id}/password"
extra_context["reset_password_url"] = (
f"../../../customuser/{user.id}/password"
)
return super().change_view(request, object_id, form_url, extra_context)


Expand Down Expand Up @@ -524,9 +524,9 @@ def export_users_by_consent(request: HttpRequest):

content.seek(0)
response = StreamingHttpResponse(content, content_type="text/csv")
response[
"Content-Disposition"
] = f"attachment; filename=consented_users_{consent_type}_{datetime.datetime.now()}.csv"
response["Content-Disposition"] = (
f"attachment; filename=consented_users_{consent_type}_{datetime.datetime.now()}.csv"
)
return response


Expand Down
3 changes: 2 additions & 1 deletion virtuallibrarycard/business_rules/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ def _place_hierarchy_match(
country: str = None,
) -> bool:
"""Test from the current place all the way to the last parent available.
All levels of the place hierarchy MUST match even if the value isn't provided in the keyword args."""
All levels of the place hierarchy MUST match even if the value isn't provided in the keyword args.
"""
match_types = {
Place.Types.COUNTRY: country,
Place.Types.STATE: state,
Expand Down
3 changes: 2 additions & 1 deletion virtuallibrarycard/business_rules/library_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,8 @@ def iter_clean_lines(io: IO) -> Generator[str, None, None]:
"""Iterate over an IO object and ignore blank lines
This is to specifically ignore empty last lines in csvs
decoding is done through charset detection
This handles unicode BOM characters since we do not control how the browser might read the file"""
This handles unicode BOM characters since we do not control how the browser might read the file
"""
# Detect charset and the decode entire file
detectline = io.read(128)
io.seek(0)
Expand Down
12 changes: 6 additions & 6 deletions virtuallibrarycard/forms/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,12 @@ def __init__(self, *args, **kwargs):
if (
instance and not instance.place
): # Edition just after creation form with minimal fields
self.fields[
"email"
].widget.value_from_datadict = lambda *args: self.instance.email
self.fields[
"first_name"
].widget.value_from_datadict = lambda *args: self.instance.first_name
self.fields["email"].widget.value_from_datadict = (
lambda *args: self.instance.email
)
self.fields["first_name"].widget.value_from_datadict = (
lambda *args: self.instance.first_name
)
self.fields["email"].widget.attrs["disabled"] = True

except KeyError as e:
Expand Down
6 changes: 3 additions & 3 deletions virtuallibrarycard/views/views_library_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ def get_form_kwargs(self):

def get_context_data(self, *args, **kwargs):
context = super().get_context_data(**kwargs)
context[
"patron_address_mandatory"
] = self.model.library.patron_address_mandatory
context["patron_address_mandatory"] = (
self.model.library.patron_address_mandatory
)
return context

def get_success_url(self):
Expand Down

0 comments on commit 9fffa9e

Please sign in to comment.