From 76f192f3d20d4656d6608cb10520016cf58ef641 Mon Sep 17 00:00:00 2001 From: cowork-bot Date: Fri, 3 Jul 2026 15:48:49 -0400 Subject: [PATCH] cowork-bot: fix packaging-quality tests on Python 3.10 (tomllib compat) The two TestPackagingQuality tests imported tomllib unconditionally, which does not exist before Python 3.11. Since the project declares requires-python = '>=3.10' and classifies 3.10 as supported, the test suite fails on the declared minimum interpreter (CI only exercises 3.11-3.13, so this was invisible there). - test_cli_edge_cases.py: import tomllib with a tomli fallback for 3.10; remove the two inline imports; sort the import block (ruff I001). - pyproject.toml: add 'tomli>=2.0.0; python_version < 3.11' to the dev extra so the fallback resolves on 3.10. Verified: 7/7 in test_cli_edge_cases.py pass on Python 3.10 (were 2 failing); 274 core tests green; ruff check src/ clean. --- pyproject.toml | 1 + tests/test_cli_edge_cases.py | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 363a758..9df6bf9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,6 +50,7 @@ dev = [ "pytest-cov>=4.0.0", "responses>=0.24.0", "ruff>=0.4.0", + "tomli>=2.0.0; python_version < '3.11'", ] all = [ "hvac>=2.0.0", diff --git a/tests/test_cli_edge_cases.py b/tests/test_cli_edge_cases.py index e80c6dc..dcd8c88 100644 --- a/tests/test_cli_edge_cases.py +++ b/tests/test_cli_edge_cases.py @@ -11,10 +11,15 @@ from __future__ import annotations -import sys -import yaml +try: + import tomllib # Python 3.11+ +except ModuleNotFoundError: # Python 3.10 + import tomli as tomllib +import sys from pathlib import Path + +import yaml from typer.testing import CliRunner sys.path.insert(0, str(Path(__file__).parent.parent / "src")) @@ -161,7 +166,6 @@ class TestPackagingQuality: def test_package_data_includes_py_typed(self): """pyproject.toml should have package-data config for py.typed.""" - import tomllib pyproject = Path(__file__).parent.parent / "pyproject.toml" with open(pyproject, "rb") as f: @@ -176,7 +180,6 @@ def test_package_data_includes_py_typed(self): def test_ruff_known_first_party(self): """ruff known-first-party should be ['envault'], not ['*'].""" - import tomllib pyproject = Path(__file__).parent.parent / "pyproject.toml" with open(pyproject, "rb") as f: