Skip to content

Commit

Permalink
Fixing tuple in yaml bug
Browse files Browse the repository at this point in the history
  • Loading branch information
bohdanbobrowski committed Dec 20, 2024
1 parent f73ba93 commit d699625
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 1 addition & 4 deletions blog2epub/common/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,5 @@ def save(self, data: ConfigurationModel | None = None):
data = self.data
data = self._save_history(data)
with open(self.settings_file, "w") as outfile:
try:
data_dict = data.model_dump()
except AttributeError:
data_dict = data.dict()
data_dict = data.model_dump()
yaml.dump(data_dict, outfile, default_flow_style=False)
6 changes: 5 additions & 1 deletion blog2epub/models/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from dataclasses import field
from pathlib import Path

from pydantic import BaseModel
from pydantic import BaseModel, field_serializer

example_blogs = [
"http://archaia-ellada.blogspot.com",
Expand Down Expand Up @@ -49,6 +49,10 @@ class ConfigurationModel(BaseModel):
email: str = ""
version: str = ""

@field_serializer("images_size")
def serialize_images_size(self, images_size: tuple[int, int], _info):
return [images_size[0], images_size[1]]

def __init__(self, **kwargs) -> None:
super().__init__(**kwargs)
if self.url == "":
Expand Down

0 comments on commit d699625

Please sign in to comment.