Skip to content

Migrate from Pydantic v1 to native Pydantic v2#634

Open
JosueNina wants to merge 6 commits intoQuantConnect:masterfrom
JosueNina:feature-migrate-from-pyndatic-v1-to-v2
Open

Migrate from Pydantic v1 to native Pydantic v2#634
JosueNina wants to merge 6 commits intoQuantConnect:masterfrom
JosueNina:feature-migrate-from-pyndatic-v1-to-v2

Conversation

@JosueNina
Copy link
Collaborator

@JosueNina JosueNina commented Mar 4, 2026

Closes #621

Replaces all Pydantic v1 patterns with their native v2 equivalents:

  • @validator -> @field_validator(..., mode="before") @classmethod
  • .dict() / .json() -> .model_dump() / .model_dump_json()
  • Optional[T] fields without defaults -> explicit = None
  • typing.Pattern -> re.Pattern
  • pydantic>=1.8.2 -> pydantic>=2.0.0 in setup.py

Adds ConfigDict(coerce_numbers_to_str=True) to WrappedBaseModel to ensure the base model continues to allow automatic number to string conversion, and an annotated type SafePath to avoid a pyfakefs conflict with Pydantic v2's.

@JosueNina JosueNina force-pushed the feature-migrate-from-pyndatic-v1-to-v2 branch from c557c69 to 7765d8e Compare March 6, 2026 20:48
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.

Add python 3.14 and 3.13

1 participant