Skip to content

Commit

Permalink
use model_construct to prevent validation
Browse files Browse the repository at this point in the history
  • Loading branch information
RLKRo committed Oct 23, 2024
1 parent 27755ce commit 44bf144
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion chatsky/messengers/telegram/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ async def _on_event(self, update: Update, _: Any, create_message: Callable[[Upda
data_available = update.message is not None or update.callback_query is not None
if update.effective_chat is not None and data_available:
message = create_message(update)
message.origin = Origin(original_message=update, origin_interface=self.id)
message.origin = Origin.model_construct(original_message=update, origin_interface=self.id)
resp = await self._pipeline_runner(message, update.effective_chat.id)
if resp.last_response is not None:
await self.cast_message_to_telegram_and_send(
Expand Down
2 changes: 1 addition & 1 deletion tests/core/test_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def test_attachment_serialize(self, attachment: DataAttachment):
def test_field_serializable(self, random_original_message: UnserializableObject):
message = Message(text="sample message")
message.misc = {"answer": 42, "unserializable": random_original_message}
message.origin = Origin(original_message=random_original_message)
message.origin = Origin.model_construct(original_message=random_original_message)
message.some_extra_field = random_original_message
message.other_extra_field = {"unserializable": random_original_message}
serialized = message.model_dump_json()
Expand Down
2 changes: 1 addition & 1 deletion tests/messengers/telegram/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def cast_dict_to_happy_step(dictionary: Dict, update_only: bool = False) -> Unio
update = eval(step["update"], imports)
if not update_only:
received = Message.model_validate(step["received_message"])
received.origin = Origin(original_message=update)
received.origin = Origin.model_construct(original_message=update)
response = Message.model_validate(step["response_message"])
path_steps += [(update, received, response, step["response_functions"])]
else:
Expand Down

0 comments on commit 44bf144

Please sign in to comment.