Skip to content

Commit ac0371b

Browse files
committed
Fixup mypy
fix function search_header_from_body_bbox
1 parent c2f94d2 commit ac0371b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

camelot/parsers/network.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,15 @@ def search_header_from_body_bbox(
238238
textline_center = 0.5 * (textline.x0 + textline.x1)
239239
if textline.y0 > top and left < textline_center < right:
240240
all_above.append(textline)
241-
closest_above = min(all_above, key=lambda tl: tl.y0, default=None)
241+
closest_above = None
242+
all_above = [
243+
tl
244+
for tl in textlines
245+
if tl.y0 > top and left < 0.5 * (tl.x0 + tl.x1) < right
246+
]
247+
248+
if all_above:
249+
closest_above = min(all_above, key=lambda tl: tl.y0)
242250

243251
if closest_above and closest_above.y0 < top + max_v_gap:
244252
# We have a candidate cell that is within the correct

0 commit comments

Comments
 (0)