Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
nadolskit committed Sep 16, 2024
1 parent 5ff4022 commit c23161e
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions paperqa/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,9 +604,8 @@ def repopulate_doc_id_from_doi(self) -> None:
if self.doi:
self.doc_id = encode_id(self.doi)

def __add__(
self, other: DocDetails | int
) -> DocDetails: # pylint: disable=too-many-branches
# pylint: disable=too-many-branches
def __add__(self, other: DocDetails | int) -> DocDetails:
"""Merge two DocDetails objects together."""
# control for usage w. Python's sum() function
if isinstance(other, int):
Expand Down Expand Up @@ -656,9 +655,12 @@ def __add__(
# get the latest data
if self_value is None or other_value is None:
merged_data[field] = (
# if self_value is 0, it's evaluated as falsy and will fallback to other_value even if other_value is None
# if self_value is 0, it's evaluated as falsy and will fallback,
# to other_value even if other_value is None
# 0 is a valid value here
self_value if self_value is not None else other_value
self_value
if self_value is not None
else other_value
)
else:
merged_data[field] = max(self_value, other_value)
Expand Down

0 comments on commit c23161e

Please sign in to comment.