Skip to content

Commit

Permalink
Packaging: drop python 3 8, add 3.13 support (#327)
Browse files Browse the repository at this point in the history
Since:

- Python 3.8 reached its end of life on 2024-10-07
- Python 3.13 has been released on 2024-10-07


See: https://devguide.python.org/versions/


Related to: #304 #286 #288
  • Loading branch information
Guts authored Oct 23, 2024
2 parents 6c9d981 + d8ceb47 commit 4179aaf
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 85 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint-and-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ repos:
hooks:
- id: pyupgrade
args:
- "--py38-plus"
- "--py39-plus"

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.6.9"
hooks:
- id: ruff
args:
- --fix-only
- --target-version=py38
- --target-version=py39

- repo: https://github.com/pycqa/isort
rev: 5.13.2
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions mkdocs_rss_plugin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = {}
Expand Down
56 changes: 0 additions & 56 deletions mkdocs_rss_plugin/timezoner_pre39.py

This file was deleted.

18 changes: 6 additions & 12 deletions mkdocs_rss_plugin/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 #############
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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"),
Expand All @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 10 additions & 6 deletions tests/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 4179aaf

Please sign in to comment.