Skip to content

Commit

Permalink
quality: Fix lint with new ruff version
Browse files Browse the repository at this point in the history
  • Loading branch information
clemlesne committed Dec 4, 2024
1 parent 2824e85 commit 44a29e8
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/scrape_it_now/helpers/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from pathlib import Path

import click
from aiofiles import open
from aiofiles import open # noqa: A004
from aiofiles.os import makedirs, path, remove


Expand Down
2 changes: 1 addition & 1 deletion src/scrape_it_now/helpers/trie.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def add(self, word: str) -> None:
"""
ref = self.data
for char in word:
ref[char] = char in ref and ref[char] or {}
ref[char] = (char in ref and ref[char]) or {}
ref = ref[char]
ref[""] = 1

Expand Down
2 changes: 1 addition & 1 deletion src/scrape_it_now/persistence/local_disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from uuid import uuid4

import aiosqlite
from aiofiles import open
from aiofiles import open # noqa: A004
from aiofiles.os import makedirs, path, remove, rmdir
from pydantic import BaseModel, Field

Expand Down
10 changes: 6 additions & 4 deletions src/scrape_it_now/scrape.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
Error as PlaywrightError,
Locator,
Route,
TimeoutError,
TimeoutError as PlaywrightTimeoutError,
ViewportSize,
async_playwright,
)
Expand Down Expand Up @@ -879,7 +879,9 @@ def _network_used_callback(size_bytes: int) -> None:
)
# Wait for 5 secs, to make sure the page is fully loaded
await page.wait_for_timeout(5000)
except TimeoutError: # TODO: Retry maybe a few times for timeout errors?
except (
PlaywrightTimeoutError
): # TODO: Retry maybe a few times for timeout errors?
return _generic_error(
etag=previous_etag,
message="Timeout while loading",
Expand Down Expand Up @@ -1062,7 +1064,7 @@ async def _extract_link(selector: Locator) -> str | None:
timeout=BROWSER_TIMEOUT_MS,
)
except (
TimeoutError
PlaywrightTimeoutError
): # TODO: Is those timeouts normal? They happen quite often
logger.debug("Timeout for selecting href attribute", exc_info=True)
return
Expand Down Expand Up @@ -1106,7 +1108,7 @@ async def _extract_meta(
element.get_attribute("name"),
element.get_attribute("content"),
)
except TimeoutError:
except PlaywrightTimeoutError:
logger.debug("Timeout for selecting meta tag attributes", exc_info=True)
return
if not name:
Expand Down
2 changes: 1 addition & 1 deletion tests/scrape.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from zipfile import ZipFile

import pytest
from aiofiles import open
from aiofiles import open # noqa: A004
from aiofiles.os import remove, rmdir
from isodate import UTC
from playwright.async_api import Browser, ViewportSize
Expand Down

0 comments on commit 44a29e8

Please sign in to comment.