Skip to content

Commit

Permalink
Bump up the versions used in our pre-commit hooks (#2092)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathangreen authored Sep 30, 2024
1 parent 881a590 commit ebcddca
Show file tree
Hide file tree
Showing 120 changed files with 382 additions and 454 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.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -17,19 +17,19 @@ repos:
- id: mixed-line-ending

- repo: https://github.com/asottile/pyupgrade
rev: v3.14.0
rev: v3.17.0
hooks:
- id: pyupgrade
args:
- --py310-plus

- repo: https://github.com/MarcoGorelli/absolufy-imports
rev: v0.3.0
rev: v0.3.1
hooks:
- id: absolufy-imports

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

- repo: https://github.com/psf/black
rev: 23.9.1
rev: 24.8.0
hooks:
- id: black
name: Run black

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

- repo: https://github.com/sirosen/check-jsonschema
rev: 0.27.0
rev: 0.29.2
hooks:
- id: check-github-workflows
- id: check-github-actions
Expand All @@ -63,7 +63,7 @@ repos:
files: pyproject\.toml

- repo: https://github.com/jackdewinter/pymarkdown
rev: v0.9.13.4
rev: v0.9.23
hooks:
- id: pymarkdown
args:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
See: https://alembic.sqlalchemy.org/en/latest/cookbook.html#building-an-up-to-date-database-from-scratch
"""

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: 2024-03-18 01:34:28.381129+00:00
"""

from functools import cache

import sqlalchemy as sa
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2024-03-19 21:48:45.911507+00:00
"""

import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2024-04-17 19:03:20.953330+00:00
"""

import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2024-05-22 19:08:51.390547+00:00
"""

from alembic import op

# revision identifiers, used by Alembic.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2024-06-12 00:53:37.497861+00:00
"""

import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2024-08-21 23:23:48.085451+00:00
"""

import sqlalchemy as sa
from alembic import op
from sqlalchemy.orm.session import Session
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2024-09-05 16:04:45.789665+00:00
"""

from alembic import op

# revision identifiers, used by Alembic.
Expand Down
3 changes: 1 addition & 2 deletions bin/informational/adobe-id-for-short-client-token
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ REGISTRY_RESPONSE_RE = re.compile(
)


class InvalidTokenException(Exception):
...
class InvalidTokenException(Exception): ...


def decompose_token(token):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@


class DiscoveryServiceLibraryRegistrationsController(AdminPermissionsControllerMixin):

"""List the libraries that have been registered with a specific
OpdsRegistrationService, and allow the admin to register a library with
a OpdsRegistrationService.
Expand Down
12 changes: 6 additions & 6 deletions src/palace/manager/api/admin/controller/integration_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ def _cached_protocols(self) -> dict[str, dict[str, Any]]:
"settings": api.settings_class().configuration_form(self._db),
}
if issubclass(api, HasLibraryIntegrationConfiguration):
protocol[
"library_settings"
] = api.library_settings_class().configuration_form(self._db)
protocol["library_settings"] = (
api.library_settings_class().configuration_form(self._db)
)
if issubclass(api, HasChildIntegrationConfiguration):
protocol[
"child_settings"
] = api.child_settings_class().configuration_form(self._db)
protocol["child_settings"] = (
api.child_settings_class().configuration_form(self._db)
)
protocol.update(api.protocol_details(self._db))
protocols.append((name, protocol))
protocols.sort(key=lambda x: x[0])
Expand Down
48 changes: 27 additions & 21 deletions src/palace/manager/api/admin/dashboard_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,21 +229,25 @@ def _run_collections_stats_queries(

return {
c.id: _CollectionStatisticsQueryResults(
metered_title_counts=metered_title_counts[c.id]
if c.id in metered_title_counts
else {},
unlimited_title_counts=unlimited_title_counts[c.id]
if c.id in unlimited_title_counts
else {},
open_access_title_counts=open_access_title_counts[c.id]
if c.id in open_access_title_counts
else {},
loanable_title_counts=loanable_title_counts[c.id]
if c.id in loanable_title_counts
else {},
metered_license_stats=metered_license_stats[c.id]
if c.id in metered_license_stats
else {},
metered_title_counts=(
metered_title_counts[c.id] if c.id in metered_title_counts else {}
),
unlimited_title_counts=(
unlimited_title_counts[c.id]
if c.id in unlimited_title_counts
else {}
),
open_access_title_counts=(
open_access_title_counts[c.id]
if c.id in open_access_title_counts
else {}
),
loanable_title_counts=(
loanable_title_counts[c.id] if c.id in loanable_title_counts else {}
),
metered_license_stats=(
metered_license_stats[c.id] if c.id in metered_license_stats else {}
),
)
for c in collections
}
Expand Down Expand Up @@ -364,12 +368,14 @@ def _gather_patron_stats(
return {
library.short_name: PatronStatistics(
total=patron_count[library.id] if library.id in patron_count else 0,
with_active_loan=active_loans[library.id]
if library.id in active_loans
else 0,
with_active_loan_or_hold=active_loan_or_hold[library.id]
if library.id in active_loan_or_hold
else 0,
with_active_loan=(
active_loans[library.id] if library.id in active_loans else 0
),
with_active_loan_or_hold=(
active_loan_or_hold[library.id]
if library.id in active_loan_or_hold
else 0
),
loans=loan_count[library.id] if library.id in loan_count else 0,
holds=hold_count[library.id] if library.id in hold_count else 0,
)
Expand Down
1 change: 0 additions & 1 deletion src/palace/manager/api/adobe_vendor_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@


class AuthdataUtility(LoggerMixin):

"""Generate authdata JWTs as per the Vendor ID Service spec:
https://docs.google.com/document/d/1j8nWPVmy95pJ_iU4UTC-QgHK2QhDUSdQ0OQTFR2NE_0
Expand Down
6 changes: 2 additions & 4 deletions src/palace/manager/api/authentication/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,10 @@
from palace.manager.util.problem_detail import ProblemDetail


class AuthProviderSettings(BaseSettings):
...
class AuthProviderSettings(BaseSettings): ...


class AuthProviderLibrarySettings(BaseSettings):
...
class AuthProviderLibrarySettings(BaseSettings): ...


SettingsType = TypeVar("SettingsType", bound=AuthProviderSettings, covariant=True)
Expand Down
2 changes: 1 addition & 1 deletion src/palace/manager/api/authentication/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ def testing_patron_or_bust(self, _db: Session) -> tuple[Patron, str | None]:
)
raise IntegrationException(message, debug_message=debug_message)

def _run_self_tests(self, _db: Session) -> Generator[SelfTestResult, None, None]:
def _run_self_tests(self, _db: Session) -> Generator[SelfTestResult]:
"""Verify the credentials of the test patron for this integration,
and update its metadata.
"""
Expand Down
2 changes: 1 addition & 1 deletion src/palace/manager/api/authentication/basic_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,5 @@ def identifies_individuals(cls):
def label(cls) -> str:
return "Library Barcode + Token"

def _run_self_tests(self, _db: Session) -> Generator[SelfTestResult, None, None]:
def _run_self_tests(self, _db: Session) -> Generator[SelfTestResult]:
raise NotImplementedError()
33 changes: 17 additions & 16 deletions src/palace/manager/api/authenticator.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ def profile_document(self):
adobe_drm = {}
adobe_drm["drm:vendor"] = vendor_id
adobe_drm["drm:clientToken"] = token
adobe_drm[
"drm:scheme"
] = "http://librarysimplified.org/terms/drm/scheme/ACS"
adobe_drm["drm:scheme"] = (
"http://librarysimplified.org/terms/drm/scheme/ACS"
)
drm.append(adobe_drm)

annotations_link = dict(
Expand Down Expand Up @@ -143,9 +143,9 @@ def populate_authenticators(
f"Library {library.name} ({library.id}) has no short name."
)
continue
self.library_authenticators[
library.short_name
] = LibraryAuthenticator.from_config(_db, library, analytics)
self.library_authenticators[library.short_name] = (
LibraryAuthenticator.from_config(_db, library, analytics)
)

def invoke_authenticator_method(self, method_name, *args, **kwargs):
short_name = self.current_library_short_name
Expand Down Expand Up @@ -197,11 +197,11 @@ def from_config(

# Find all of this library's integrations with
# the goal of authenticating patrons.
integrations: list[
IntegrationLibraryConfiguration
] = IntegrationLibraryConfiguration.for_library_and_goal(
_db, library, Goals.PATRON_AUTH_GOAL
).all()
integrations: list[IntegrationLibraryConfiguration] = (
IntegrationLibraryConfiguration.for_library_and_goal(
_db, library, Goals.PATRON_AUTH_GOAL
).all()
)

# Turn each such integration into an AuthenticationProvider.
for integration in integrations:
Expand All @@ -227,8 +227,9 @@ def __init__(
basic_auth_provider: BasicAuthenticationProvider | None = None,
saml_providers: list[BaseSAMLAuthenticationProvider] | None = None,
bearer_token_signing_secret: str | None = None,
integration_registry: None
| (IntegrationRegistry[AuthenticationProvider]) = None,
integration_registry: None | (
IntegrationRegistry[AuthenticationProvider]
) = None,
):
"""Initialize a LibraryAuthenticator from a list of AuthenticationProviders.
Expand Down Expand Up @@ -269,9 +270,9 @@ def __init__(
] = {}

self.basic_auth_provider: BasicAuthenticationProvider | None = None
self.access_token_authentication_provider: BasicTokenAuthenticationProvider | None = (
None
)
self.access_token_authentication_provider: (
BasicTokenAuthenticationProvider | None
) = None
if basic_auth_provider:
self.register_basic_auth_provider(basic_auth_provider)

Expand Down
17 changes: 9 additions & 8 deletions src/palace/manager/api/axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def authorization_headers(self) -> dict[str, str]:
)
return dict(Authorization="Basic " + authorization_b64)

def _run_self_tests(self, _db: Session) -> Generator[SelfTestResult, None, None]:
def _run_self_tests(self, _db: Session) -> Generator[SelfTestResult]:
result = self.run_test("Refreshing bearer token", self.refresh_bearer_token)
yield result
if not result.success:
Expand Down Expand Up @@ -648,7 +648,7 @@ def update_book(

def _fetch_remote_availability(
self, identifiers: list[Identifier]
) -> Generator[tuple[Metadata, CirculationData], None, None]:
) -> Generator[tuple[Metadata, CirculationData]]:
"""Retrieve availability information for the specified identifiers.
:yield: A stream of (Metadata, CirculationData) 2-tuples.
Expand Down Expand Up @@ -690,7 +690,7 @@ def _reap(self, identifier: Identifier) -> None:

def recent_activity(
self, since: datetime.datetime
) -> Generator[tuple[Metadata, CirculationData], None, None]:
) -> Generator[tuple[Metadata, CirculationData]]:
"""Find books that have had recent activity.
:yield: A sequence of (Metadata, CirculationData) 2-tuples
Expand Down Expand Up @@ -735,7 +735,6 @@ def _make_request(


class Axis360CirculationMonitor(CollectionMonitor, TimelineMonitor):

"""Maintain LicensePools for Axis 360 titles."""

SERVICE_NAME = "Axis 360 Circulation Monitor"
Expand Down Expand Up @@ -1390,8 +1389,9 @@ def _raise_exception_on_error(
cls,
code: str | int,
message: str,
custom_error_classes: None
| (Mapping[int | tuple[int, str], type[IntegrationException]]) = None,
custom_error_classes: None | (
Mapping[int | tuple[int, str], type[IntegrationException]]
) = None,
ignore_error_codes: list[int] | None = None,
) -> tuple[int, str]:
try:
Expand Down Expand Up @@ -1435,8 +1435,9 @@ def raise_exception_on_error(
self,
e: _Element,
ns: dict[str, str] | None,
custom_error_classes: None
| (Mapping[int | tuple[int, str], type[IntegrationException]]) = None,
custom_error_classes: None | (
Mapping[int | tuple[int, str], type[IntegrationException]]
) = None,
ignore_error_codes: list[int] | None = None,
) -> tuple[int, str]:
"""Raise an error if the given lxml node represents an Axis 360 error
Expand Down
Loading

0 comments on commit ebcddca

Please sign in to comment.