Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

108 upgrade pydantic version #110

Merged
merged 13 commits into from
Oct 16, 2024
Merged

108 upgrade pydantic version #110

merged 13 commits into from
Oct 16, 2024

Conversation

Antonyjin
Copy link
Member

No description provided.

@Antonyjin Antonyjin requested a review from hoh October 2, 2024 03:01
@Antonyjin Antonyjin self-assigned this Oct 2, 2024
@Antonyjin Antonyjin linked an issue Oct 2, 2024 that may be closed by this pull request
aleph_message/models/__init__.py Outdated Show resolved Hide resolved
aleph_message/models/__init__.py Outdated Show resolved Hide resolved
aleph_message/models/__init__.py Outdated Show resolved Hide resolved
aleph_message/models/__init__.py Outdated Show resolved Hide resolved
aleph_message/models/execution/instance.py Outdated Show resolved Hide resolved
aleph_message/models/execution/program.py Show resolved Hide resolved
Antonyjin and others added 12 commits October 16, 2024 14:56
Pydantic used to be in 1.10.5 now moving to up to v2 accepting from v2.x to the latest
Replaced `__get_pydantic_core_schema__` with a more efficient schema
handling using `core_schema.str_schema()` and custom validation for ItemHash.
- Updated code to explicitly specify optional keys where necessary.
- Replaced direct `.get` calls with `data.get()` to handle new validation logic.
- Migrated model configuration to use `model_config = ConfigDict(extra="forbid")`
or `model_config = ConfigDict(extra="allow")` in place of Pydantic v1's configuration style.
…eprecated methods.

- Replaced `.dict()` with `.model_dump()` for model serialization.
- Replaced deprecated `.json()` with `.model_dump_json()` for JSON serialization.

These changes ensure compatibility with Pydantic v2 by using the updated serialization methods.
…_content` function for stricter comparison.

- Replaced `.dict()` with `.model_dump()` for model serialization.
- Replaced deprecated `.json()` with `.model_dump_json()` for JSON serialization.
- Updated the `check_content` function to properly normalize and compare JSON structures,
as Pydantic v2 enforces stricter validation and comparison rules.

These changes ensure compatibility with Pydantic v2 by adopting
the new serialization methods and handling stricter content comparison logic.
- Refactored the normalize_content function to respect MyPy.
- Reformatted code according to Black.
- Fixed linting issues raised by Ruff.
Some fields were missing and needed to be specified
du to the v2 of pydantic.
Black test failed
Wrong indentation on one line, add comment for custom_dump
Refactoring normalize_content function from Hugo and added docstring
for better comprehension
Debuging using logger and not print
Function to convert size always return the instance needed.
@hoh hoh force-pushed the 108-upgrade-pydantic-version branch from ce83957 to 2c79fca Compare October 16, 2024 12:57
Copy link
Member

@hoh hoh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@hoh hoh merged commit 8a62363 into main Oct 16, 2024
2 checks passed
@hoh hoh deleted the 108-upgrade-pydantic-version branch October 16, 2024 13:49
@nesitor nesitor restored the 108-upgrade-pydantic-version branch October 31, 2024 19:20
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.

ALEPH-126 - Upgrade pydantic version
2 participants