fix: import tomllib's tomli fallback on Python 3.10

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 <noreply@anthropic.com>
This commit is contained in:
coderdailyone
2026-07-31 10:28:28 +01:00
co-authored by Claude Fable 5
parent e0cb129d20
commit abb7eef863
2 changed files with 6 additions and 1 deletions
+4 -1
View File
@@ -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
+2
View File
@@ -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]