Skip to content

Fix mypy errors for optional Pydantic imports - #603

Merged
pjbull merged 2 commits into
drivendataorg:masterfrom
terminalchai:fix/optional-pydantic-type-import
Oct 16, 2026
Merged

pjbull merged 2 commits into
drivendataorg:masterfrom
terminalchai:fix/optional-pydantic-type-import

Conversation

@terminalchai

@terminalchai terminalchai commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Running mypy with ignore_missing_imports = false without Pydantic installed reports import-not-found at the guarded pydantic_core imports in both CloudPath and AnyPath. Mark those two imports with a narrow type ignore, following the maintainer's requested approach in #385. Suppressing unused-ignore at the same locations also keeps these directives quiet when Pydantic is installed. The runtime guards and dependencies are unchanged.

Closes #385.

Verified on Windows/Python 3.11: the explicit missing-Pydantic type check failed with two errors before this change and passes after it; the same check passes with Pydantic installed. Both schema hooks return None safely without Pydantic. The full mocked/local suite passed with 2,165 tests and 127 skipped, including existing Pydantic validation and serialization tests across provider rigs. Repository Black, flake8 and mypy checks pass, source and wheel distributions build, and MkDocs builds with existing link warnings. Codex reviewed the supplied diff and validation context. Live cloud backends were not tested. Upstream test and docs workflows require maintainer approval for this fork PR; live backend jobs also wait for maintainer approval.

The reproducible type-check configuration used follow_imports = silent with missing imports left as errors, checking cloudpathlib/cloudpath.py and cloudpathlib/anypath.py and pointing mypy's --python-executable at a minimal environment without Pydantic. A separate check with --warn-unused-ignores confirms no new warnings at these imports; six existing warnings elsewhere in cloudpath.py remain under that opt-in flag.

Contributor checklist:

  • Read and understood CONTRIBUTING.md
  • Existing issue and Closes mark pydantic integration (as an extra?) #385 in summary
  • Based on latest master
  • Failure-before / success-after evidence
  • Applied consistently to CloudPath and AnyPath
  • Manual live cloud backend testing
  • Existing integration tests pass; explicit type-check regression reproduced
  • Lint passes
  • Tests pass
  • Updated HISTORY.md under UNRELEASED

Prepared with AI assistance; the diff and verification results were reviewed before submission.

@terminalchai
terminalchai deployed to reviewed-live-cloud October 14, 2026 21:29 — with GitHub Actions Active
@terminalchai
terminalchai deployed to reviewed-live-cloud October 14, 2026 21:29 — with GitHub Actions Active
@codecov

codecov Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.3%. Comparing base (7a0712b) to head (b919294).

Additional details and impacted files
@@           Coverage Diff            @@
##           master    #603     +/-   ##
========================================
- Coverage    96.1%   95.3%   -0.8%     
========================================
  Files          30      30             
  Lines        2977    2977             
========================================
- Hits         2861    2839     -22     
- Misses        116     138     +22     
Files with missing lines Coverage Δ
cloudpathlib/anypath.py 91.3% <100.0%> (ø)
cloudpathlib/cloudpath.py 96.5% <100.0%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@terminalchai
terminalchai deployed to reviewed-live-cloud October 16, 2026 14:59 — with GitHub Actions Active
@terminalchai
terminalchai deployed to reviewed-live-cloud October 16, 2026 15:39 — with GitHub Actions Active
@terminalchai
terminalchai deployed to reviewed-live-cloud October 16, 2026 15:39 — with GitHub Actions Active
@pjbull
pjbull merged commit 1f95095 into drivendataorg:master Oct 16, 2026
43 of 50 checks passed

This branch was successfully deployed

1 active deployment
reviewed-live-cloud — b9192949 Deployed Oct 16, 2026 by terminalchai via Live Tests (azure) #37
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.

mark pydantic integration (as an extra?)

2 participants