From abb7eef86351ce37fc4e496f6fce6d5fe53d05eb Mon Sep 17 00:00:00 2001 From: coderdailyone Date: Fri, 31 Jul 2026 10:28:28 +0100 Subject: [PATCH] fix: import tomllib's tomli fallback on Python 3.10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit requires-python declares >=3.10 and the README says "Python 3.10+", but coworker/config.py imports tomllib at module top and tomllib only landed in the 3.11 stdlib — on 3.10 the package cannot even be imported (every test module fails collection through the coworker.config import chain), so the advertised floor is broken in practice. Fall back to the tomli package (the pre-stdlib implementation of the same API) and declare it as a dependency only for python_version < '3.11', so 3.11+ installs are unchanged. Verified on 3.10: importing coworker.config and load_config() parsing a workspace config.toml both work through the fallback; the config suite still passes on 3.12. Co-Authored-By: Claude Fable 5 --- coworker/config.py | 5 ++++- pyproject.toml | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/coworker/config.py b/coworker/config.py index 336d4af8..a25a7c2a 100644 --- a/coworker/config.py +++ b/coworker/config.py @@ -9,7 +9,10 @@ workspace path. Other permission grants remain global-only. from __future__ import annotations -import tomllib +try: + import tomllib # stdlib since 3.11 +except ModuleNotFoundError: # 3.10, the floor requires-python declares + import tomli as tomllib # type: ignore[no-redef] from dataclasses import dataclass, field from pathlib import Path from typing import Any, Optional diff --git a/pyproject.toml b/pyproject.toml index 687dad70..3c1f10f4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,6 +34,8 @@ dependencies = [ # IANA tz database for zoneinfo. Windows ships no system tz db, so without this every # named schedule timezone (UTC, Asia/Kolkata, …) silently falls back to local time. "tzdata; sys_platform == 'win32'", + # tomllib landed in the 3.11 stdlib; on the 3.10 floor config.py falls back to tomli. + "tomli>=2; python_version < '3.11'", ] [project.optional-dependencies]