Skip to content

fix: restore Python 3.11 TypedDict compatibility - #242

Merged
Sinity merged 1 commit into
masterfrom
feature/fix/pydantic-typeddict-compat
Apr 20, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/fix/pydantic-typeddict-compat

Conversation

@Sinity

@Sinity Sinity commented Apr 20, 2026 •

Copy link
Copy Markdown
Owner

Ref #241
Ref #222

Summary

  • switch runtime-loaded TypedDict payload surfaces to typing_extensions.TypedDict so Pydantic stays compatible with Python 3.11
  • carry the same import boundary through adjacent devtool and test helper surfaces for consistency
  • stabilize one slow Hypothesis Drive payload property test that started flaking once the suite was exercised under 3.11

Problem

Open refactor PRs were failing the test (3.11) GitHub Actions leg with pydantic.errors.PydanticUserError: Please use typing_extensions.TypedDict instead of typing.TypedDict on Python < 3.12. The repo verified locally on newer interpreters, but several runtime-loaded payload and state models still imported TypedDict from typing, which Pydantic v2 rejects under Python 3.11.

Solution

  • rewired the affected runtime payload surfaces in polylogue/ to import TypedDict from typing_extensions, including state, pipeline, surface-payload, source-assembly, and query-model helpers
  • mirrored the same import boundary in adjacent devtool and test/helper modules so the repo uses one consistent TypedDict contract across supported Python versions
  • updated tests/unit/sources/test_drive_source_client.py to suppress the HealthCheck.too_slow warning for the newline-delimited payload property test, which became flaky when the suite was actually run under Python 3.11

Verification

  • ruff check devtools/pipeline_probe.py devtools/project_motd.py polylogue/cli/embed_stats.py polylogue/pipeline/run_finalization.py polylogue/pipeline/run_stages.py polylogue/pipeline/semantic_capture.py polylogue/pipeline/services/indexing.py polylogue/pipeline/services/ingest_worker.py polylogue/sources/assembly.py polylogue/storage/backends/queries/stats.py polylogue/storage/query_models.py polylogue/storage/session_product_runtime.py polylogue/storage/state_views.py polylogue/surface_payloads.py tests/infra/cli_subprocess.py tests/unit/cli/test_source_selection_helpers.py tests/unit/core/test_filters_props.py tests/unit/pipeline/test_resilience.py tests/unit/sources/test_drive_source_client.py tests/unit/sources/test_parser_crashlessness.py tests/unit/sources/test_source_laws.py tests/unit/storage/test_store_ops.py
  • uv run --python 3.11 --extra dev pytest -q -n 0 tests/unit/ui/test_ui.py tests/unit/scenarios/test_scenario_specs.py tests/integration/test_cli_machine_contract.py tests/unit/showcase/test_scenario_models.py
  • uv run --python 3.11 --extra dev pytest -q -n 0 tests/unit/sources/test_drive_source_client.py
  • devtools verify

@coderabbitai

coderabbitai Bot commented Apr 20, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: c72a662e-cdcc-4ce9-b80b-3109efad0e2f

📥 Commits

Reviewing files that changed from the base of the PR and between 5ed4243 and a11b9b8.

📒 Files selected for processing (22)
  • devtools/pipeline_probe.py
  • devtools/project_motd.py
  • polylogue/cli/embed_stats.py
  • polylogue/pipeline/run_finalization.py
  • polylogue/pipeline/run_stages.py
  • polylogue/pipeline/semantic_capture.py
  • polylogue/pipeline/services/indexing.py
  • polylogue/pipeline/services/ingest_worker.py
  • polylogue/sources/assembly.py
  • polylogue/storage/backends/queries/stats.py
  • polylogue/storage/query_models.py
  • polylogue/storage/session_product_runtime.py
  • polylogue/storage/state_views.py
  • polylogue/surface_payloads.py
  • tests/infra/cli_subprocess.py
  • tests/unit/cli/test_source_selection_helpers.py
  • tests/unit/core/test_filters_props.py
  • tests/unit/pipeline/test_resilience.py
  • tests/unit/sources/test_drive_source_client.py
  • tests/unit/sources/test_parser_crashlessness.py
  • tests/unit/sources/test_source_laws.py
  • tests/unit/storage/test_store_ops.py

📝 Walkthrough

Walkthrough

Systematically updated TypedDict imports across the codebase from the standard typing module to typing_extensions in 18 files spanning CLI, pipeline, storage, and test modules, while preserving all type definitions and logic.

Changes

Cohort / File(s) Summary
TypedDict Import Migration - Core & DevTools
devtools/pipeline_probe.py, devtools/project_motd.py, polylogue/cli/embed_stats.py, polylogue/sources/assembly.py, polylogue/surface_payloads.py
Replaced TypedDict import from typing with typing_extensions.TypedDict across all files, with no changes to type definitions or runtime logic.
TypedDict Import Migration - Pipeline
polylogue/pipeline/run_finalization.py, polylogue/pipeline/run_stages.py, polylogue/pipeline/semantic_capture.py, polylogue/pipeline/services/indexing.py, polylogue/pipeline/services/ingest_worker.py
Updated TypedDict import source from typing to typing_extensions in all pipeline-related modules, leaving type declarations and control flow unchanged.
TypedDict Import Migration - Storage
polylogue/storage/backends/queries/stats.py, polylogue/storage/query_models.py, polylogue/storage/session_product_runtime.py, polylogue/storage/state_views.py
Migrated TypedDict import from typing to typing_extensions across all storage modules without altering type structures or exported signatures.
TypedDict Import Migration - Tests
tests/infra/cli_subprocess.py, tests/unit/cli/test_source_selection_helpers.py, tests/unit/core/test_filters_props.py, tests/unit/pipeline/test_resilience.py, tests/unit/sources/test_parser_crashlessness.py, tests/unit/sources/test_source_laws.py, tests/unit/storage/test_store_ops.py
Updated TypedDict import source from typing to typing_extensions in test modules without modifying test logic or assertions.
Hypothesis Health Check Configuration
tests/unit/sources/test_drive_source_client.py
Added suppress_health_check=[HealthCheck.too_slow] to Hypothesis @settings decorator on test_parse_downloaded_json_payload_preserves_newline_delimited_documents and imported HealthCheck from hypothesis.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

Possibly related PRs

Suggested labels

type:fix, area:cli, area:pipeline, area:storage

Poem

🐰 Hopping through imports with glee,
From typing to extensions so free,
TypedDict now springs,
On more modern wings,
Pydantic and Python agree! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: restore Python 3.11 TypedDict compatibility' clearly and concisely summarizes the main change across all 18 modified files: switching TypedDict imports from typing to typing_extensions for Pydantic v2 compatibility.
Description check ✅ Passed The description follows the template with all required sections (Summary, Problem, Solution, Verification) completed. It provides clear context for the Pydantic v2 error on Python 3.11, explains the systematic solution across multiple modules, and documents specific verification steps run.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/fix/pydantic-typeddict-compat

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Sinity
Sinity merged commit 0a824a5 into master Apr 20, 2026
14 checks passed
@Sinity
Sinity deleted the feature/fix/pydantic-typeddict-compat branch April 20, 2026 03:06
Sinity added a commit that referenced this pull request Apr 22, 2026
Ref #241
Ref #222

## Summary
- switch runtime-loaded `TypedDict` payload surfaces to `typing_extensions.TypedDict` so Pydantic stays compatible with Python 3.11
- carry the same import boundary through adjacent devtool and test helper surfaces for consistency
- stabilize one slow Hypothesis Drive payload property test that started flaking once the suite was exercised under 3.11

## Problem
Open refactor PRs were failing the `test (3.11)` GitHub Actions leg with `pydantic.errors.PydanticUserError: Please use typing_extensions.TypedDict instead of typing.TypedDict on Python < 3.12.` The repo verified locally on newer interpreters, but several runtime-loaded payload and state models still imported `TypedDict` from `typing`, which Pydantic v2 rejects under Python 3.11.

## Solution
- rewired the affected runtime payload surfaces in `polylogue/` to import `TypedDict` from `typing_extensions`, including state, pipeline, surface-payload, source-assembly, and query-model helpers
- mirrored the same import boundary in adjacent devtool and test/helper modules so the repo uses one consistent `TypedDict` contract across supported Python versions
- updated `tests/unit/sources/test_drive_source_client.py` to suppress the `HealthCheck.too_slow` warning for the newline-delimited payload property test, which became flaky when the suite was actually run under Python 3.11

## Verification
- `ruff check devtools/pipeline_probe.py devtools/project_motd.py polylogue/cli/embed_stats.py polylogue/pipeline/run_finalization.py polylogue/pipeline/run_stages.py polylogue/pipeline/semantic_capture.py polylogue/pipeline/services/indexing.py polylogue/pipeline/services/ingest_worker.py polylogue/sources/assembly.py polylogue/storage/backends/queries/stats.py polylogue/storage/query_models.py polylogue/storage/session_product_runtime.py polylogue/storage/state_views.py polylogue/surface_payloads.py tests/infra/cli_subprocess.py tests/unit/cli/test_source_selection_helpers.py tests/unit/core/test_filters_props.py tests/unit/pipeline/test_resilience.py tests/unit/sources/test_drive_source_client.py tests/unit/sources/test_parser_crashlessness.py tests/unit/sources/test_source_laws.py tests/unit/storage/test_store_ops.py`
- `uv run --python 3.11 --extra dev pytest -q -n 0 tests/unit/ui/test_ui.py tests/unit/scenarios/test_scenario_specs.py tests/integration/test_cli_machine_contract.py tests/unit/showcase/test_scenario_models.py`
- `uv run --python 3.11 --extra dev pytest -q -n 0 tests/unit/sources/test_drive_source_client.py`
- `devtools verify`
@Sinity Sinity added tool:claude Claude type:fix Bug fix labels Apr 22, 2026
Sinity added a commit that referenced this pull request Apr 22, 2026
Open refactor PRs were failing the `test (3.11)` CI leg with
`pydantic.errors.PydanticUserError: Please use
typing_extensions.TypedDict instead of typing.TypedDict on Python
< 3.12.` The repo verified locally on newer interpreters, but
several runtime-loaded payload and state models still imported
`TypedDict` from `typing`, which Pydantic v2 rejects under 3.11.

Rewires the affected runtime payload surfaces in `polylogue/` to
import `TypedDict` from `typing_extensions` (state, pipeline,
surface-payload, source-assembly, query-model helpers). Mirrors the
same import boundary in adjacent devtool and test/helper modules so
the repo uses one consistent `TypedDict` contract across supported
Python versions.

Also stabilizes one slow Hypothesis Drive payload property test that
started flaking once the suite was actually exercised under 3.11
(`HealthCheck.too_slow` suppression on
`test_drive_source_client.py`'s newline-delimited property test).

Verification: ruff clean across touched modules; pytest green under
`uv run --python 3.11`; devtools verify green.

Ref #241
Ref #222
Sinity added a commit that referenced this pull request Apr 22, 2026
Open refactor PRs were failing the `test (3.11)` CI leg with
`pydantic.errors.PydanticUserError: Please use
typing_extensions.TypedDict instead of typing.TypedDict on Python
< 3.12.` The repo verified locally on newer interpreters, but
several runtime-loaded payload and state models still imported
`TypedDict` from `typing`, which Pydantic v2 rejects under 3.11.

Rewires the affected runtime payload surfaces in `polylogue/` to
import `TypedDict` from `typing_extensions` (state, pipeline,
surface-payload, source-assembly, query-model helpers). Mirrors the
same import boundary in adjacent devtool and test/helper modules so
the repo uses one consistent `TypedDict` contract across supported
Python versions.

Also stabilizes one slow Hypothesis Drive payload property test that
started flaking once the suite was actually exercised under 3.11
(`HealthCheck.too_slow` suppression on
`test_drive_source_client.py`'s newline-delimited property test).

Verification: ruff clean across touched modules; pytest green under
`uv run --python 3.11`; devtools verify green.

Ref #241
Ref #222
Sinity added a commit that referenced this pull request Apr 22, 2026
Open refactor PRs were failing the `test (3.11)` CI leg with
`pydantic.errors.PydanticUserError: Please use
typing_extensions.TypedDict instead of typing.TypedDict on Python
< 3.12.` The repo verified locally on newer interpreters, but
several runtime-loaded payload and state models still imported
`TypedDict` from `typing`, which Pydantic v2 rejects under 3.11.

Rewires the affected runtime payload surfaces in `polylogue/` to
import `TypedDict` from `typing_extensions` (state, pipeline,
surface-payload, source-assembly, query-model helpers). Mirrors the
same import boundary in adjacent devtool and test/helper modules so
the repo uses one consistent `TypedDict` contract across supported
Python versions.

Also stabilizes one slow Hypothesis Drive payload property test that
started flaking once the suite was actually exercised under 3.11
(`HealthCheck.too_slow` suppression on
`test_drive_source_client.py`'s newline-delimited property test).

Verification: ruff clean across touched modules; pytest green under
`uv run --python 3.11`; devtools verify green.

Ref #241
Ref #222
@Sinity

Sinity commented May 1, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Sinity
Sinity requested review from Copilot and removed request for Copilot May 1, 2026 01:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant