Repository navigation
[2.1.x] fix(grpo): hanzoai 2.1.2 cannot be imported on Python 3.9 - #50
Merged
Merged
Conversation
hanzoai 2.1.2 declares requires-python >= 3.9, yet `import hanzoai` raises TypeError on 3.9. grpo/enhanced_api_model_adapter.py annotates four returns as `str | Tuple[str, Optional[str]]`, which 3.9 evaluates at class-body time, and hanzoai/__init__.py imports grpo eagerly. grpo/enhanced_semantic_extractor.py has the same shape once, behind it. Postpone annotation evaluation in both modules. They are the only two in the package whose PEP 604 unions reach the interpreter. Their dataclasses never resolve annotations, so nothing else changes. tests/test_imports.py imports every module under hanzoai. A new CI job runs it after `pip install .` on 3.9 and 3.13, because the test job only runs .python-version (3.12), where the annotation is valid. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
zeekay
added a commit
that referenced
this pull request
Sep 11, 2026
2.1.2 declares requires-python >= 3.9 and `import hanzoai` raises TypeError there, so the whole line is unusable on the floor it publishes. The fix has been on this branch since #50 and reaches nobody until a number above 2.1.2 carries it. Co-authored-by: Hanzo Dev <dev@hanzo.ai>
Member
|
Thanks @Naz-Tac, released as hanzoai 2.1.3. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Important
This fix targets the 2.1.x line. Please don't merge it into
main. Onmain, grpo no longer exists andrequires-pythonis>=3.12. The diff is one commit on top of07646380, the commit the 2.1.2 wheel was built from. To ship it, cutrelease/2.1.xat07646380and retarget this PR.Repro
On Python 3.9.6:
Fix
from __future__ import annotations, so 3.9 no longer evaluates theirstr | Tuple[...]return annotations. The second module,enhanced_semantic_extractor.py, has one such annotation.import, runspip install .and thentests/test_imports.py, which imports all 318 modules, on 3.9 and 3.13.07646380gives 313 failed. This branch gives 318 passed, on both 3.9.6 and 3.13.15.Why 3.9 users get 2.1.2
Every release from 2.2.0 on requires Python
>=3.12, so pip on 3.9, 3.10 and 3.11 resolves to 2.1.2. Of those three, only 3.9 breaks.A 2.1.3 that raised
requires-pythonto>=3.10would change nothing: pip on 3.9 would still pick 2.1.2. Only a fixed 2.1.3, or yanking 2.1.2, changes what 3.9 gets. Yanking alone would work too, since 2.0.2 imports on 3.9.6, but it sends 3.9 users back to a client from March 2025.Why this branch starts at
07646380and notv2.1.2The PyPI wheel matches
07646380("chore: update hanzoai SDK and tests", 2026-01-21) on all 321 files. Tagv2.1.2(e57aa3f8, 2025-12-09) doesn't: 266 files differ from the wheel, and 49 exist only in the wheel.Sibling sweep
An AST scan of the whole wheel finds PEP 604 unions that 3.9 evaluates only in these two modules. Every other module that writes
X | Yin annotations already has the future import, and no module uses a union outside an annotation (type aliases,isinstance).PEP 585 generics such as
tuple[...]already work on 3.9. Both modules use plain dataclasses, which never evaluate their annotations, so behavior is unchanged.Test runs
07646380tests/test_imports.pyon 3.9.6pytest testson 3.12pytest testson 3.9.6conftest.pycan't importhanzoai¹ Those 5 pass only because the failed
import hanzoaileft their submodules insys.modules.The 2 failures and 8 errors appear on both sides and come from outside
hanzoai:hanzoCLI package needclick, which is not ahanzoaidependency.test_workflow.pyruns apythoncommand, and this machine has nopythonon PATH.I ran pytest directly, because rye isn't installed here, so neither
scripts/testnor the nox pydantic-v1 session ran.ruff 0.14.8 finds nothing in the changed files.
After retargeting, add
release/2.1.xtoci.yml'spull_request.branches, or CI won't run on this PR.🤖 Generated with Claude Code