Skip to content
Draft
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
33 changes: 11 additions & 22 deletions paperseek_core/client/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ def to_str(self) -> str:

def to_json(self) -> str:
"""Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict())
return self.model_dump_json(by_alias=True, exclude_unset=True)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using 'exclude_unset=True' in 'to_json()' creates an inconsistency with 'to_dict()', which uses 'exclude_none=True'. For example, if a field is explicitly initialized to 'None', 'to_dict()' will exclude it, whereas 'model_dump_json(exclude_unset=True)' will include it. To ensure consistent serialization behavior between 'to_dict()' and 'to_json()', use 'exclude_none=True' instead.

Suggested change
return self.model_dump_json(by_alias=True, exclude_unset=True)
return self.model_dump_json(by_alias=True, exclude_none=True)


@classmethod
def from_json(cls, json_str: str) -> Self:
Expand Down Expand Up @@ -95,8 +94,7 @@ def to_str(self) -> str:

def to_json(self) -> str:
"""Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict())
return self.model_dump_json(by_alias=True, exclude_unset=True)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using 'exclude_unset=True' in 'to_json()' creates an inconsistency with 'to_dict()', which uses 'exclude_none=True'. For example, if a field is explicitly initialized to 'None', 'to_dict()' will exclude it, whereas 'model_dump_json(exclude_unset=True)' will include it. To ensure consistent serialization behavior between 'to_dict()' and 'to_json()', use 'exclude_none=True' instead.

Suggested change
return self.model_dump_json(by_alias=True, exclude_unset=True)
return self.model_dump_json(by_alias=True, exclude_none=True)


@classmethod
def from_json(cls, json_str: str) -> Self:
Expand Down Expand Up @@ -164,8 +162,7 @@ def to_str(self) -> str:

def to_json(self) -> str:
"""Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict())
return self.model_dump_json(by_alias=True, exclude_unset=True)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using 'exclude_unset=True' in 'to_json()' creates an inconsistency with 'to_dict()', which uses 'exclude_none=True'. For example, if a field is explicitly initialized to 'None', 'to_dict()' will exclude it, whereas 'model_dump_json(exclude_unset=True)' will include it. To ensure consistent serialization behavior between 'to_dict()' and 'to_json()', use 'exclude_none=True' instead.

Suggested change
return self.model_dump_json(by_alias=True, exclude_unset=True)
return self.model_dump_json(by_alias=True, exclude_none=True)


@classmethod
def from_json(cls, json_str: str) -> Self:
Expand Down Expand Up @@ -232,8 +229,7 @@ def to_str(self) -> str:

def to_json(self) -> str:
"""Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict())
return self.model_dump_json(by_alias=True, exclude_unset=True)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using 'exclude_unset=True' in 'to_json()' creates an inconsistency with 'to_dict()', which uses 'exclude_none=True'. For example, if a field is explicitly initialized to 'None', 'to_dict()' will exclude it, whereas 'model_dump_json(exclude_unset=True)' will include it. To ensure consistent serialization behavior between 'to_dict()' and 'to_json()', use 'exclude_none=True' instead.

Suggested change
return self.model_dump_json(by_alias=True, exclude_unset=True)
return self.model_dump_json(by_alias=True, exclude_none=True)


@classmethod
def from_json(cls, json_str: str) -> Self:
Expand Down Expand Up @@ -298,8 +294,7 @@ def to_str(self) -> str:

def to_json(self) -> str:
"""Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict())
return self.model_dump_json(by_alias=True, exclude_unset=True)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using 'exclude_unset=True' in 'to_json()' creates an inconsistency with 'to_dict()', which uses 'exclude_none=True'. For example, if a field is explicitly initialized to 'None', 'to_dict()' will exclude it, whereas 'model_dump_json(exclude_unset=True)' will include it. To ensure consistent serialization behavior between 'to_dict()' and 'to_json()', use 'exclude_none=True' instead.

Suggested change
return self.model_dump_json(by_alias=True, exclude_unset=True)
return self.model_dump_json(by_alias=True, exclude_none=True)


@classmethod
def from_json(cls, json_str: str) -> Self:
Expand Down Expand Up @@ -376,8 +371,7 @@ def to_str(self) -> str:

def to_json(self) -> str:
"""Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict())
return self.model_dump_json(by_alias=True, exclude_unset=True)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using 'exclude_unset=True' in 'to_json()' creates an inconsistency with 'to_dict()', which uses 'exclude_none=True'. For example, if a field is explicitly initialized to 'None', 'to_dict()' will exclude it, whereas 'model_dump_json(exclude_unset=True)' will include it. To ensure consistent serialization behavior between 'to_dict()' and 'to_json()', use 'exclude_none=True' instead.

Suggested change
return self.model_dump_json(by_alias=True, exclude_unset=True)
return self.model_dump_json(by_alias=True, exclude_none=True)


@classmethod
def from_json(cls, json_str: str) -> Self:
Expand Down Expand Up @@ -545,8 +539,7 @@ def to_str(self) -> str:

def to_json(self) -> str:
"""Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict())
return self.model_dump_json(by_alias=True, exclude_unset=True)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using 'exclude_unset=True' in 'to_json()' creates an inconsistency with 'to_dict()', which uses 'exclude_none=True'. For example, if a field is explicitly initialized to 'None', 'to_dict()' will exclude it, whereas 'model_dump_json(exclude_unset=True)' will include it. To ensure consistent serialization behavior between 'to_dict()' and 'to_json()', use 'exclude_none=True' instead.

Suggested change
return self.model_dump_json(by_alias=True, exclude_unset=True)
return self.model_dump_json(by_alias=True, exclude_none=True)


@classmethod
def from_json(cls, json_str: str) -> Self:
Expand Down Expand Up @@ -619,8 +612,7 @@ def to_str(self) -> str:

def to_json(self) -> str:
"""Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict())
return self.model_dump_json(by_alias=True, exclude_unset=True)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using 'exclude_unset=True' in 'to_json()' creates an inconsistency with 'to_dict()', which uses 'exclude_none=True'. For example, if a field is explicitly initialized to 'None', 'to_dict()' will exclude it, whereas 'model_dump_json(exclude_unset=True)' will include it. To ensure consistent serialization behavior between 'to_dict()' and 'to_json()', use 'exclude_none=True' instead.

Suggested change
return self.model_dump_json(by_alias=True, exclude_unset=True)
return self.model_dump_json(by_alias=True, exclude_none=True)


@classmethod
def from_json(cls, json_str: str) -> Self:
Expand Down Expand Up @@ -695,8 +687,7 @@ def to_str(self) -> str:

def to_json(self) -> str:
"""Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict())
return self.model_dump_json(by_alias=True, exclude_unset=True)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using 'exclude_unset=True' in 'to_json()' creates an inconsistency with 'to_dict()', which uses 'exclude_none=True'. For example, if a field is explicitly initialized to 'None', 'to_dict()' will exclude it, whereas 'model_dump_json(exclude_unset=True)' will include it. To ensure consistent serialization behavior between 'to_dict()' and 'to_json()', use 'exclude_none=True' instead.

Suggested change
return self.model_dump_json(by_alias=True, exclude_unset=True)
return self.model_dump_json(by_alias=True, exclude_none=True)


@classmethod
def from_json(cls, json_str: str) -> Self:
Expand Down Expand Up @@ -761,8 +752,7 @@ def to_str(self) -> str:

def to_json(self) -> str:
"""Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict())
return self.model_dump_json(by_alias=True, exclude_unset=True)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using 'exclude_unset=True' in 'to_json()' creates an inconsistency with 'to_dict()', which uses 'exclude_none=True'. For example, if a field is explicitly initialized to 'None', 'to_dict()' will exclude it, whereas 'model_dump_json(exclude_unset=True)' will include it. To ensure consistent serialization behavior between 'to_dict()' and 'to_json()', use 'exclude_none=True' instead.

Suggested change
return self.model_dump_json(by_alias=True, exclude_unset=True)
return self.model_dump_json(by_alias=True, exclude_none=True)


@classmethod
def from_json(cls, json_str: str) -> Self:
Expand Down Expand Up @@ -844,8 +834,7 @@ def to_str(self) -> str:

def to_json(self) -> str:
"""Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict())
return self.model_dump_json(by_alias=True, exclude_unset=True)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using 'exclude_unset=True' in 'to_json()' creates an inconsistency with 'to_dict()', which uses 'exclude_none=True'. For example, if a field is explicitly initialized to 'None', 'to_dict()' will exclude it, whereas 'model_dump_json(exclude_unset=True)' will include it. To ensure consistent serialization behavior between 'to_dict()' and 'to_json()', use 'exclude_none=True' instead.

Suggested change
return self.model_dump_json(by_alias=True, exclude_unset=True)
return self.model_dump_json(by_alias=True, exclude_none=True)


@classmethod
def from_json(cls, json_str: str) -> Self:
Expand Down
Loading