misc: Upgrade Python to v3.12 and Alpine to v3.20

Included upgrades:
* Python: v3.12
* Alpine: v3.20 (which uses Python 3.12)
* nginx: v1.27.1
This commit is contained in:
Michael Manganiello
2024-08-15 20:02:41 -03:00
parent ea8c3b622a
commit 0fdbbe4625
23 changed files with 30 additions and 68 deletions

View File

@@ -42,10 +42,10 @@ jobs:
run: |
pipx install poetry
- name: Set up Python 3.11
- name: Set up Python 3.12
uses: actions/setup-python@v4
with:
python-version: "3.11"
python-version: "3.12"
cache: "poetry"
- name: Install dependencies

View File

@@ -1 +1 @@
3.11
3.12

View File

@@ -14,7 +14,7 @@ runtimes:
enabled:
- go@1.21.0
- node@18.12.1
- python@3.11.6
- python@3.12.2
# This is the section where you manage your linters. (https://docs.trunk.io/check/configuration)
lint:
enabled:

View File

@@ -1,4 +1,4 @@
from typing_extensions import TypedDict
from typing import TypedDict
class MessageResponse(TypedDict):

View File

@@ -1,7 +1,7 @@
from datetime import datetime
from typing import TypedDict
from pydantic import BaseModel
from typing_extensions import TypedDict
class BaseAsset(BaseModel):

View File

@@ -1,4 +1,4 @@
from typing_extensions import TypedDict
from typing import TypedDict
class ConfigResponse(TypedDict):

View File

@@ -1,6 +1,4 @@
from typing import NotRequired
from typing_extensions import TypedDict
from typing import NotRequired, TypedDict
WEBRCADE_SUPPORTED_PLATFORM_SLUGS = frozenset(
(

View File

@@ -1,7 +1,7 @@
from datetime import datetime
from typing import TypedDict
from pydantic import BaseModel
from typing_extensions import TypedDict
class FirmwareSchema(BaseModel):

View File

@@ -1,4 +1,4 @@
from typing_extensions import TypedDict
from typing import TypedDict
class WatcherDict(TypedDict):

View File

@@ -1,6 +1,4 @@
from typing import NotRequired
from typing_extensions import TypedDict
from typing import NotRequired, TypedDict
class TokenResponse(TypedDict):

View File

@@ -2,7 +2,7 @@ from __future__ import annotations
import re
from datetime import datetime
from typing import NotRequired, get_type_hints
from typing import NotRequired, TypedDict, get_type_hints
from endpoints.responses.assets import SaveSchema, ScreenshotSchema, StateSchema
from endpoints.responses.collection import CollectionSchema
@@ -13,7 +13,6 @@ from handler.metadata.moby_handler import MobyMetadata
from handler.socket_handler import socket_handler
from models.rom import Rom, RomFile
from pydantic import BaseModel, Field, computed_field
from typing_extensions import TypedDict
SORT_COMPARE_REGEX = re.compile(r"^([Tt]he|[Aa]|[Aa]nd)\s")

View File

@@ -1,4 +1,4 @@
from typing_extensions import TypedDict
from typing import TypedDict
class StatsReturn(TypedDict):

View File

@@ -6,8 +6,9 @@ import re
import shutil
import tarfile
import zipfile
from collections.abc import Iterator
from pathlib import Path
from typing import Any, Final, Iterator, Tuple
from typing import Any, Final, TypedDict
import magic
import py7zr
@@ -15,7 +16,6 @@ from config import LIBRARY_BASE_PATH
from config.config_manager import config_manager as cm
from exceptions.fs_exceptions import RomAlreadyExistsException, RomsNotFoundException
from models.rom import RomFile
from typing_extensions import TypedDict
from utils.filesystem import iter_directories, iter_files
from .base_handler import (
@@ -189,7 +189,7 @@ class FSRomsHandler(FSHandler):
def _calculate_rom_hashes(
self, file_path: Path, crc_c: int, md5_h: Any, sha1_h: Any
) -> Tuple[int, Any, Any]:
) -> tuple[int, Any, Any]:
mime = magic.Magic(mime=True)
file_type = mime.from_file(file_path)
extension = Path(file_path).suffix.lower()

View File

@@ -2,6 +2,7 @@ import json
import os
import re
import unicodedata
from itertools import batched
from typing import Final
from handler.redis_handler import async_cache, sync_cache
@@ -11,7 +12,6 @@ from tasks.update_switch_titledb import (
SWITCH_TITLEDB_INDEX_KEY,
update_switch_titledb_task,
)
from utils.iterators import batched
def conditionally_set_cache(

View File

@@ -1,7 +1,7 @@
import functools
import re
import time
from typing import Final, NotRequired
from typing import Final, NotRequired, TypedDict
import httpx
import pydash
@@ -9,7 +9,6 @@ from config import IGDB_CLIENT_ID, IGDB_CLIENT_SECRET, IS_PYTEST_RUN
from fastapi import HTTPException, status
from handler.redis_handler import sync_cache
from logger.logger import log
from typing_extensions import TypedDict
from unidecode import unidecode as uc
from utils.context import ctx_httpx_client

View File

@@ -1,7 +1,7 @@
import asyncio
import http
import re
from typing import Final, NotRequired
from typing import Final, NotRequired, TypedDict
from urllib.parse import quote
import httpx
@@ -10,7 +10,6 @@ import yarl
from config import MOBYGAMES_API_KEY
from fastapi import HTTPException, status
from logger.logger import log
from typing_extensions import TypedDict
from unidecode import unidecode as uc
from utils.context import ctx_httpx_client

View File

@@ -1,7 +1,7 @@
from __future__ import annotations
from functools import cached_property
from typing import TYPE_CHECKING, Any
from typing import TYPE_CHECKING, Any, TypedDict
from config import FRONTEND_RESOURCES_PATH
from models.base import BaseModel
@@ -16,7 +16,6 @@ from sqlalchemy import (
)
from sqlalchemy.dialects.mysql.json import JSON as MySQLJSON
from sqlalchemy.orm import Mapped, mapped_column, relationship
from typing_extensions import TypedDict
if TYPE_CHECKING:
from models.assets import Save, Screenshot, State

View File

@@ -1,4 +1,5 @@
import json
from itertools import batched
from typing import Final
from config import (
@@ -9,7 +10,6 @@ from handler.redis_handler import async_cache
from logger.logger import log
from tasks.tasks import RemoteFilePullTask
from utils.context import initialize_context
from utils.iterators import batched
SWITCH_TITLEDB_INDEX_KEY: Final = "romm:switch_titledb"
SWITCH_PRODUCT_ID_KEY: Final = "romm:switch_product_id"

View File

@@ -1,17 +0,0 @@
import sys
if sys.version_info >= (3, 12):
from itertools import batched # noqa: F401
else:
from collections.abc import Iterable, Iterator
from itertools import islice
from typing import TypeVar
T = TypeVar("T")
def batched(iterable: Iterable[T], n: int) -> Iterator[tuple[T, ...]]:
if n < 1:
raise ValueError("n must be at least one")
iterator = iter(iterable)
while batch := tuple(islice(iterator, n)):
yield batch

View File

@@ -1,4 +1,5 @@
from typing import Any, Callable
from collections.abc import Callable
from typing import Any
from fastapi import APIRouter as FastAPIRouter
from fastapi.types import DecoratedCallable

View File

@@ -1,7 +1,7 @@
ARG ALPINE_VERSION=3.19
ARG NGINX_VERSION=1.27.0
ARG ALPINE_VERSION=3.20
ARG NGINX_VERSION=1.27.1
ARG NODE_VERSION=lts
ARG PYTHON_VERSION=3.11
ARG PYTHON_VERSION=3.12
# Build frontend
FROM node:${NODE_VERSION}-alpine${ALPINE_VERSION} AS front-build-stage

20
poetry.lock generated
View File

@@ -79,17 +79,6 @@ six = ">=1.12.0"
astroid = ["astroid (>=1,<2)", "astroid (>=2,<4)"]
test = ["astroid (>=1,<2)", "astroid (>=2,<4)", "pytest"]
[[package]]
name = "async-timeout"
version = "4.0.3"
description = "Timeout context manager for asyncio programs"
optional = false
python-versions = ">=3.7"
files = [
{file = "async-timeout-4.0.3.tar.gz", hash = "sha256:4640d96be84d82d02ed59ea2b7105a0f7b33abe8703703cd0ab0bf87c427522f"},
{file = "async_timeout-4.0.3-py3-none-any.whl", hash = "sha256:7405140ff1230c310e51dc27b3145b9092d659ce68ff733fb0cefe3ee42be028"},
]
[[package]]
name = "bcrypt"
version = "4.1.3"
@@ -884,7 +873,6 @@ prompt-toolkit = ">=3.0.41,<3.1.0"
pygments = ">=2.4.0"
stack-data = "*"
traitlets = ">=5.13.0"
typing-extensions = {version = ">=4.6", markers = "python_version < \"3.12\""}
[package.extras]
all = ["ipython[black,doc,kernel,matplotlib,nbconvert,nbformat,notebook,parallel,qtconsole]", "ipython[test,test-extra]"]
@@ -2201,6 +2189,7 @@ files = [
{file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"},
{file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"},
{file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"},
{file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef"},
{file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"},
{file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"},
{file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"},
@@ -2444,9 +2433,6 @@ files = [
{file = "redis-5.0.7.tar.gz", hash = "sha256:8f611490b93c8109b50adc317b31bfd84fff31def3475b92e7e80bf39f48175b"},
]
[package.dependencies]
async-timeout = {version = ">=4.0.3", markers = "python_full_version < \"3.11.3\""}
[package.extras]
hiredis = ["hiredis (>=1.0.0)"]
ocsp = ["cryptography (>=36.0.1)", "pyopenssl (==20.0.1)", "requests (>=2.26.0)"]
@@ -3238,5 +3224,5 @@ multidict = ">=4.0"
[metadata]
lock-version = "2.0"
python-versions = "^3.11"
content-hash = "1a225b47254091e5ab0e5b1b5b23773074c52c04a74e126f2aab12a890ca6082"
python-versions = "^3.12"
content-hash = "05c76acc85421bab1fc3f9f28f9291bce64c5e99154b8ee72dc809a26d9804e2"

View File

@@ -8,7 +8,7 @@ repository = "https://github.com/rommapp/romm"
authors = ["Zurdi <zurdi@romm.app>", "Arcane <arcane@romm.app>"]
[tool.poetry.dependencies]
python = "^3.11"
python = "^3.12"
anyio = "^4.4"
fastapi = "0.110.0"
uvicorn = "0.29.0"