Skip to content

chore: update to Python 3.13+ and fix CI issues#6

Merged
aquemy merged 8 commits intomainfrom
feat/python-3.13-plus-ci-fixes
Dec 26, 2025
Merged

chore: update to Python 3.13+ and fix CI issues#6
aquemy merged 8 commits intomainfrom
feat/python-3.13-plus-ci-fixes

Conversation

@aquemy
Copy link
Copy Markdown
Member

@aquemy aquemy commented Dec 26, 2025

Summary

This PR updates the library to support only Python 3.13+ (dropping Python 3.12 support) and fixes critical CI configuration issues that were causing:

  • Duplicate workflow runs on every PR
  • Documentation build failures
  • Type checking failures in test files

BREAKING CHANGE: Drops Python 3.12 support, requires Python 3.13+


Changes

1. Python Version Requirements (3.12+ → 3.13+)

Files Modified:

  • pyproject.toml: Updated requires-python to >=3.13, removed 3.12 classifier, updated Ruff and Basedpyright targets
  • .github/workflow-config.yml: Updated supported-versions to ["3.13", "3.14"]
  • .github/workflows/test.yaml: Updated matrix to ["3.13", "3.14"]
  • .github/workflows/pull_request.yaml: Updated matrix to ["3.13", "3.14"]
  • README.md: Updated Python version badge to "3.13 | 3.14" and description to "Python 3.13+"

Rationale:

  • Aligns with modern Python ecosystem
  • Codebase already uses Python 3.12+ features (PEP 695 type aliases, @override decorator)
  • Simplifies testing matrix

2. CI Workflow Fixes

Issue 1: Duplicate Workflow Runs

Problem: pull_request.yaml had BOTH pull_request and pull_request_target triggers, causing every PR to run validation jobs twice.

Solution: Added conditional guards:

validate:
  if: github.event_name == 'pull_request'  # Only run on pull_request event

validate-docs:
  if: github.event_name == 'pull_request'  # Only run on pull_request event
  
check-pr-title:
  if: github.event_name == 'pull_request_target'  # Only run on pull_request_target event

Impact: PR workflows now run once instead of twice

Issue 2: Documentation Build Failure

Problem: uvx hatch version dev step was failing with NotImplementedError in shallow git clones

Solution: Removed the step entirely - MkDocs doesn't require version to be set in pyproject.toml for validation builds

Impact: Documentation validation now succeeds


3. Type Annotation Fixes

Files Modified:

  • tests/unit/test_threading_bridge.py
  • tests/unit/test_thread_cancelation.py

Changes:

  • Added type annotations to fixture parameters (bridge: AnyioBridge, clean_registry: OperationRegistry)
  • Added return type annotations (-> None) to all test methods
  • Added missing imports for AnyioBridge and OperationRegistry

Impact: Resolves basedpyright type checking errors that were blocking CI


Testing

  • ✅ All 26 tests in modified files pass locally
  • ✅ Type annotations verified with basedpyright
  • ✅ No regressions introduced
  • ✅ CI should now:
    • Run only once per PR update (not twice)
    • Pass all validation checks
    • Build documentation successfully

Verification

Once this PR is merged, verify:

  1. Workflows run only once per PR (check Actions tab)
  2. All validation jobs pass (Validate 3.13, Validate 3.14, Validate Docs, Check PR Title)
  3. No duplicate workflow runs appear

Related Issues

Fixes the CI failures on PR #5

Add 9 comprehensive tests to reach 100% coverage for:
- cancelable.py (99.80% -> all targeted lines covered)
- composite.py (76.87% -> 100%)
- decorators.py (99% -> 100%)

New tests cover:
- Parent token linking warnings (line 810)
- Combined cancelable linking warnings (line 828)
- BaseException handling (branch 723→734)
- MonitoredSource exception handling (lines 71-75, 250-254)
- Attribute delegation via __getattr__ (lines 79, 258)
- Multiple trigger calls (branch 48→54)
- Existing cancelable config handling (line 157)

All 452 tests passing. 15 files now have 100% coverage.
BREAKING CHANGE: Drop Python 3.12 support, require Python 3.13+

## Python Version Updates
- Update requires-python to >=3.13 in pyproject.toml
- Update Python version classifiers (remove 3.12, keep 3.13, 3.14)
- Update Ruff target-version to py313
- Update Basedpyright pythonVersion to 3.13
- Update all workflow matrices to test Python 3.13 and 3.14
- Update README.md badges and description

## CI Workflow Fixes
- Add conditional guards to prevent duplicate runs:
  - validate job: runs only on 'pull_request' event
  - validate-docs job: runs only on 'pull_request' event
  - check-pr-title job: runs only on 'pull_request_target' event
- Remove problematic 'uvx hatch version dev' step from docs build
  (MkDocs doesn't require version to be set)

## Type Annotation Fixes
- Add type annotations to test fixture parameters in:
  - tests/unit/test_threading_bridge.py
  - tests/unit/test_thread_cancelation.py
- Add missing imports for AnyioBridge and OperationRegistry
- Add return type annotations (-> None) to all test methods

Resolves duplicate workflow runs issue where both pull_request and
pull_request_target events were triggering validation jobs.

All tests passing (26 tests in affected files).
This removes the pull_request_target trigger which was causing duplicate workflow runs. The pull_request_target event uses the workflow file from the base branch (main), not the PR branch, which was causing the old workflow configuration to run alongside the new one.

Changes:
- Remove pull_request_target trigger section
- Remove check-pr-title job (depends on pull_request_target)
- Remove conditional guards (no longer needed with single trigger)

The PR title check can be re-enabled in a separate workflow file after this PR merges.
GitHub Actions uses /bin/sh (dash) by default which doesn't support bash-specific [[syntax used in lefthook.yml. Explicitly specify bash shell for steps that use lefthook to ensure compatibility.
Replace bash-specific [[ syntax with POSIX-compliant [ and case statements.
Lefthook internally uses sh (not bash) to execute commands, which requires
POSIX compliance. This fixes the "sh: [[: not found" errors in CI.
- Fix import order in 10_shared_context.py
- Make cancelable parameter keyword-only in database example to avoid parameter ordering conflict
- Make cancelable parameter keyword-only in monitoring dashboard
- Fix import sorting in test_cancelable.py and examples
Test assertions commonly use magic numbers which shouldn't require constants.
This rule is too strict for test files where readability is more important.
@aquemy aquemy merged commit 9df2983 into main Dec 26, 2025
2 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant