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 pre-commit #766

Merged
merged 2 commits into from
Feb 11, 2025
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
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: v5.0.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.17.0
rev: v3.19.1
hooks:
- id: pyupgrade
args:
- --py310-plus

- repo: https://github.com/myint/autoflake
rev: v2.0.0
rev: v2.3.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: 25.1.0
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.31.1
hooks:
- id: check-github-workflows
- id: check-github-actions

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

- repo: https://github.com/jackdewinter/pymarkdown
rev: v0.9.8
rev: v0.9.27
hooks:
- id: pymarkdown
args:
Expand Down
3 changes: 2 additions & 1 deletion alembic/versions/4f716132bf58_upload_logos_to_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2022-12-01 08:22:19.889670+00:00

"""

import logging
from dataclasses import dataclass

Expand Down Expand Up @@ -32,7 +33,7 @@ def upgrade() -> None:
log.setLevel(logging.INFO)
connection = op.get_bind()
result = connection.execute("SELECT internal_urn, name, logo FROM libraries;")
for (lib_uuid, lib_name, lib_logo) in result:
for lib_uuid, lib_name, lib_logo in result:
if lib_logo:
log.info(f"Uploading logo for {lib_name}")
uploaded_path = LibraryLogoStore.write_from_b64(
Expand Down
1 change: 1 addition & 0 deletions alembic/versions/7dc7590e1819_remove_library_logo.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2023-04-28 07:20:50.401126+00:00

"""

import sqlalchemy as sa

from alembic import op
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2023-04-20 21:34:10.306771+00:00

"""

from alembic import op

# revision identifiers, used by Alembic.
Expand Down
1 change: 1 addition & 0 deletions alembic/versions/aa6b44e2e879_library_logo_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2022-11-28 08:41:40.026366+00:00

"""

import sqlalchemy as sa

from alembic import op
Expand Down
7 changes: 4 additions & 3 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Library registry web application."""

import os
import sys
import urllib.parse
Expand Down Expand Up @@ -239,9 +240,9 @@ def application_version():
@returns_problem_detail
def hearbeat():
version_info = application_version()
version_info[
"WARNING"
] = "The /heartbeat endpoint is deprecated. Please use /version.json instead."
version_info["WARNING"] = (
"The /heartbeat endpoint is deprecated. Please use /version.json instead."
)
return version_info


Expand Down
2 changes: 1 addition & 1 deletion controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ def library_details(self, uuid, library=None, patron_count=None):

def _areas(self, areas):
result = {}
for (a, b) in [
for a, b in [
(ServiceArea.FOCUS, "focus"),
(ServiceArea.ELIGIBILITY, "service"),
]:
Expand Down
6 changes: 1 addition & 5 deletions model.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ def patron_counts_by_library(self, _db, libraries):

# Convert the results to a dictionary.
results = dict()
for (library_id, count) in rows:
for library_id, count in rows:
results[library_id] = count

return results
Expand Down Expand Up @@ -1217,7 +1217,6 @@ def get_hyperlink(cls, library, rel):


class LibraryAlias(Base):

"""An alternate name for a library."""

__tablename__ = "libraryalias"
Expand Down Expand Up @@ -1527,7 +1526,6 @@ def overlaps_not_counting_border(self, qu):
return qu.filter(intersects).filter(touches == False)

def lookup_inside(self, name, using_overlap=False, using_external_source=True):

"""Look up a named Place that is geographically 'inside' this Place.

:param name: The name of a place, such as "Boston" or
Expand Down Expand Up @@ -1707,7 +1705,6 @@ def __repr__(self):


class PlaceAlias(Base):

"""An alternate name for a place."""

__tablename__ = "placealiases"
Expand Down Expand Up @@ -2284,7 +2281,6 @@ def _decode(self, _db, token, supposed_signature):


class ExternalIntegration(Base):

"""An external integration contains configuration for connecting
to a third-party API.
"""
Expand Down
8 changes: 4 additions & 4 deletions scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def run(self, cmd_args=None, place_class=Place):
service_area, focus_area = AuthenticationDocument.parse_service_and_focus_area(
self._db, service_area, focus_area, place_class
)
for (valid, unknown, ambiguous) in [service_area, focus_area]:
for valid, unknown, ambiguous in [service_area, focus_area]:
if unknown:
raise ValueError("Unknown places: %r" % list(unknown.items()))
if ambiguous:
Expand Down Expand Up @@ -637,9 +637,9 @@ def do_run(self, _db=None, cmd_args=None, output=sys.stdout):
'Invalid delegate: %s. Expected something ending with "/AdobeAuth/"'
% delegate
)
integration.setting(
Configuration.ADOBE_VENDOR_ID_DELEGATE_URL
).value = json.dumps(delegates)
integration.setting(Configuration.ADOBE_VENDOR_ID_DELEGATE_URL).value = (
json.dumps(delegates)
)
_db.commit()


Expand Down
6 changes: 3 additions & 3 deletions tests/fixtures/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,9 +538,9 @@ def directory(self) -> str:


@pytest.fixture(scope="function")
def temporary_directory_configuration() -> Iterable[
TemporaryDirectoryConfigurationFixture
]:
def temporary_directory_configuration() -> (
Iterable[TemporaryDirectoryConfigurationFixture]
):
fix = TemporaryDirectoryConfigurationFixture.create()
yield fix
fix.close()
Expand Down
21 changes: 9 additions & 12 deletions tests/test_adobe_vendor_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,11 @@ def dequeue(self, *args, **kwargs):


class TestAdobeVendorIdController:
def test_signin_handler(self):
...
def test_signin_handler(self): ...

def test_userinfo_handler(self):
...
def test_userinfo_handler(self): ...

def test_status_handler(self):
...
def test_status_handler(self): ...


class VendorIDFixture:
Expand All @@ -74,9 +71,9 @@ def integration(self):
goal=ExternalIntegration.DRM_GOAL,
)
integration.setting(Configuration.ADOBE_VENDOR_ID).value = "VENDORID"
integration.setting(
Configuration.ADOBE_VENDOR_ID_NODE_VALUE
).value = self.NODE_VALUE
integration.setting(Configuration.ADOBE_VENDOR_ID_NODE_VALUE).value = (
self.NODE_VALUE
)
return integration


Expand Down Expand Up @@ -107,9 +104,9 @@ def test_accessor_vendor_id_not_configured(

def test_accessor_with_delegates(self, vendor_id_fixture: VendorIDFixture):
integration = vendor_id_fixture.integration()
integration.setting(
Configuration.ADOBE_VENDOR_ID_DELEGATE_URL
).value = json.dumps(["delegate"])
integration.setting(Configuration.ADOBE_VENDOR_ID_DELEGATE_URL).value = (
json.dumps(["delegate"])
)
vendor_id, node_value, delegates = Configuration.vendor_id(
vendor_id_fixture.db.session
)
Expand Down
4 changes: 3 additions & 1 deletion tests/test_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -1775,7 +1775,7 @@ def test_register_fails_on_missing_email_in_authentication_document(
):
fixture = registry_controller_fixture

for (rel, error, badlink) in (
for rel, error, badlink in (
(
"http://librarysimplified.org/rel/designated-agent/copyright",
"Invalid or missing copyright designated agent email address",
Expand Down Expand Up @@ -1850,6 +1850,7 @@ def test_registration_fails_if_email_server_fails(
"""Even if everything looks good, registration can fail if
the library registry can't send out the validation emails.
"""

# Simulate an SMTP server that won't accept email for
# whatever reason.
class NonfunctionalEmailer(MockEmailer):
Expand Down Expand Up @@ -1895,6 +1896,7 @@ def test_registration_fails_if_email_server_unusable(
WHEN: A registration is requested
THEN: A ProblemDetail of an appropriate type should be returned
"""

# Simulate an SMTP server that is wholly unresponsive
class UnresponsiveEmailer(Emailer):
def _send_email(*args):
Expand Down
1 change: 1 addition & 0 deletions tests/test_util_string_helpers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test the helper objects in util.string."""

import base64 as stdlib_base64
import re

Expand Down
1 change: 1 addition & 0 deletions util/app_server.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Implement logic common to more than one of the Simplified applications."""

import logging
import sys
import traceback
Expand Down
1 change: 1 addition & 0 deletions util/flask_util.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utilities for Flask applications."""

import ipaddress
import re

Expand Down
2 changes: 1 addition & 1 deletion util/problem_detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

As per http://datatracker.ietf.org/doc/draft-ietf-appsawg-http-problem/
"""

import json as j
import logging

Expand All @@ -22,7 +23,6 @@ def json(type, status, title, detail=None, instance=None, debug_message=None):


class ProblemDetail:

"""A common type of problem."""

JSON_MEDIA_TYPE = JSON_MEDIA_TYPE
Expand Down
Loading