Skip to content

Commit

Permalink
Format with isort & black
Browse files Browse the repository at this point in the history
  • Loading branch information
MHHukiewitz committed Nov 25, 2023
1 parent ca0f174 commit 5e5fb7a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
16 changes: 5 additions & 11 deletions aleph_message/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,7 @@
from hashlib import sha256
from json import JSONDecodeError
from pathlib import Path
from typing import (
Any,
Dict,
List,
Literal,
Optional,
Type,
Union, TypeVar, cast,
)
from typing import Any, Dict, List, Literal, Optional, Type, TypeVar, Union, cast

from pydantic import BaseModel, Extra, Field, validator
from typing_extensions import TypeAlias
Expand Down Expand Up @@ -204,7 +196,9 @@ class BaseMessage(BaseModel):
size: Optional[int] = Field(
default=None, description="Size of the content"
) # Almost always present
time: datetime.datetime = Field(description="Unix timestamp or datetime when the message was published")
time: datetime.datetime = Field(
description="Unix timestamp or datetime when the message was published"
)
item_type: ItemType = Field(description="Storage method used for the content")
item_content: Optional[str] = Field(
default=None,
Expand Down Expand Up @@ -349,7 +343,7 @@ class InstanceMessage(BaseMessage):
]


T = TypeVar('T', bound=AlephMessage)
T = TypeVar("T", bound=AlephMessage)

AlephMessageType: TypeAlias = Type[T]

Expand Down
7 changes: 4 additions & 3 deletions aleph_message/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from aleph_message.exceptions import UnknownHashError
from aleph_message.models import (
AggregateMessage,
AlephMessage,
ForgetMessage,
InstanceMessage,
ItemType,
Expand All @@ -26,7 +27,7 @@
create_message_from_file,
create_message_from_json,
create_new_message,
parse_message, AlephMessage,
parse_message,
)
from aleph_message.tests.download_messages import MESSAGES_STORAGE_PATH

Expand Down Expand Up @@ -290,10 +291,10 @@ def test_create_new_message():
assert new_message_1
assert new_message_1.type == MessageType.post
# Check that the time was converted to a datetime
assert new_message_1.time.isoformat() == '2021-07-07T10:04:47.017000+00:00'
assert new_message_1.time.isoformat() == "2021-07-07T10:04:47.017000+00:00"

# The time field can be either a float or a datetime as string
message_dict["time"] = '2021-07-07T10:04:47.017000+00:00'
message_dict["time"] = "2021-07-07T10:04:47.017000+00:00"
new_message_2 = create_message_from_json(
json.dumps(message_dict), factory=PostMessage
)
Expand Down

0 comments on commit 5e5fb7a

Please sign in to comment.