From 04bce59bc2e4a2b50abdc0c5748aebad15fe4d19 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Feb 2026 03:34:08 +0000 Subject: [PATCH] Fix tomllib import error on Python 3.10 tomllib is only available in the standard library from Python 3.11+. Since the project supports Python >=3.10, use the tomli backport package as a fallback when running on Python 3.10. https://claude.ai/code/session_01Tzo8wK29J226UkmuZQ1DSE --- pyproject.toml | 1 + scripts/convert.py | 6 +++++- uv.lock | 6 +++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 2825fdb97..6a6eb064e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,6 +7,7 @@ readme = "README.md" requires-python = ">=3.10,<4.0" dependencies = [ "tomli_w>=1.0", + "tomli>=2.0; python_version < '3.11'", ] [project.urls] diff --git a/scripts/convert.py b/scripts/convert.py index 1d3fa2700..488a847fe 100644 --- a/scripts/convert.py +++ b/scripts/convert.py @@ -19,7 +19,11 @@ from pathlib import Path import tomli_w -import tomllib + +if sys.version_info >= (3, 11): + import tomllib +else: + import tomli as tomllib from scripts.config import ( DOC_SET_INFO, diff --git a/uv.lock b/uv.lock index 96a8d20a1..55f4a6408 100644 --- a/uv.lock +++ b/uv.lock @@ -73,6 +73,7 @@ name = "idfkit-docs" version = "0.0.1" source = { virtual = "." } dependencies = [ + { name = "tomli", marker = "python_full_version < '3.11'" }, { name = "tomli-w" }, ] @@ -86,7 +87,10 @@ dev = [ ] [package.metadata] -requires-dist = [{ name = "tomli-w", specifier = ">=1.0" }] +requires-dist = [ + { name = "tomli", marker = "python_full_version < '3.11'", specifier = ">=2.0" }, + { name = "tomli-w", specifier = ">=1.0" }, +] [package.metadata.requires-dev] dev = [