Skip to content

refactor: migrate deprecated Pydantic v1 class Config to v2 ConfigDict - #660

Merged
chinmayajha merged 2 commits into
mozarkai:mainfrom
MilindChatrabhuji:fix/pydantic-v2-configdict
Oct 28, 2026
Merged

chinmayajha merged 2 commits into
mozarkai:mainfrom
MilindChatrabhuji:fix/pydantic-v2-configdict

Conversation

@MilindChatrabhuji

@MilindChatrabhuji MilindChatrabhuji commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Description

Migrates deprecated Pydantic V1-style class Config: inner classes to Pydantic V2 model_config = ConfigDict(...) across the repository.

Changes:

  • optics_framework/common/config_handler.py:
    • DependencyConfig: Migrated class Config (arbitrary_types_allowed = True) -> model_config = ConfigDict(arbitrary_types_allowed=True).
    • Config: Migrated class Config (arbitrary_types_allowed = True) -> model_config = ConfigDict(arbitrary_types_allowed=True).
    • Added ConfigDict import from pydantic.
  • optics_framework/common/base_factory.py:
    • GenericFactory.ModuleRegistry: Migrated class Config (arbitrary_types_allowed = True) -> model_config = ConfigDict(arbitrary_types_allowed=True).
    • InstanceFallback: Migrated class Config (arbitrary_types_allowed = True) -> model_config = ConfigDict(arbitrary_types_allowed=True).
    • Added ConfigDict import from pydantic.
  • optics_framework/engines/drivers/ble.py:
    • CapabilitiesConfig: Migrated class Config (populate_by_name = True) -> model_config = ConfigDict(populate_by_name=True).
    • Added ConfigDict import from pydantic.
  • optics_framework/engines/elementsources/camera_screenshot.py:
    • CapabilitiesConfig: Migrated class Config (populate_by_name = True) -> model_config = ConfigDict(populate_by_name=True).
    • Added ConfigDict import from pydantic.

Verification:

  • Verified 0 remaining occurrences of class Config: across the codebase (git grep -n "class Config:").
  • Ran tests with -W error::pydantic.warnings.PydanticDeprecatedSince20, confirming 0 deprecation warnings and all tests passing.

Closes #311

Migrate deprecated inner class Config: to Pydantic v2 model_config = ConfigDict(...) across the framework models to resolve deprecation warnings and prepare for Pydantic v3 compatibility.

Closes mozarkai#311
@chinmayajha

Copy link
Copy Markdown
Collaborator

@MilindChatrabhuji Thanks for this, are there any other Pydantic V1 references we could migrate?

@MilindChatrabhuji

Copy link
Copy Markdown
Contributor Author

Hi @chinmayajha!

I ran a full automated AST and regex audit across the entire repository to verify if any remaining Pydantic V1 patterns existed. Here is what was checked:

  • Inner class Config: 100% migrated to model_config = ConfigDict(...) (in �ase_factory.py, config_handler.py, execution.py, �le.py, and camera_screenshot.py).
  • Validators: All custom validators (e.g. in helper/execute.py) use Pydantic V2 @field_validator.
  • Model Methods: Verified zero remaining calls to .dict(), .copy(), .parse_obj(), .parse_raw(), or .from_orm() on Pydantic models (all .copy() calls across the repo are standard Python dict.copy() or NumPy
    darray.copy()).
  • Serialization / Deserialization: All models use standard V2 .model_dump() and model_validate().

The entire codebase is now cleanly compliant with Pydantic V2 without any deprecated V1 compatibility shims or deprecation warnings. Everything is in place and ready to merge!

@chinmayajha

Copy link
Copy Markdown
Collaborator

Thanks @MilindChatrabhuji !

@sonarqubecloud

Copy link
Copy Markdown

@chinmayajha
chinmayajha merged commit 896e357 into mozarkai:main Oct 28, 2026
12 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.

Migrate Pydantic V1 class Config to V2 ConfigDict

2 participants