Skip to content

Add pydantic v1 compatibility shim for v2 environments#1

Open
mmanzur2 wants to merge 2 commits intobase-v1.15.0from
pydantic-v1-shim
Open

Add pydantic v1 compatibility shim for v2 environments#1
mmanzur2 wants to merge 2 commits intobase-v1.15.0from
pydantic-v1-shim

Conversation

@mmanzur2
Copy link

Summary

  • Adds a central shim at src/knockapi/_pydantic.py that imports from pydantic.v1 when pydantic v2 is detected, falling back to direct pydantic imports for native v1
  • Updates all files that import directly from pydantic to use the shim instead
  • Hardcodes PYDANTIC_V1 = True in _compat.py so this fork always uses v1 behavior
  • Fixes pre-existing pyright errors in model_dump/model_dump_json overrides and test_bulk.py

Test plan

  • All linters pass (pyright, mypy, ruff) with zero errors
  • Runtime import works with pydantic v2 installed
  • Run full test suite against mock server

🤖 Generated with Claude Code

mmanzur2 and others added 2 commits March 15, 2026 20:59
Add a central shim at _pydantic.py that routes imports through
pydantic.v1 when pydantic v2 is detected. Hardcode PYDANTIC_V1=True
in _compat.py so this fork always uses v1 behavior. Update all files
to use the shim instead of importing directly from pydantic.

Also fix pre-existing pyright errors: add missing params to
model_dump/model_dump_json overrides and cast test fixtures.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Use knockapi._pydantic imports in tests for Field and ValidationError
- Check both v1 and v2 BaseModel in _response.py issubclass checks

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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