Skip to content

Commit

Permalink
simplifies code a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
willi-mueller committed Aug 20, 2024
1 parent a9d1775 commit 605461c
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions dlt/extract/incremental/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,26 +156,19 @@ def find_cursor_value(self, row: TDataItem) -> Any:

return row_value


def _value_at_cursor_path(self, row: TDataItem):
row_value = None
def _value_at_cursor_path(self, row: TDataItem) -> Optional[TDataItem]:
try:
row_value = row.get(self.cursor_path)
return row.get(self.cursor_path)
except AttributeError:
# supports Pydantic models and other classes
row_value = getattr(row, self.cursor_path)
return row_value

return getattr(row, self.cursor_path)

def _contains_cursor_path(self, row: TDataItem) -> bool:
has_field = None
try:
has_field = self.cursor_path in row.keys()
return self.cursor_path in row.keys()
except AttributeError:
# supports Pydantic models and other classes
has_field = hasattr(row, self.cursor_path)
return has_field

return hasattr(row, self.cursor_path)

def __call__(
self,
Expand Down

0 comments on commit 605461c

Please sign in to comment.