Skip to content

Commit

Permalink
fix type check
Browse files Browse the repository at this point in the history
  • Loading branch information
unsleepy22 committed Feb 9, 2025
1 parent 2e31705 commit d46bc7e
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions trafilatura/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,14 +469,13 @@ def is_in_table_cell(elem: _Element) -> bool:

def is_last_element_in_cell(elem: _Element) -> bool:
'''Check whether an element is the last element in table cell'''
if not is_in_table_cell(elem): # shortcut
return False

if elem.tag == "cell":
children = list(elem)
if not children:
return True
else:
return children[-1] == elem
return children and children[-1] == elem
elif is_in_table_cell(elem):
cell = elem.getparent()
children = list(cell)

children = list(elem.getparent())
return children and children[-1] == elem
return False

0 comments on commit d46bc7e

Please sign in to comment.