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

Solve FieldValidationInfo warning #1342

Merged
merged 6 commits into from
Oct 4, 2023
Merged

Conversation

RomainBrault
Copy link
Contributor

Fix #1341 by replacing FieldValidationInfo with ValidationInfo.

Copy link
Member

@sisp sisp left a comment

Choose a reason for hiding this comment

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

The tests are failing because the data attribute was added to ValidationInfo in pydantic-core v2.10.0, and Pydantic v2.3.0 uses pydantic-core v2.6.3, which is the currently locked version.

To make this work, we'd need to bump Pydantic to >=2.4.0 in pyproject.toml and update the lock file. There's no other way as Pydantic pins the version of pydantic-core.

Since this would be a dependency version bump only because of an internal type hint, would the other @copier-org/maintainers be okay with this change?

@sisp
Copy link
Member

sisp commented Sep 28, 2023

It seems that Pydantic v2.4 (implicitly via the updated pin of pydantic-core) breaks typing with FieldValidationInfo

copier/user_data.py:194: error: Variable "pydantic_core.core_schema.FieldValidationInfo" is not valid as a type  [valid-type]
copier/user_data.py:194: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
copier/user_data.py:196: error: FieldValidationInfo? has no attribute "data"  [attr-defined]
copier/user_data.py:202: error: Variable "pydantic_core.core_schema.FieldValidationInfo" is not valid as a type  [valid-type]
copier/user_data.py:202: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
copier/user_data.py:203: error: FieldValidationInfo? has no attribute "data"  [attr-defined]

so we may need to bump the minimum Pydantic version to v2.4.

@yajo
Copy link
Member

yajo commented Sep 29, 2023

Yes, please, do the bump, no problem with that. 😉

Bump minimum version number for pydantic to 2.4.2
@sisp
Copy link
Member

sisp commented Sep 29, 2023

@RomainBrault You also need to update poetry.lock:

poetry update pydantic

@yajo yajo enabled auto-merge (squash) October 1, 2023 06:49
@codecov
Copy link

codecov bot commented Oct 1, 2023

Codecov Report

Merging #1342 (1e9b769) into master (fe3b1ae) will increase coverage by 0.06%.
Report is 13 commits behind head on master.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #1342      +/-   ##
==========================================
+ Coverage   97.13%   97.19%   +0.06%     
==========================================
  Files          48       48              
  Lines        4258     4280      +22     
==========================================
+ Hits         4136     4160      +24     
+ Misses        122      120       -2     
Flag Coverage Δ
unittests 97.19% <100.00%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
copier/user_data.py 95.08% <100.00%> (ø)

... and 8 files with indirect coverage changes

Copy link
Member

@sisp sisp left a comment

Choose a reason for hiding this comment

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

@yajo You updated the lock file with an old version of Poetry which reintroduced these category = "..." entries. This adds diff noise and the next Dependabot PR will remove them again.

@sisp
Copy link
Member

sisp commented Oct 1, 2023

FYI, I've fixed pydantic-core (pydantic/pydantic-core#995), so the next Pydantic release that depends on the fixed pydantic-core version will work again (i.e. not fail CI, but the deprecation remains of course).

@yajo
Copy link
Member

yajo commented Oct 1, 2023

Thanks! I updated it with a more modern poetry. I also updated the nix dev shell.

@yajo yajo requested a review from sisp October 1, 2023 11:26
Copy link
Member

@sisp sisp left a comment

Choose a reason for hiding this comment

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

Perfect! 👌

@yajo yajo disabled auto-merge October 2, 2023 07:01
@yajo yajo enabled auto-merge (squash) October 2, 2023 07:02
@yajo yajo merged commit 1f2603d into copier-org:master Oct 4, 2023
16 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.

FieldValidationInfo is deprecated, use ValidationInfo instead.
3 participants