Skip to content

Commit

Permalink
Merge pull request #10187 from internetarchive/RayBB-patch-4
Browse files Browse the repository at this point in the history
update ruff and mypy precommit hook versions
  • Loading branch information
cdrini authored Dec 23, 2024
2 parents 57104a8 + 2cf396f commit 302c66b
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 29 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]
Expand All @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions openlibrary/accounts/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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(
Expand Down
33 changes: 16 additions & 17 deletions openlibrary/core/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
4 changes: 2 additions & 2 deletions openlibrary/core/lists/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down Expand Up @@ -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")}
Expand Down
5 changes: 2 additions & 3 deletions openlibrary/data/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]

Expand Down
4 changes: 2 additions & 2 deletions openlibrary/solr/types_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 302c66b

Please sign in to comment.