Skip to content

Commit

Permalink
fix mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
felixdittrich92 committed Aug 24, 2022
1 parent a9ee6f5 commit 0d2826b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
8 changes: 4 additions & 4 deletions doctr/datasets/ic03.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ def __init__(
# x_min, y_min, x_max, y_max
_boxes = [
[
float(rect.attrib["x"]),
float(rect.attrib["y"]),
float(rect.attrib["x"]) + float(rect.attrib["width"]),
float(rect.attrib["y"]) + float(rect.attrib["height"]),
float(rect.attrib["x"]), # type: ignore[list-item]
float(rect.attrib["y"]), # type: ignore[list-item]
float(rect.attrib["x"]) + float(rect.attrib["width"]), # type: ignore[list-item]
float(rect.attrib["y"]) + float(rect.attrib["height"]), # type: ignore[list-item]
]
for rect in rectangles
]
Expand Down
8 changes: 4 additions & 4 deletions doctr/datasets/svt.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ def __init__(
# x_min, y_min, x_max, y_max
_boxes = [
[
float(rect.attrib["x"]),
float(rect.attrib["y"]),
float(rect.attrib["x"]) + float(rect.attrib["width"]),
float(rect.attrib["y"]) + float(rect.attrib["height"]),
float(rect.attrib["x"]), # type: ignore[list-item]
float(rect.attrib["y"]), # type: ignore[list-item]
float(rect.attrib["x"]) + float(rect.attrib["width"]), # type: ignore[list-item]
float(rect.attrib["y"]) + float(rect.attrib["height"]), # type: ignore[list-item]
]
for rect in rectangles
]
Expand Down
6 changes: 4 additions & 2 deletions doctr/models/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,10 @@ def __call__(
if len(boxes) != len(text_preds) or len(boxes) != len(page_shapes):
raise ValueError("All arguments are expected to be lists of the same size")

_orientations = orientations if isinstance(orientations, list) else [None] * len(boxes)
_languages = languages if isinstance(languages, list) else [None] * len(boxes)
_orientations = (
orientations if isinstance(orientations, list) else [None] * len(boxes) # type: ignore[list-item]
)
_languages = languages if isinstance(languages, list) else [None] * len(boxes) # type: ignore[list-item]
if self.export_as_straight_boxes and len(boxes) > 0:
# If boxes are already straight OK, else fit a bounding rect
if boxes[0].ndim == 3:
Expand Down

0 comments on commit 0d2826b

Please sign in to comment.