diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a23447edb32..57cd90cbc2a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -32,7 +32,7 @@ repos: - id: auto-walrus - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.6.7 + rev: v0.8.4 hooks: - id: ruff args: [ --fix ] @@ -56,7 +56,7 @@ repos: - id: cython-lint - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.11.2 + rev: v1.14.0 hooks: - id: mypy # See pyproject.toml for args additional_dependencies: diff --git a/openlibrary/accounts/model.py b/openlibrary/accounts/model.py index 31f1a14ddf7..0318b46d810 100644 --- a/openlibrary/accounts/model.py +++ b/openlibrary/accounts/model.py @@ -161,7 +161,7 @@ def username(self): def get_edit_count(self): user = self.get_user() - return user and user.get_edit_count() or 0 + return (user and user.get_edit_count()) or 0 @property def registered_on(self): @@ -622,8 +622,8 @@ def authenticate(cls, email, password, test=False): class InternetArchiveAccount(web.storage): def __init__(self, **kwargs): - for k in kwargs: - setattr(self, k, kwargs[k]) + for k, v in kwargs.items(): + setattr(self, k, v) @classmethod def create( diff --git a/openlibrary/core/helpers.py b/openlibrary/core/helpers.py index 3d9709ca5a8..8bd1ad1da32 100644 --- a/openlibrary/core/helpers.py +++ b/openlibrary/core/helpers.py @@ -36,28 +36,27 @@ # Helper functions that are added to `__all__` are exposed for use in templates # in /openlibrary/plugins/upstream/utils.py setup() __all__ = [ - "sanitize", - "json_encode", - "safesort", - "days_since", + "affiliate_id", + "bookreader_host", + "commify", + "cond", "datestr", + "datetimestr_utc", + "days_since", + "extract_year", "format_date", + "json_encode", + "parse_datetime", # function imported from elsewhere + "percentage", + "private_collection_in", + "private_collections", + "safeint", # function imported from elsewhere + "safesort", + "sanitize", "sprintf", - "cond", - "commify", + "texsafe", "truncate", - "datetimestr_utc", "urlsafe", - "texsafe", - "percentage", - "affiliate_id", - "bookreader_host", - "private_collections", - "private_collection_in", - "extract_year", - # functions imported from elsewhere - "parse_datetime", - "safeint", ] __docformat__ = "restructuredtext en" diff --git a/openlibrary/core/lists/model.py b/openlibrary/core/lists/model.py index 6043a0921c1..1946338466e 100644 --- a/openlibrary/core/lists/model.py +++ b/openlibrary/core/lists/model.py @@ -161,7 +161,7 @@ def preview(self): "full_url": self.url(), "name": self.name or "", "seed_count": self.seed_count, - "last_update": self.last_update and self.last_update.isoformat() or None, + "last_update": (self.last_update and self.last_update.isoformat()) or None, } def get_work_keys(self) -> Iterable[ThingKey]: @@ -585,7 +585,7 @@ def dict(self): "full_url": full_url, "type": self.type, "title": self.title, - "last_update": self.last_update and self.last_update.isoformat() or None, + "last_update": (self.last_update and self.last_update.isoformat()) or None, } if cover := self.get_cover(): d['picture'] = {"url": cover.url("S")} diff --git a/openlibrary/data/db.py b/openlibrary/data/db.py index db3db45f36d..0295b8a1c53 100644 --- a/openlibrary/data/db.py +++ b/openlibrary/data/db.py @@ -30,11 +30,10 @@ from openlibrary.utils import olmemcache __all__ = [ + "iterdocs", + "longquery", "setup_database", "setup_memcache", - "longquery", - "iterdocs", - # "get_docs", # "get_docs()" is not defined. "update_docs", ] diff --git a/openlibrary/solr/types_generator.py b/openlibrary/solr/types_generator.py index 9c46445d31c..a731daa4595 100755 --- a/openlibrary/solr/types_generator.py +++ b/openlibrary/solr/types_generator.py @@ -75,9 +75,9 @@ def generate(): seen_names.add(name) python_fields.append(f" {name}: {python_type}") - for key in OVERRIDES: + for key, value in OVERRIDES.items(): if key not in seen_names: - python_fields.append(f" {key}: {OVERRIDES[key]}") + python_fields.append(f" {key}: {value}") body = '\n'.join(python_fields) python = f"""# This file is auto-generated by types_generator.py