-
Notifications
You must be signed in to change notification settings - Fork 5
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
177 upgrade pydantic version #179
base: main
Are you sure you want to change the base?
Changes from all commits
a409433
660762f
4908fbe
e50fabb
29b3a1b
cd2f8e4
a86da5f
fa8e7c8
706f63a
213982b
8894347
5674356
00177ae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,7 +72,7 @@ async def sign_message(self, message: Dict) -> Dict: | |
""" | ||
message = self._setup_sender(message) | ||
signature = await self.sign_raw(get_verification_buffer(message)) | ||
message["signature"] = signature.hex() | ||
message["signature"] = "0x" + signature.hex() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this added here ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, my mistake. Normally, I'll debug to see why the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I found out that with python3>=3.5 .hex() should remove the 0x prefix from the string. |
||
return message | ||
|
||
@abstractmethod | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,7 +52,7 @@ async def from_crypto_host( | |
session = aiohttp.ClientSession(connector=connector) | ||
|
||
async with session.get(f"{host}/properties") as response: | ||
response.raise_for_status() | ||
await response.raise_for_status() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this related to pydantic ? Should this use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not related to pydantic, just saw some warning when lauching the tests, so I tried to fix some of them because it wasn't a lot of work. |
||
data = await response.json() | ||
properties = AccountProperties(**data) | ||
|
||
|
@@ -75,7 +75,7 @@ def private_key(self): | |
async def sign_message(self, message: Dict) -> Dict: | ||
"""Sign a message inplace.""" | ||
async with self._session.post(f"{self._host}/sign", json=message) as response: | ||
response.raise_for_status() | ||
await response.raise_for_status() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same: Is this related to pydantic ? Should this use await or should the implementation not be async ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same: This is not related to pydantic, just saw some warning when lauching the tests, so I tried to fix some of them because it wasn't a lot of work. |
||
return await response.json() | ||
|
||
async def sign_raw(self, buffer: bytes) -> bytes: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -180,7 +180,7 @@ async def get_posts( | |
posts: List[Post] = [] | ||
for post_raw in posts_raw: | ||
try: | ||
posts.append(Post.parse_obj(post_raw)) | ||
posts.append(Post.model_validate(post_raw)) | ||
except ValidationError as e: | ||
if not ignore_invalid_messages: | ||
raise e | ||
|
@@ -467,3 +467,6 @@ async def get_message_status(self, item_hash: str) -> MessageStatus: | |
if resp.status == HTTPNotFound.status_code: | ||
raise MessageNotFoundError(f"No such hash {item_hash}") | ||
resp.raise_for_status() | ||
|
||
data = await resp.json() | ||
return MessageStatus(**data) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was there no There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right. When I initially tested upgrading to Pydantic v2, I encountered an error saying that a return value was required, so I added it. I just checked again, and the error is no longer there, so I may have done it incorrectly. I'll remove it in the next push. |
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.
What is this dependency ?
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.
By moving to pydantic v2, the settings management has been moved to a separate package called pydantic-settings so if we don't import it, it causes some errors