Skip to content

Commit

Permalink
Fixed linting issues for 'pre-commit run --all-files'
Browse files Browse the repository at this point in the history
  • Loading branch information
jompu committed Mar 14, 2024
1 parent 837ed3f commit 78531ef
Show file tree
Hide file tree
Showing 26 changed files with 168 additions and 170 deletions.
1 change: 0 additions & 1 deletion .tx/config
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,3 @@ type = PO
minimum_perc = 0
replace_edited_strings = false
keep_translations = false

7 changes: 4 additions & 3 deletions api/circulation_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
import flask
from dependency_injector.wiring import Provide, inject
from expiringdict import ExpiringDict
from flask_babel import lazy_gettext as _, gettext
from flask_babel import gettext
from flask_babel import lazy_gettext as _
from sqlalchemy import select

from api.authenticator import Authenticator
Expand Down Expand Up @@ -259,11 +260,11 @@ def get_domain(url):
self.setup_configuration_dependent_controllers()
# Finland: Disabled cache, because the E-kirjasto authentication provider
# will have links containing a query parameter for user's locale.
authentication_document_cache_time = 0#int(
authentication_document_cache_time = 0 # int(
# ConfigurationSetting.sitewide(
# self._db, Configuration.AUTHENTICATION_DOCUMENT_CACHE_TIME
# ).value_or_default(3600)
#)
# )
self.authentication_for_opds_documents = ExpiringDict(
max_len=1000, max_age_seconds=authentication_document_cache_time
)
Expand Down
2 changes: 1 addition & 1 deletion api/ekirjasto_authentication.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from __future__ import annotations

import datetime
import flask_babel
import uuid
from abc import ABC
from base64 import b64decode, b64encode
from enum import Enum
from typing import Any

import flask_babel
import jwt
import requests
from cryptography.fernet import Fernet, InvalidToken
Expand Down
1 change: 1 addition & 0 deletions api/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def print_cache(response):
log.debug(f"{cls}: {cache.stats.hits}/{cache.stats.misses} hits/misses")
return response


@app.after_request
def set_content_language_header(response):
response.headers["Content-Language"] = flask_babel.get_locale()
Expand Down
280 changes: 140 additions & 140 deletions core/classifier/localized_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,144 +4,144 @@
# This file was generated by the CollectTranslationsScript class.

genres = {
"Adventure": _("Adventure"),
"Classics": _("Classics"),
"Comics & Graphic Novels": _("Comics & Graphic Novels"),
"Drama": _("Drama"),
"Erotica": _("Erotica"),
"Fantasy": _("Fantasy"),
"Epic Fantasy": _("Epic Fantasy"),
"Historical Fantasy": _("Historical Fantasy"),
"Urban Fantasy": _("Urban Fantasy"),
"Folklore": _("Folklore"),
"Historical Fiction": _("Historical Fiction"),
"Horror": _("Horror"),
"Gothic Horror": _("Gothic Horror"),
"Ghost Stories": _("Ghost Stories"),
"Vampires": _("Vampires"),
"Werewolves": _("Werewolves"),
"Occult Horror": _("Occult Horror"),
"Humorous Fiction": _("Humorous Fiction"),
"Literary Fiction": _("Literary Fiction"),
"LGBTQ Fiction": _("LGBTQ Fiction"),
"Mystery": _("Mystery"),
"Crime & Detective Stories": _("Crime & Detective Stories"),
"Hard-Boiled Mystery": _("Hard-Boiled Mystery"),
"Police Procedural": _("Police Procedural"),
"Cozy Mystery": _("Cozy Mystery"),
"Historical Mystery": _("Historical Mystery"),
"Paranormal Mystery": _("Paranormal Mystery"),
"Women Detectives": _("Women Detectives"),
"Poetry": _("Poetry"),
"Religious Fiction": _("Religious Fiction"),
"Romance": _("Romance"),
"Contemporary Romance": _("Contemporary Romance"),
"Gothic Romance": _("Gothic Romance"),
"Historical Romance": _("Historical Romance"),
"Paranormal Romance": _("Paranormal Romance"),
"Western Romance": _("Western Romance"),
"Romantic Suspense": _("Romantic Suspense"),
"Science Fiction": _("Science Fiction"),
"Dystopian SF": _("Dystopian SF"),
"Space Opera": _("Space Opera"),
"Cyberpunk": _("Cyberpunk"),
"Military SF": _("Military SF"),
"Alternative History": _("Alternative History"),
"Steampunk": _("Steampunk"),
"Romantic SF": _("Romantic SF"),
"Media Tie-in SF": _("Media Tie-in SF"),
"Short Stories": _("Short Stories"),
"Suspense/Thriller": _("Suspense/Thriller"),
"Historical Thriller": _("Historical Thriller"),
"Espionage": _("Espionage"),
"Supernatural Thriller": _("Supernatural Thriller"),
"Medical Thriller": _("Medical Thriller"),
"Political Thriller": _("Political Thriller"),
"Psychological Thriller": _("Psychological Thriller"),
"Technothriller": _("Technothriller"),
"Legal Thriller": _("Legal Thriller"),
"Military Thriller": _("Military Thriller"),
"Urban Fiction": _("Urban Fiction"),
"Westerns": _("Westerns"),
"Women's Fiction": _("Women's Fiction"),
"Art & Design": _("Art & Design"),
"Architecture": _("Architecture"),
"Art": _("Art"),
"Art Criticism & Theory": _("Art Criticism & Theory"),
"Art History": _("Art History"),
"Design": _("Design"),
"Fashion": _("Fashion"),
"Photography": _("Photography"),
"Biography & Memoir": _("Biography & Memoir"),
"Education": _("Education"),
"Personal Finance & Business": _("Personal Finance & Business"),
"Business": _("Business"),
"Economics": _("Economics"),
"Management & Leadership": _("Management & Leadership"),
"Personal Finance & Investing": _("Personal Finance & Investing"),
"Real Estate": _("Real Estate"),
"Parenting & Family": _("Parenting & Family"),
"Family & Relationships": _("Family & Relationships"),
"Parenting": _("Parenting"),
"Food & Health": _("Food & Health"),
"Bartending & Cocktails": _("Bartending & Cocktails"),
"Cooking": _("Cooking"),
"Health & Diet": _("Health & Diet"),
"Vegetarian & Vegan": _("Vegetarian & Vegan"),
"History": _("History"),
"African History": _("African History"),
"Ancient History": _("Ancient History"),
"Asian History": _("Asian History"),
"Civil War History": _("Civil War History"),
"European History": _("European History"),
"Latin American History": _("Latin American History"),
"Medieval History": _("Medieval History"),
"Middle East History": _("Middle East History"),
"Military History": _("Military History"),
"Modern History": _("Modern History"),
"Renaissance & Early Modern History": _("Renaissance & Early Modern History"),
"United States History": _("United States History"),
"World History": _("World History"),
"Hobbies & Home": _("Hobbies & Home"),
"Antiques & Collectibles": _("Antiques & Collectibles"),
"Crafts & Hobbies": _("Crafts & Hobbies"),
"Gardening": _("Gardening"),
"Games": _("Games"),
"House & Home": _("House & Home"),
"Pets": _("Pets"),
"Humorous Nonfiction": _("Humorous Nonfiction"),
"Entertainment": _("Entertainment"),
"Film & TV": _("Film & TV"),
"Music": _("Music"),
"Performing Arts": _("Performing Arts"),
"Life Strategies": _("Life Strategies"),
"Literary Criticism": _("Literary Criticism"),
"Periodicals": _("Periodicals"),
"Philosophy": _("Philosophy"),
"Political Science": _("Political Science"),
"Reference & Study Aids": _("Reference & Study Aids"),
"Dictionaries": _("Dictionaries"),
"Foreign Language Study": _("Foreign Language Study"),
"Law": _("Law"),
"Study Aids": _("Study Aids"),
"Religion & Spirituality": _("Religion & Spirituality"),
"Body, Mind & Spirit": _("Body, Mind & Spirit"),
"Buddhism": _("Buddhism"),
"Christianity": _("Christianity"),
"Hinduism": _("Hinduism"),
"Islam": _("Islam"),
"Judaism": _("Judaism"),
"Science & Technology": _("Science & Technology"),
"Computers": _("Computers"),
"Mathematics": _("Mathematics"),
"Medical": _("Medical"),
"Nature": _("Nature"),
"Psychology": _("Psychology"),
"Science": _("Science"),
"Social Sciences": _("Social Sciences"),
"Technology": _("Technology"),
"Self-Help": _("Self-Help"),
"Sports": _("Sports"),
"Travel": _("Travel"),
"True Crime": _("True Crime"),
"Adventure": _("Adventure"),
"Classics": _("Classics"),
"Comics & Graphic Novels": _("Comics & Graphic Novels"),
"Drama": _("Drama"),
"Erotica": _("Erotica"),
"Fantasy": _("Fantasy"),
"Epic Fantasy": _("Epic Fantasy"),
"Historical Fantasy": _("Historical Fantasy"),
"Urban Fantasy": _("Urban Fantasy"),
"Folklore": _("Folklore"),
"Historical Fiction": _("Historical Fiction"),
"Horror": _("Horror"),
"Gothic Horror": _("Gothic Horror"),
"Ghost Stories": _("Ghost Stories"),
"Vampires": _("Vampires"),
"Werewolves": _("Werewolves"),
"Occult Horror": _("Occult Horror"),
"Humorous Fiction": _("Humorous Fiction"),
"Literary Fiction": _("Literary Fiction"),
"LGBTQ Fiction": _("LGBTQ Fiction"),
"Mystery": _("Mystery"),
"Crime & Detective Stories": _("Crime & Detective Stories"),
"Hard-Boiled Mystery": _("Hard-Boiled Mystery"),
"Police Procedural": _("Police Procedural"),
"Cozy Mystery": _("Cozy Mystery"),
"Historical Mystery": _("Historical Mystery"),
"Paranormal Mystery": _("Paranormal Mystery"),
"Women Detectives": _("Women Detectives"),
"Poetry": _("Poetry"),
"Religious Fiction": _("Religious Fiction"),
"Romance": _("Romance"),
"Contemporary Romance": _("Contemporary Romance"),
"Gothic Romance": _("Gothic Romance"),
"Historical Romance": _("Historical Romance"),
"Paranormal Romance": _("Paranormal Romance"),
"Western Romance": _("Western Romance"),
"Romantic Suspense": _("Romantic Suspense"),
"Science Fiction": _("Science Fiction"),
"Dystopian SF": _("Dystopian SF"),
"Space Opera": _("Space Opera"),
"Cyberpunk": _("Cyberpunk"),
"Military SF": _("Military SF"),
"Alternative History": _("Alternative History"),
"Steampunk": _("Steampunk"),
"Romantic SF": _("Romantic SF"),
"Media Tie-in SF": _("Media Tie-in SF"),
"Short Stories": _("Short Stories"),
"Suspense/Thriller": _("Suspense/Thriller"),
"Historical Thriller": _("Historical Thriller"),
"Espionage": _("Espionage"),
"Supernatural Thriller": _("Supernatural Thriller"),
"Medical Thriller": _("Medical Thriller"),
"Political Thriller": _("Political Thriller"),
"Psychological Thriller": _("Psychological Thriller"),
"Technothriller": _("Technothriller"),
"Legal Thriller": _("Legal Thriller"),
"Military Thriller": _("Military Thriller"),
"Urban Fiction": _("Urban Fiction"),
"Westerns": _("Westerns"),
"Women's Fiction": _("Women's Fiction"),
"Art & Design": _("Art & Design"),
"Architecture": _("Architecture"),
"Art": _("Art"),
"Art Criticism & Theory": _("Art Criticism & Theory"),
"Art History": _("Art History"),
"Design": _("Design"),
"Fashion": _("Fashion"),
"Photography": _("Photography"),
"Biography & Memoir": _("Biography & Memoir"),
"Education": _("Education"),
"Personal Finance & Business": _("Personal Finance & Business"),
"Business": _("Business"),
"Economics": _("Economics"),
"Management & Leadership": _("Management & Leadership"),
"Personal Finance & Investing": _("Personal Finance & Investing"),
"Real Estate": _("Real Estate"),
"Parenting & Family": _("Parenting & Family"),
"Family & Relationships": _("Family & Relationships"),
"Parenting": _("Parenting"),
"Food & Health": _("Food & Health"),
"Bartending & Cocktails": _("Bartending & Cocktails"),
"Cooking": _("Cooking"),
"Health & Diet": _("Health & Diet"),
"Vegetarian & Vegan": _("Vegetarian & Vegan"),
"History": _("History"),
"African History": _("African History"),
"Ancient History": _("Ancient History"),
"Asian History": _("Asian History"),
"Civil War History": _("Civil War History"),
"European History": _("European History"),
"Latin American History": _("Latin American History"),
"Medieval History": _("Medieval History"),
"Middle East History": _("Middle East History"),
"Military History": _("Military History"),
"Modern History": _("Modern History"),
"Renaissance & Early Modern History": _("Renaissance & Early Modern History"),
"United States History": _("United States History"),
"World History": _("World History"),
"Hobbies & Home": _("Hobbies & Home"),
"Antiques & Collectibles": _("Antiques & Collectibles"),
"Crafts & Hobbies": _("Crafts & Hobbies"),
"Gardening": _("Gardening"),
"Games": _("Games"),
"House & Home": _("House & Home"),
"Pets": _("Pets"),
"Humorous Nonfiction": _("Humorous Nonfiction"),
"Entertainment": _("Entertainment"),
"Film & TV": _("Film & TV"),
"Music": _("Music"),
"Performing Arts": _("Performing Arts"),
"Life Strategies": _("Life Strategies"),
"Literary Criticism": _("Literary Criticism"),
"Periodicals": _("Periodicals"),
"Philosophy": _("Philosophy"),
"Political Science": _("Political Science"),
"Reference & Study Aids": _("Reference & Study Aids"),
"Dictionaries": _("Dictionaries"),
"Foreign Language Study": _("Foreign Language Study"),
"Law": _("Law"),
"Study Aids": _("Study Aids"),
"Religion & Spirituality": _("Religion & Spirituality"),
"Body, Mind & Spirit": _("Body, Mind & Spirit"),
"Buddhism": _("Buddhism"),
"Christianity": _("Christianity"),
"Hinduism": _("Hinduism"),
"Islam": _("Islam"),
"Judaism": _("Judaism"),
"Science & Technology": _("Science & Technology"),
"Computers": _("Computers"),
"Mathematics": _("Mathematics"),
"Medical": _("Medical"),
"Nature": _("Nature"),
"Psychology": _("Psychology"),
"Science": _("Science"),
"Social Sciences": _("Social Sciences"),
"Technology": _("Technology"),
"Self-Help": _("Self-Help"),
"Sports": _("Sports"),
"Travel": _("Travel"),
"True Crime": _("True Crime"),
}
2 changes: 1 addition & 1 deletion core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def quicksight_authorized_arns(cls) -> dict[str, list[str]]:

@classmethod
def localization_languages(cls):
return [LanguageCodes.three_to_two["eng"], 'fi', 'sv']
return [LanguageCodes.three_to_two["eng"], "fi", "sv"]

# The last time the database configuration is known to have changed.
SITE_CONFIGURATION_LAST_UPDATE = None
Expand Down
4 changes: 3 additions & 1 deletion core/configuration/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ class LibrarySettings(BaseSettings):
"audiobook vendors: Bibliotheca, Axis 360",
type=ConfigurationFormItemType.MENU,
options={
entrypoint.INTERNAL_NAME: str(EntryPoint.LOCALIZED_DISPLAY_TITLES[entrypoint])
entrypoint.INTERNAL_NAME: str(
EntryPoint.LOCALIZED_DISPLAY_TITLES[entrypoint]
)
for entrypoint in EntryPoint.ENTRY_POINTS
},
category="Lanes & Filters",
Expand Down
8 changes: 6 additions & 2 deletions core/entrypoint.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from __future__ import annotations

from flask_babel import lazy_gettext as _, LazyString
from flask_babel import LazyString
from flask_babel import lazy_gettext as _


class EntryPoint:

Expand Down Expand Up @@ -44,7 +46,9 @@ def register(cls, entrypoint_class, display_title, default_enabled=False):
enabled by default.
"""
value = getattr(entrypoint_class, "INTERNAL_NAME", None)
localized_display_title = getattr(entrypoint_class, "LOCALIZED_DISPLAY_TITLE", None)
localized_display_title = getattr(
entrypoint_class, "LOCALIZED_DISPLAY_TITLE", None
)
if not value:
raise ValueError(
"EntryPoint class %s must define INTERNAL_NAME."
Expand Down
1 change: 0 additions & 1 deletion core/feed/acquisition.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
from core.util.flask_util import OPDSEntryResponse, OPDSFeedResponse
from core.util.opds_writer import OPDSMessage
from core.util.problem_detail import ProblemDetail
from flask_babel import gettext

if TYPE_CHECKING:
from api.circulation import CirculationAPI, FulfillmentInfo
Expand Down
1 change: 1 addition & 0 deletions core/feed/annotator/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from core.model.work import Work
from core.util.opds_writer import AtomFeed, OPDSFeed


class ToFeedEntry:
@classmethod
def authors(cls, edition: Edition) -> dict[str, list[Author]]:
Expand Down
Loading

0 comments on commit 78531ef

Please sign in to comment.