From b875574c5cbaad0b429bd6a278f1fa99d2a988d0 Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Wed, 25 Jan 2023 19:56:04 +0100 Subject: bump minimum Python version up to 3.9 3.7 will reach EOL in June of 2023, so it doesn't really make too much sense to forcefully stick with it for much longer - especially since upgrading gives us a few nice things (walrus, type subscription on builtins). 3.9 is shipped by Debian 11 (stable), so everything should be good. --- fietsboek/__init__.py | 4 ++-- fietsboek/updater/__init__.py | 6 ++---- fietsboek/util.py | 6 ++---- pyproject.toml | 6 +----- 4 files changed, 7 insertions(+), 15 deletions(-) diff --git a/fietsboek/__init__.py b/fietsboek/__init__.py index 10ba164..9112576 100644 --- a/fietsboek/__init__.py +++ b/fietsboek/__init__.py @@ -13,10 +13,10 @@ For more information, you can check out the following resources: Content ------- """ +import importlib.metadata from pathlib import Path from typing import Callable, Optional -import importlib_metadata import redis from pyramid.config import Configurator from pyramid.csrf import CookieCSRFStoragePolicy @@ -33,7 +33,7 @@ from .data import DataManager from .pages import Pages from .security import SecurityPolicy -__VERSION__ = importlib_metadata.version("fietsboek") +__VERSION__ = importlib.metadata.version("fietsboek") def locale_negotiator(request: Request) -> Optional[str]: diff --git a/fietsboek/updater/__init__.py b/fietsboek/updater/__init__.py index a62b395..9e2e7f0 100644 --- a/fietsboek/updater/__init__.py +++ b/fietsboek/updater/__init__.py @@ -1,5 +1,6 @@ """Updating (data migration) logic for fietsboek.""" import datetime +import importlib.resources import importlib.util import logging import random @@ -10,9 +11,6 @@ from typing import List import alembic.command import alembic.config import alembic.runtime - -# Compat for Python < 3.9 -import importlib_resources import jinja2 import pyramid.paster import sqlalchemy @@ -385,7 +383,7 @@ def _filename_to_modname(name): def _load_update_scripts(): """Loads all available import scripts.""" - files = importlib_resources.files(__name__) / "scripts" + files = importlib.resources.files(__name__) / "scripts" return [ UpdateScript(file.read_text(encoding="utf-8"), _filename_to_modname(file.name)) for file in files.iterdir() diff --git a/fietsboek/util.py b/fietsboek/util.py index 96ba660..c741550 100644 --- a/fietsboek/util.py +++ b/fietsboek/util.py @@ -1,5 +1,6 @@ """Various utility functions.""" import datetime +import importlib.resources import os import re import secrets @@ -9,9 +10,6 @@ from typing import List, Optional, Union import babel import bleach import gpxpy - -# Compat for Python < 3.9 -import importlib_resources import markdown import sqlalchemy import webob @@ -311,7 +309,7 @@ def read_localized_resource( for locale in locales: for package in locale_packages: - locale_dir = importlib_resources.files(package) / "locale" / locale + locale_dir = importlib.resources.files(package) / "locale" / locale resource_path = locale_dir / path try: return resource_path.read_text(encoding="utf-8") diff --git a/pyproject.toml b/pyproject.toml index 41236f3..e6dcf34 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,7 +25,7 @@ repository = "https://gitlab.com/dunj3/fietsboek" keywords = ["web", "gpx"] [tool.poetry.dependencies] -python = "^3.7.2" +python = "^3.9" pyramid = "^2" pyramid_jinja2 = "^2.10" @@ -40,10 +40,6 @@ transaction = "^3" "zope.sqlalchemy" = "^1.6" redis = "^4.3.4" -# Compatibility with old Python versions -importlib_resources = "^5.10" -importlib_metadata = "^6.0.0" - Babel = "^2.11" cryptography = "^39" gpxpy = "^1.5" -- cgit v1.2.3