-
-
Notifications
You must be signed in to change notification settings - Fork 536
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
[strawberry.ext.mypy_plugin] Fix import error for users who don't use pydantic #3018
Conversation
Thanks for adding the Here's a preview of the changelog: Fix import error in Here's the preview release card for twitter: Here's the tweet text:
|
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #3018 +/- ##
==========================================
- Coverage 96.47% 96.47% -0.01%
==========================================
Files 469 469
Lines 29144 29144
Branches 3587 3587
==========================================
- Hits 28117 28116 -1
Misses 840 840
- Partials 187 188 +1 |
CodSpeed Performance ReportMerging #3018 will not alter performanceComparing Summary
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah good catch! Can you add a release file for this?
@@ -64,6 +63,8 @@ | |||
try: | |||
from pydantic.mypy import METADATA_KEY as PYDANTIC_METADATA_KEY | |||
from pydantic.mypy import PydanticModelField | |||
|
|||
from strawberry.experimental.pydantic._compat import IS_PYDANTIC_V1 | |||
except ImportError: | |||
PYDANTIC_METADATA_KEY = "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also I think it is safe to add a default to false 😊
so
IS_PYDANTIC_V1 = False
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IS_PYDANTIC_V1
is used in if-else
. Should I update it to if-elif
and also set (and check in elif) IS_PYDANTIC_V2=False
? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant only in the expect except ImportError:
if we can't import pydantic it means we don't have it installed, so the default for IS_PYDANTIC_V1
doesn't matter that much :)
0f50166
to
ad2dbb8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
This should fix import error in strawberry.ext.mypy_plugin for users who don't use pydantic introduced in latest version. Hopefully the new location of the import is fine.
Error importing plugin "strawberry.ext.mypy_plugin": No module named 'pydantic'