diff options
| author | Dennis Fink | 2026-11-12 22:07:12 +0100 |
|---|---|---|
| committer | Dennis Fink | 2026-11-12 22:07:12 +0100 |
| commit | c7993952c585b66acad5275e39dbf91cf662b975 (patch) | |
| tree | 976b3746444b3bd0bbb269bef9197c8b6a2e1696 /webmentions_ssg/tasks/receiver.py | |
| parent | b930b4425b91aa42abcec6c3443685065a5ca242 (diff) | |
| download | webmentions-ssg-c7993952c585b66acad5275e39dbf91cf662b975.tar.gz webmentions-ssg-c7993952c585b66acad5275e39dbf91cf662b975.zip | |
chore(core): enable stricter Ruff lint rules
Expand Ruff checks for bugbear, complexity, pathlib, return statements,
simplifications, upgrades, and docstring style.
Apply the resulting behavior-neutral cleanup across application and test
code.
Diffstat (limited to 'webmentions_ssg/tasks/receiver.py')
| -rw-r--r-- | webmentions_ssg/tasks/receiver.py | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/webmentions_ssg/tasks/receiver.py b/webmentions_ssg/tasks/receiver.py index feb6823..ada89f8 100644 --- a/webmentions_ssg/tasks/receiver.py +++ b/webmentions_ssg/tasks/receiver.py @@ -42,8 +42,7 @@ RECOVERY_EXHAUSTED_REASON = "Verification recovery limit reached" def fetch_source(source_url: str) -> tuple[httpx.Response, bytes]: - """ - Fetch a webmention source document. + """Fetch a webmention source document. The request follows redirects while enforcing the configured timeout, redirect limit, and maximum response size. @@ -55,7 +54,6 @@ def fetch_source(source_url: str) -> tuple[httpx.Response, bytes]: :raises VerificationError: If the source returns another unsuccessful HTTP status or exceeds the configured maximum response size. """ - try: with ( build_client( @@ -89,8 +87,7 @@ def fetch_source(source_url: str) -> tuple[httpx.Response, bytes]: def source_mentions_target(source_url: str, target_url: str) -> bool: - """ - Fetch a source and check whether it mentions the target URL. + """Fetch a source and check whether it mentions the target URL. HTML and XHTML sources are inspected for supported URL attributes, while plain-text sources are searched for the exact target IRI. @@ -103,7 +100,6 @@ def source_mentions_target(source_url: str, target_url: str) -> bool: :raises SourceGoneError: If the source explicitly reports that it is gone. :raises TemporaryFetchError: If fetching the source fails temporarily. """ - response, body = fetch_source(source_url) media_type = ( @@ -129,8 +125,7 @@ def source_mentions_target(source_url: str, target_url: str) -> bool: @huey.task(retries=2, retry_delay=50) def verify_webmention(webmention_uuid: uuid.UUID) -> None: - """ - Verify a received webmention and persist the result. + """Verify a received webmention and persist the result. The transition into ``verifying`` is an atomic claim. Its ``updated_at`` timestamp acts as a lease version: if a reaper has reclaimed the row while @@ -230,8 +225,7 @@ def verify_webmention(webmention_uuid: uuid.UUID) -> None: def recover_stale_webmentions() -> int: - """ - Requeue verification attempts that were abandoned or lost from the queue. + """Requeue verification attempts that were abandoned or lost from the queue. Recover both stale ``verifying`` rows (workers that died) and stale ``received`` rows (tasks that were never enqueued or were lost). Conditional |
