Skip to content

Turn any technical book PDF into a Claude Code skill — ready to study, reference, and use while you work.

fix(extractor): defer annotation evaluation so import works on Python 3.9 (#34)

Randerson Melville06844f4b3780
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 15e3012..501d3ca 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: false
matrix:
- python-version: ["3.10", "3.11", "3.12", "3.13"]
+ python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a0f54bb..9ec0525 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,22 @@ All notable changes to **book-to-skill** are documented here.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## [Unreleased]
+
+### Fixed
+- **Package now imports on interpreters that evaluate annotations eagerly.**
+ Added `from __future__ import annotations` to every module using PEP 604
+ unions (`str | None`) — `scripts/extractor/{utils,dependencies}.py`, all
+ `scripts/extractor/parsers/*.py`, and `tools/discovery_tax.py`. Before this,
+ importing the package under Python 3.9 raised `TypeError: unsupported operand
+ type(s) for |: 'type' and 'NoneType'` at import time, so the whole test suite
+ failed during collection. The annotations are now lazy (free at runtime), so
+ the package imports and runs cleanly on Python 3.9 as well.
+
+### Changed
+- CI test matrix now includes Python 3.9 so the import path above is guarded and
+ cannot silently re-break.
+
## [1.1.0] — 2026-06-12
### Added
diff --git a/scripts/extractor/dependencies.py b/scripts/extractor/dependencies.py
index 224cb27..f48c88b 100644
--- a/scripts/extractor/dependencies.py
+++ b/scripts/extractor/dependencies.py
@@ -1,3 +1,5 @@
+from __future__ import annotations
+
import importlib.util
import os
import shutil
diff --git a/scripts/extractor/parsers/calibre.py b/scripts/extractor/parsers/calibre.py
index 14471c1..96a6a14 100644
--- a/scripts/extractor/parsers/calibre.py
+++ b/scripts/extractor/parsers/calibre.py
@@ -1,3 +1,5 @@
+from __future__ import annotations
+
import shutil
import subprocess
from extractor.config import OUTPUT_DIR
diff --git a/scripts/extractor/parsers/docx.py b/scripts/extractor/parsers/docx.py
index bc7a1d1..e6bf9dc 100644
--- a/scripts/extractor/parsers/docx.py
+++ b/scripts/extractor/parsers/docx.py
@@ -1,3 +1,5 @@
+from __future__ import annotations
+
import zipfile
from extractor.exceptions import ExtractionError
diff --git a/scripts/extractor/parsers/epub.py b/scripts/extractor/parsers/epub.py
index 681108c..f905c23 100644
--- a/scripts/extractor/parsers/epub.py
+++ b/scripts/extractor/parsers/epub.py
@@ -1,3 +1,5 @@
+from __future__ import annotations
+
import posixpath
import re
import zipfile
diff --git a/scripts/extractor/parsers/html.py b/scripts/extractor/parsers/html.py
index 8e38c84..5133f7b 100644
--- a/scripts/extractor/parsers/html.py
+++ b/scripts/extractor/parsers/html.py
@@ -1,3 +1,5 @@
+from __future__ import annotations
+
import html
import html.parser
from extractor.parsers.text import read_text_file
diff --git a/scripts/extractor/parsers/pdf.py b/scripts/extractor/parsers/pdf.py
index 123fa46..614fa7a 100644
--- a/scripts/extractor/parsers/pdf.py
+++ b/scripts/extractor/parsers/pdf.py
@@ -1,3 +1,5 @@
+from __future__ import annotations
+
import shutil
import subprocess
diff --git a/scripts/extractor/parsers/text.py b/scripts/extractor/parsers/text.py
index 7304f81..56a3b6d 100644
--- a/scripts/extractor/parsers/text.py
+++ b/scripts/extractor/parsers/text.py
@@ -1,3 +1,5 @@
+from __future__ import annotations
+
from pathlib import Path
diff --git a/scripts/extractor/utils.py b/scripts/extractor/utils.py
index b5356fc..4a8d656 100644
--- a/scripts/extractor/utils.py
+++ b/scripts/extractor/utils.py
@@ -1,3 +1,5 @@
+from __future__ import annotations
+
import glob
import json
import os
diff --git a/tools/discovery_tax.py b/tools/discovery_tax.py
index 96ec016..7c2ff7c 100644
--- a/tools/discovery_tax.py
+++ b/tools/discovery_tax.py
@@ -28,6 +28,8 @@ Usage:
[--skill-dir <skill_folder>] [--target-chapter N] [--core-tokens 4000]
"""
+from __future__ import annotations
+
import argparse
import re
import sys