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

fix: add type parameters to generic RootModel #1560

Merged

Conversation

tcrasset
Copy link
Contributor

@tcrasset tcrasset commented Sep 21, 2023

Closes: #1491

and by extension it fixes mypy's error:

Missing type parameters for generic type 'RootModel'

It's not clear from the pydantic documentation whether they force the user to use declare the type twice. They have one example with Pets(RootModel[List[str]]) and one with Pets(RootModel). Though mypy seems to be in favor of the double type hint style.

This fixes mypy's error:

Missing type parameters for generic type 'RootModel'
@tcrasset tcrasset force-pushed the tc/fix-pydanticv2-RootModel-mypy-error branch from d15e132 to 80b4782 Compare September 21, 2023 15:11
@codecov
Copy link

codecov bot commented Sep 21, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (e9b6edf) 100.00% compared to head (80b4782) 100.00%.
Report is 717 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##            master     #1560     +/-   ##
===========================================
  Coverage   100.00%   100.00%             
===========================================
  Files           11        33     +22     
  Lines         1020      3621   +2601     
  Branches       201       841    +640     
===========================================
+ Hits          1020      3621   +2601     
Flag Coverage Δ
unittests 99.64% <99.59%> (?)

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

Files Changed Coverage Δ
datamodel_code_generator/__init__.py 100.00% <100.00%> (ø)
datamodel_code_generator/__main__.py 100.00% <100.00%> (ø)
datamodel_code_generator/arguments.py 100.00% <100.00%> (ø)
datamodel_code_generator/format.py 100.00% <100.00%> (ø)
datamodel_code_generator/http.py 100.00% <100.00%> (ø)
datamodel_code_generator/imports.py 100.00% <100.00%> (ø)
datamodel_code_generator/model/__init__.py 100.00% <100.00%> (ø)
datamodel_code_generator/model/base.py 100.00% <100.00%> (ø)
datamodel_code_generator/model/dataclass.py 100.00% <100.00%> (ø)
datamodel_code_generator/model/enum.py 100.00% <100.00%> (ø)
... and 23 more

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tcrasset
Copy link
Contributor Author

tcrasset commented Sep 21, 2023

Hi @koxudaxi, the CI seems to fail only due to the code coverage report not succeeding to upload. The tests seem to pass.
Please review :)

@koxudaxi koxudaxi merged commit daa0ba6 into koxudaxi:master Sep 21, 2023
73 checks passed
@koxudaxi
Copy link
Owner

@tcrasset
I didn't know RootModel is a generic type.
Thank you very much!! 😄

@tcrasset tcrasset deleted the tc/fix-pydanticv2-RootModel-mypy-error branch September 27, 2023 12:44
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.

New type error for Pydantic v2 models in 0.21.4 release
2 participants