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

chore(deps): add pydantic type validation #21

Merged
merged 1 commit into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 131 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ bech32 = "^1.2.0"
pycryptodome = "^3.20.0"
pyjwt = "^2.8.0"
eciespy = "^0.4.2"
pydantic = "^2.8.0"

[tool.poetry.group.dev.dependencies]
pytest = "^8.2.2"
Expand Down
5 changes: 2 additions & 3 deletions src/babble/auth.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
from dataclasses import dataclass
from datetime import datetime, timezone
from typing import Optional, Tuple

import jwt
import requests
from pydantic import BaseModel

from .config import AUTH_SERVER, DEFAULT_REQUEST_TIMEOUT
from .crypto.identity import Identity
from .encoding import from_base64, to_base64


@dataclass
class TokenMetadata:
class TokenMetadata(BaseModel):
address: str
public_key: str
issued_at: datetime
Expand Down
5 changes: 2 additions & 3 deletions src/babble/client.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from dataclasses import dataclass
from datetime import datetime, timedelta, timezone
from typing import List

import bech32
from pydantic import BaseModel

from .auth import authenticate
from .crypto.exceptions import RoutingError
Expand All @@ -24,8 +24,7 @@ def _validate_address(address: str):
raise ValueError(f"Bad delegate address {address}")


@dataclass
class Message:
class Message(BaseModel):
id: str
sender: str
target: str
Expand Down
5 changes: 2 additions & 3 deletions src/babble/mailbox.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from dataclasses import dataclass
from datetime import datetime, timezone
from typing import Any, Dict, List, Optional

import requests
from pydantic import BaseModel

from .config import MEMORANDUM_SERVER

Expand Down Expand Up @@ -115,8 +115,7 @@ def dispatch_messages(token: str, messages: List[str]):
)


@dataclass
class RawMessage:
class RawMessage(BaseModel):
id: str
group_id: str
sender: str
Expand Down
Loading