From 1a430ad5d11ae4d5ae1f5638f80205f060e3c68a Mon Sep 17 00:00:00 2001 From: I-Al-Istannen Date: Mon, 14 Apr 2025 21:13:25 +0200 Subject: [PATCH] Update minimum Python version to 3.11 --- .github/workflows/build-and-release.yml | 2 +- CHANGELOG.md | 1 + PFERD/crawl/crawler.py | 4 +--- PFERD/logging.py | 9 ++++----- PFERD/report.py | 11 +---------- README.md | 2 +- flake.lock | 8 ++++---- flake.nix | 2 +- pyproject.toml | 2 +- 9 files changed, 15 insertions(+), 26 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 1f60c59..0117222 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -14,7 +14,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, windows-latest, macos-13, macos-latest] - python: ["3.9"] + python: ["3.11"] steps: - uses: actions/checkout@v4 diff --git a/CHANGELOG.md b/CHANGELOG.md index 0625a0e..7919c67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ ambiguous situations. ### Changed - Added prettier CSS to forum threads +- Increase minimum supported Python version to 3.11 ## Fixed - File links in report on Windows diff --git a/PFERD/crawl/crawler.py b/PFERD/crawl/crawler.py index 74616e0..7ef5fe4 100644 --- a/PFERD/crawl/crawler.py +++ b/PFERD/crawl/crawler.py @@ -149,9 +149,7 @@ class CrawlerSection(Section): return self.s.getboolean("skip", fallback=False) def output_dir(self, name: str) -> Path: - # TODO Use removeprefix() after switching to 3.9 - if name.startswith("crawl:"): - name = name[len("crawl:"):] + name = name.removeprefix("crawl:") return Path(self.s.get("output_dir", name)).expanduser() def redownload(self) -> Redownload: diff --git a/PFERD/logging.py b/PFERD/logging.py index b958fb2..c19e4a0 100644 --- a/PFERD/logging.py +++ b/PFERD/logging.py @@ -1,9 +1,8 @@ import asyncio import sys import traceback -from contextlib import asynccontextmanager, contextmanager -# TODO In Python 3.9 and above, ContextManager is deprecated -from typing import AsyncIterator, ContextManager, Iterator, List, Optional +from contextlib import AbstractContextManager, asynccontextmanager, contextmanager +from typing import AsyncIterator, Iterator, List, Optional from rich.console import Console, Group from rich.live import Live @@ -261,7 +260,7 @@ directly or as a GitHub issue: https://github.com/Garmelon/PFERD/issues/new action: str, text: str, total: Optional[float] = None, - ) -> ContextManager[ProgressBar]: + ) -> AbstractContextManager[ProgressBar]: """ Allows markup in the "style" argument which will be applied to the "action" string. @@ -277,7 +276,7 @@ directly or as a GitHub issue: https://github.com/Garmelon/PFERD/issues/new action: str, text: str, total: Optional[float] = None, - ) -> ContextManager[ProgressBar]: + ) -> AbstractContextManager[ProgressBar]: """ Allows markup in the "style" argument which will be applied to the "action" string. diff --git a/PFERD/report.py b/PFERD/report.py index 0eaaca9..72e2727 100644 --- a/PFERD/report.py +++ b/PFERD/report.py @@ -34,15 +34,6 @@ class MarkConflictError(Exception): self.collides_with = collides_with -# TODO Use PurePath.is_relative_to when updating to 3.9 -def is_relative_to(a: PurePath, b: PurePath) -> bool: - try: - a.relative_to(b) - return True - except ValueError: - return False - - class Report: """ A report of a synchronization. Includes all files found by the crawler, as @@ -173,7 +164,7 @@ class Report: if path == other: raise MarkDuplicateError(path) - if is_relative_to(path, other) or is_relative_to(other, path): + if path.is_relative_to(other) or other.is_relative_to(path): raise MarkConflictError(path, other) self.known_files.add(path) diff --git a/README.md b/README.md index d5d7980..c96fea0 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Binaries for Linux, Windows and Mac can be downloaded directly from the ### With pip -Ensure you have at least Python 3.9 installed. Run the following command to +Ensure you have at least Python 3.11 installed. Run the following command to install PFERD or upgrade it to the latest version: ``` diff --git a/flake.lock b/flake.lock index 6428667..d9326af 100644 --- a/flake.lock +++ b/flake.lock @@ -2,16 +2,16 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1708979614, - "narHash": "sha256-FWLWmYojIg6TeqxSnHkKpHu5SGnFP5um1uUjH+wRV6g=", + "lastModified": 1744440957, + "narHash": "sha256-FHlSkNqFmPxPJvy+6fNLaNeWnF1lZSgqVCl/eWaJRc4=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "b7ee09cf5614b02d289cd86fcfa6f24d4e078c2a", + "rev": "26d499fc9f1d567283d5d56fcf367edd815dba1d", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-23.11", + "ref": "nixos-24.11", "repo": "nixpkgs", "type": "github" } diff --git a/flake.nix b/flake.nix index 4fc47b2..c8dbe0c 100644 --- a/flake.nix +++ b/flake.nix @@ -2,7 +2,7 @@ description = "Tool for downloading course-related files from ILIAS"; inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11"; }; outputs = { self, nixpkgs }: diff --git a/pyproject.toml b/pyproject.toml index bc67e1c..e22fe85 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,7 @@ dependencies = [ "certifi>=2021.10.8" ] dynamic = ["version"] -requires-python = ">=3.9" +requires-python = ">=3.11" [project.scripts] pferd = "PFERD.__main__:main"