diff --git a/.github/workflows/lint-and-tests.yml b/.github/workflows/lint-and-tests.yml index 2b3df85..6aae454 100644 --- a/.github/workflows/lint-and-tests.yml +++ b/.github/workflows/lint-and-tests.yml @@ -22,11 +22,11 @@ jobs: fail-fast: false matrix: python-version: - - "3.8" - "3.9" - "3.10" - "3.11" - "3.12" + - "3.13" # Steps represent a sequence of tasks that will be executed as part of the job steps: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index aada480..7a9fc1c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -35,7 +35,7 @@ repos: hooks: - id: pyupgrade args: - - "--py38-plus" + - "--py39-plus" - repo: https://github.com/astral-sh/ruff-pre-commit rev: "v0.6.9" @@ -43,7 +43,7 @@ repos: - id: ruff args: - --fix-only - - --target-version=py38 + - --target-version=py39 - repo: https://github.com/pycqa/isort rev: 5.13.2 @@ -59,7 +59,7 @@ repos: hooks: - id: black args: - - --target-version=py38 + - --target-version=py39 - repo: https://github.com/pycqa/flake8 rev: 7.1.1 diff --git a/mkdocs_rss_plugin/plugin.py b/mkdocs_rss_plugin/plugin.py index 703c6c1..a9e7beb 100644 --- a/mkdocs_rss_plugin/plugin.py +++ b/mkdocs_rss_plugin/plugin.py @@ -11,7 +11,7 @@ from email.utils import formatdate from pathlib import Path from re import compile as re_compile -from typing import List, Literal, Optional +from typing import Literal, Optional # 3rd party from jinja2 import Environment, FileSystemLoader, select_autoescape @@ -79,7 +79,7 @@ def on_startup( # flag used command to disable some actions if serve is used self.cmd_is_serve = command == "serve" - self.pages_to_filter: List[PageInformation] = [] + self.pages_to_filter: list[PageInformation] = [] # prepare output feeds self.feed_created: dict = {} self.feed_updated: dict = {} diff --git a/mkdocs_rss_plugin/timezoner_pre39.py b/mkdocs_rss_plugin/timezoner_pre39.py deleted file mode 100644 index 36e309d..0000000 --- a/mkdocs_rss_plugin/timezoner_pre39.py +++ /dev/null @@ -1,56 +0,0 @@ -#! python3 # noqa: E265 - - -""" -Manage timezones for pages date(time)s using pytz module. -Meant to be dropped when Python 3.8 reaches EOL. -""" - -# ############################################################################ -# ########## Libraries ############# -# ################################## - -# standard library -from datetime import datetime - -# 3rd party -import pytz -from mkdocs.plugins import get_plugin_logger - -# package -from mkdocs_rss_plugin.constants import MKDOCS_LOGGER_NAME - -# ############################################################################ -# ########## Globals ############# -# ################################ - - -logger = get_plugin_logger(MKDOCS_LOGGER_NAME) - - -# ############################################################################ -# ########## Functions ########### -# ################################ - - -def set_datetime_zoneinfo( - input_datetime: datetime, config_timezone: str = "UTC" -) -> datetime: - """Apply timezone to a naive datetime. - - :param input_datetime: offset-naive datetime - :type input_datetime: datetime - :param config_timezone: name of timezone as registered in IANA database, - defaults to "UTC". Example : Europe/Paris. - :type config_timezone: str, optional - - :return: offset-aware datetime - :rtype: datetime - """ - if input_datetime.tzinfo: - return input_datetime - elif not config_timezone: - return input_datetime.replace(tzinfo=pytz.utc) - else: - config_tz = pytz.timezone(config_timezone) - return config_tz.localize(input_datetime) diff --git a/mkdocs_rss_plugin/util.py b/mkdocs_rss_plugin/util.py index df00c72..1c14ab3 100644 --- a/mkdocs_rss_plugin/util.py +++ b/mkdocs_rss_plugin/util.py @@ -6,14 +6,13 @@ # standard library import logging -import sys from collections.abc import Iterable from datetime import date, datetime from email.utils import format_datetime from functools import lru_cache from mimetypes import guess_type from pathlib import Path -from typing import Any, List, Tuple, Union +from typing import Any, Union from urllib.parse import urlencode, urlparse, urlunparse # 3rd party @@ -46,12 +45,7 @@ IntegrationMaterialSocialCards, ) from mkdocs_rss_plugin.models import PageInformation - -# conditional imports -if sys.version_info < (3, 9): - from mkdocs_rss_plugin.timezoner_pre39 import set_datetime_zoneinfo -else: - from mkdocs_rss_plugin.timezoner import set_datetime_zoneinfo +from mkdocs_rss_plugin.timezoner import set_datetime_zoneinfo # ############################################################################ # ########## Globals ############# @@ -202,7 +196,7 @@ def get_file_dates( meta_datetime_format: str, meta_default_time: datetime, meta_default_timezone: str, - ) -> Tuple[datetime, datetime]: + ) -> tuple[datetime, datetime]: """Extract creation and update dates from page metadata (yaml frontmatter) or git log for given file. @@ -358,7 +352,7 @@ def get_file_dates( get_build_datetime(), ) - def get_authors_from_meta(self, in_page: Page) -> Optional[Tuple[str]]: + def get_authors_from_meta(self, in_page: Page) -> Optional[tuple[str]]: """Returns authors from page meta. It handles 'author' and 'authors' for keys, \ str and iterable as values types. @@ -542,7 +536,7 @@ def get_description_or_abstract( ) return "" - def get_image(self, in_page: Page, base_url: str) -> Optional[Tuple[str, str, int]]: + def get_image(self, in_page: Page, base_url: str) -> Optional[tuple[str, str, int]]: """Get page's image from page meta or social cards and returns properties. Args: @@ -782,7 +776,7 @@ def guess_locale(self, mkdocs_config: MkDocsConfig) -> Optional[str]: return None @staticmethod - def filter_pages(pages: List[PageInformation], attribute: str, length: int) -> list: + def filter_pages(pages: list[PageInformation], attribute: str, length: int) -> list: """Filter and return pages into a friendly RSS structure. Args: diff --git a/setup.py b/setup.py index 76b4b2a..87ff97d 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ # standard library from pathlib import Path -from typing import List, Union +from typing import Union # 3rd party from setuptools import find_packages, setup @@ -26,7 +26,7 @@ # ################################## -def load_requirements(requirements_files: Union[Path, List[Path]]) -> list: +def load_requirements(requirements_files: Union[Path, list[Path]]) -> list: """Helper to load requirements list from a path or a list of paths. Args: @@ -79,7 +79,7 @@ def load_requirements(requirements_files: Union[Path, List[Path]]) -> list: # run entry_points={"mkdocs.plugins": ["rss = mkdocs_rss_plugin.plugin:GitRssPlugin"]}, # dependencies - python_requires=">=3.8, <4", + python_requires=">=3.9, <4", extras_require={ # tooling "dev": load_requirements(HERE / "requirements/development.txt"), @@ -93,11 +93,11 @@ def load_requirements(requirements_files: Union[Path, List[Path]]) -> list: "Intended Audience :: Developers", "Intended Audience :: Information Technology", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Programming Language :: Python :: Implementation :: CPython", "Development Status :: 5 - Production/Stable", "License :: OSI Approved :: MIT License", diff --git a/sonar-project.properties b/sonar-project.properties index dd18175..9b18975 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -6,7 +6,7 @@ sonar.projectKey=Guts_mkdocs-rss-plugin # only=main # Python versions -sonar.python.version=3.8, 3.9, 3.10, 3.11, 3.12 +sonar.python.version=3.9, 3.10, 3.11, 3.12, 3.13 # Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. sonar.sources=mkdocs_rss_plugin diff --git a/tests/test_build.py b/tests/test_build.py index 78ac477..a312fbf 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -755,16 +755,20 @@ def test_json_feed_validation(self): self.assertIsNone(cli_result.exception) # created items - with Path(tmpdirname).joinpath(OUTPUT_JSON_FEED_CREATED).open( - "r", encoding="UTF-8" - ) as in_json: + with ( + Path(tmpdirname) + .joinpath(OUTPUT_JSON_FEED_CREATED) + .open("r", encoding="UTF-8") as in_json + ): json_feed_created_data = json.load(in_json) jsonfeed.Feed.parse(json_feed_created_data) # updated items - with Path(tmpdirname).joinpath(OUTPUT_JSON_FEED_UPDATED).open( - "r", encoding="UTF-8" - ) as in_json: + with ( + Path(tmpdirname) + .joinpath(OUTPUT_JSON_FEED_UPDATED) + .open("r", encoding="UTF-8") as in_json + ): json_feed_updated_data = json.load(in_json) jsonfeed.Feed.parse(json_feed_updated_data)