diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index d967cd5..bdcabf2 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,12 +1,20 @@ -name: Test +name: Lint -on: [push, pull_request] +on: + push: + branches: + - master + - develop + pull_request: + branches: + - master + - develop permissions: contents: read jobs: - test: + lint: runs-on: ubuntu-latest steps: @@ -22,7 +30,7 @@ jobs: run: poetry install --no-interaction --no-root - name: Install Project run: poetry install --no-interaction - - name: Poetry Build + - name: Ruff Lint Format run: poetry run ruff format --check id: format - name: Ruff Lint Check diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e03be65..a716e87 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,6 +1,14 @@ name: Test -on: [push, pull_request] +on: + push: + branches: + - master + - develop + pull_request: + branches: + - master + - develop permissions: contents: read @@ -10,6 +18,7 @@ jobs: runs-on: ubuntu-latest strategy: + fail-fast: false matrix: python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 72c661c..d29890d 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -13,6 +13,8 @@ build: # nodejs: "20" # rust: "1.70" # golang: "1.20" + apt_packages: + - graphviz jobs: post_create_environment: # Install poetry diff --git a/tests/tree/test_save.py b/tests/tree/test_save.py index 1d78ae0..9716358 100644 --- a/tests/tree/test_save.py +++ b/tests/tree/test_save.py @@ -57,6 +57,7 @@ def test_page_to_dict(self, tree, tmp_path): 2009, 12, 17, 12, 4, 56, tzinfo=tzoffset(None, 7200) ), "change_frequency": "monthly", + "images": None, "news_story": None, }, { @@ -66,6 +67,7 @@ def test_page_to_dict(self, tree, tmp_path): 2009, 12, 17, 12, 4, 56, tzinfo=tzoffset(None, 7200) ), "change_frequency": "always", + "images": None, "news_story": None, }, { @@ -73,6 +75,7 @@ def test_page_to_dict(self, tree, tmp_path): "priority": Decimal("0.5"), "last_modified": None, "change_frequency": None, + "images": None, "news_story": { "title": "Foo ", "publish_date": datetime.datetime( @@ -91,6 +94,7 @@ def test_page_to_dict(self, tree, tmp_path): "priority": Decimal("0.5"), "last_modified": None, "change_frequency": None, + "images": None, "news_story": { "title": "Bar & bar", "publish_date": datetime.datetime( @@ -109,6 +113,7 @@ def test_page_to_dict(self, tree, tmp_path): "priority": Decimal("0.5"), "last_modified": None, "change_frequency": None, + "images": None, "news_story": { "title": "Bar & bar", "publish_date": datetime.datetime( @@ -127,6 +132,7 @@ def test_page_to_dict(self, tree, tmp_path): "priority": Decimal("0.5"), "last_modified": None, "change_frequency": None, + "images": None, "news_story": { "title": "Bąž", "publish_date": datetime.datetime( diff --git a/usp/fetch_parse.py b/usp/fetch_parse.py index ae995e4..e960d0e 100644 --- a/usp/fetch_parse.py +++ b/usp/fetch_parse.py @@ -608,6 +608,7 @@ class PagesXMLSitemapParser(AbstractXMLSitemapParser): class Image: """Data class for holding image data while parsing.""" + __slots__ = ["loc", "caption", "geo_location", "title", "license"] def __init__(self): diff --git a/usp/objects/sitemap.py b/usp/objects/sitemap.py index 9cdad94..38933b9 100644 --- a/usp/objects/sitemap.py +++ b/usp/objects/sitemap.py @@ -9,16 +9,17 @@ """ import abc -from functools import cache +from functools import lru_cache import os import pickle import tempfile -from typing import List, Iterator +from typing import List, Iterator, Tuple from .page import SitemapPage -@cache +# TODO: change to functools.cache when dropping py3.8 +@lru_cache(maxsize=None) def _all_slots(target_cls): mro = target_cls.__mro__ @@ -248,7 +249,7 @@ def __eq__(self, other) -> bool: def __repr__(self): return f"{self.__class__.__name__}(url={self.url}, pages={self.pages})" - def __getstate__(self) -> tuple[None, dict]: + def __getstate__(self) -> Tuple[None, dict]: # Load slots of this class and its parents (mangling if appropriate) obj_slots = {slot: getattr(self, slot) for slot in _all_slots(self.__class__)} # Replace temp file path with actual content diff --git a/usp/web_client/requests_client.py b/usp/web_client/requests_client.py index c27f58d..0719afb 100644 --- a/usp/web_client/requests_client.py +++ b/usp/web_client/requests_client.py @@ -43,7 +43,7 @@ def status_code(self) -> int: def status_message(self) -> str: message = self.__requests_response.reason if not message: - message = HTTPStatus(self.status_code(), None).phrase + message = HTTPStatus(self.status_code()).phrase return message def header(self, case_insensitive_name: str) -> Optional[str]: