misc: Upgrade to Python 3.13

Small changes to upgrade Python to version 3.13, and fixes based on a
`pyupgrade` run using the `--py313-plus` flag.
This commit is contained in:
Michael Manganiello
2025-07-03 22:58:54 -03:00
parent 21d4bc3fec
commit f96adeeaee
11 changed files with 19 additions and 24 deletions

View File

@@ -15,10 +15,10 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python 3.12
- name: Set up Python 3.13
uses: actions/setup-python@v5
with:
python-version: "3.12"
python-version: "3.13"
- name: Run localization check
run: python frontend/src/locales/check_i18n_locales.py

View File

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

View File

@@ -1 +1 @@
3.12
3.13

View File

@@ -7,14 +7,14 @@ cli:
plugins:
sources:
- id: trunk
ref: v1.7.0
ref: v1.7.1
uri: https://github.com/trunk-io/plugins
# Many linters and tools depend on runtimes - configure them here. (https://docs.trunk.io/runtimes)
runtimes:
enabled:
- go@1.21.0
- node@22.16.0
- python@3.12.2
- python@3.13.3
# This is the section where you manage your linters. (https://docs.trunk.io/check/configuration)
lint:
disabled:

View File

@@ -67,8 +67,8 @@ RUN npm install
# Set working directory
WORKDIR /app
# Install Python 3.12
RUN pyenv install 3.12 && pyenv global 3.12
# Install Python 3.13
RUN pyenv install 3.13 && pyenv global 3.13
# Install pipx and poetry for the non-root user
RUN pip3 install pipx poetry \

View File

@@ -54,7 +54,7 @@ logging.config.dictConfig(LOGGING_CONFIG)
@asynccontextmanager
async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]:
async def lifespan(app: FastAPI) -> AsyncGenerator[None]:
async with initialize_context():
app.state.aiohttp_session = ctx_aiohttp_session.get()
app.state.httpx_client = ctx_httpx_client.get()

View File

@@ -14,9 +14,7 @@ ctx_httpx_client: ContextVar[httpx.AsyncClient] = ContextVar("httpx_client")
@asynccontextmanager
async def set_context_var(
var: ContextVar[_T], value: _T
) -> AsyncGenerator[Token[_T], None]:
async def set_context_var(var: ContextVar[_T], value: _T) -> AsyncGenerator[Token[_T]]:
"""Temporarily set a context variables."""
token = var.set(value)
yield token
@@ -24,7 +22,7 @@ async def set_context_var(
@asynccontextmanager
async def initialize_context() -> AsyncGenerator[None, None]:
async def initialize_context() -> AsyncGenerator[None]:
"""Initialize context variables."""
async with (
aiohttp.ClientSession() as aiohttp_session,

View File

@@ -15,7 +15,7 @@
ARG ALPINE_VERSION=3.22
ARG NGINX_VERSION=1.29.0
ARG NODE_VERSION=20.19
ARG PYTHON_VERSION=3.12
ARG PYTHON_VERSION=3.13
FROM node:${NODE_VERSION}-alpine${ALPINE_VERSION} AS frontend-build

View File

@@ -39,10 +39,10 @@ for lang_dir in lang_dirs:
en_file_path = os.path.join(en_dir, filename)
lang_file_path = os.path.join(lang_dir, filename)
with open(en_file_path, "r", encoding="utf-8") as f:
with open(en_file_path, encoding="utf-8") as f:
en_data = json.load(f)
with open(lang_file_path, "r", encoding="utf-8") as f:
with open(lang_file_path, encoding="utf-8") as f:
lang_data = json.load(f)
missing_keys = []

9
poetry.lock generated
View File

@@ -182,7 +182,6 @@ files = [
[package.dependencies]
idna = ">=2.8"
sniffio = ">=1.1"
typing_extensions = {version = ">=4.5", markers = "python_version < \"3.13\""}
[package.extras]
doc = ["Sphinx (>=7.4,<8.0)", "packaging", "sphinx-autodoc-typehints (>=1.2.0)", "sphinx_rtd_theme"]
@@ -954,7 +953,7 @@ description = "Lightweight in-process concurrent programming"
optional = false
python-versions = ">=3.7"
groups = ["main"]
markers = "python_version < \"3.14\" and (platform_machine == \"aarch64\" or platform_machine == \"ppc64le\" or platform_machine == \"x86_64\" or platform_machine == \"amd64\" or platform_machine == \"AMD64\" or platform_machine == \"win32\" or platform_machine == \"WIN32\")"
markers = "python_version == \"3.13\" and (platform_machine == \"aarch64\" or platform_machine == \"ppc64le\" or platform_machine == \"x86_64\" or platform_machine == \"amd64\" or platform_machine == \"AMD64\" or platform_machine == \"win32\" or platform_machine == \"WIN32\")"
files = [
{file = "greenlet-3.1.1-cp310-cp310-macosx_11_0_universal2.whl", hash = "sha256:0bbae94a29c9e5c7e4a2b7f0aae5c17e8e90acbfd3bf6270eeba60c39fce3563"},
{file = "greenlet-3.1.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0fde093fb93f35ca72a556cf72c92ea3ebfda3d79fc35bb19fbe685853869a83"},
@@ -2287,7 +2286,6 @@ files = [
[package.dependencies]
psycopg-c = {version = "3.2.4", optional = true, markers = "implementation_name != \"pypy\" and extra == \"c\""}
typing-extensions = {version = ">=4.6", markers = "python_version < \"3.13\""}
tzdata = {version = "*", markers = "sys_platform == \"win32\""}
[package.extras]
@@ -3524,7 +3522,6 @@ files = [
packaging = ">=20.0"
python-dateutil = ">=2.0"
sqlalchemy = ">=1.3.11"
typing-extensions = {version = ">=4.7,<5", markers = "python_version < \"3.13\""}
[[package]]
name = "sqlalchemy"
@@ -4454,5 +4451,5 @@ test = ["fakeredis", "pytest", "pytest-asyncio", "pytest-env", "pytest-mock", "p
[metadata]
lock-version = "2.1"
python-versions = "^3.12"
content-hash = "94c9ec6caf38454d244fccefa6ff4222745d4adf727e11b240dc839385f94986"
python-versions = "^3.13"
content-hash = "04d856c636fd06d52c2704d9b2d649442c6a61e3e0efde0c365e0be631a2906a"

View File

@@ -8,7 +8,7 @@ authors = [
{ name = "Arcane", email = "arcane@romm.app" },
{ name = "Adamantike", email = "adamantike@romm.app" },
]
requires-python = "^3.12"
requires-python = "^3.13"
dependencies = [
"PyYAML == 6.0.1",
"SQLAlchemy[mariadb-connector,mysql-connector,postgresql-psycopg] ~= 2.0",