Skip to content
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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.20
rev: v0.16.1
hooks:
- id: ruff-check
types_or: [python, pyproject]
Expand Down
10 changes: 8 additions & 2 deletions _scripts/sync-releases.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ class Docs:
)


class SyncReleasesException(Exception):
pass


def api_request(endpoint: str) -> Any:
resp = requests.get(
f'https://api.github.com/{endpoint}',
Expand Down Expand Up @@ -105,7 +109,7 @@ def main() -> None:
if version != prev['version']:
cur = prev.copy()
cur['version'] = version
cur['date'] = date.today().strftime('%Y-%m-%d')
cur['date'] = date.today().strftime('%Y-%m-%d') # noqa: DTZ011
releases[proj.id].insert(0, cur)

# sync docs
Expand All @@ -130,7 +134,9 @@ def main() -> None:
expected_hash = artifact['digest'].replace('sha256:', '')
found_hash = sha256(resp.content).hexdigest()
if expected_hash != found_hash:
raise Exception(f'SHA-256 {found_hash} != {expected_hash}')
raise SyncReleasesException(
f'SHA-256 {found_hash} != {expected_hash}'
)

# unpack
docdir = DOCROOT / proj.docs.subdir
Expand Down
14 changes: 10 additions & 4 deletions demo/_synctiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ class StatusMetadata(TypedDict):
stamp: str | None


class SyncTilesException(Exception):
pass


def slugify(text: str) -> str:
"""Generate an ASCII-only slug."""
text = normalize('NFKD', text.lower()).encode('ascii', 'ignore').decode()
Expand Down Expand Up @@ -450,7 +454,8 @@ def sync_slide(
# Get current metadata
try:
resp = storage.object(metadata_key_name).get()
metadata: SlideMetadata | None = json.load(gzip.open(resp['Body']))
with gzip.open(resp['Body']) as body:
metadata: SlideMetadata | None = json.load(body)
except storage.NoSuchKey:
metadata = None

Expand Down Expand Up @@ -675,7 +680,8 @@ def start_retile(
# If the stamp is changing, mark bucket dirty
try:
resp = storage.object(PurePath(METADATA_NAME)).get()
metadata: BucketMetadata = json.load(gzip.open(resp['Body']))
with gzip.open(resp['Body']) as body:
metadata: BucketMetadata = json.load(body)
old_stamp = metadata['stamp']
except storage.NoSuchKey:
old_stamp = None
Expand Down Expand Up @@ -709,7 +715,7 @@ def retile_slide(
# Tile slide
slide_info = context['slides'].get(slide_relpath.as_posix())
if slide_info is None:
raise Exception(f'No such slide {slide_relpath}')
raise SyncTilesException(f'No such slide {slide_relpath}')
metadata = sync_slide(
context['stamp'], storage, slide_relpath, slide_info, workers
)
Expand Down Expand Up @@ -845,4 +851,4 @@ def finish_retile(ctxfile: TextIO, summarydir: Path) -> None:
elif args.cmd == 'finish':
finish_retile(args.context_file, args.summary_dir)
else:
raise Exception('unimplemented subcommand')
raise SyncTilesException('unimplemented subcommand')