-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Run python -m mypy .
formfyxer/pdf_wrangling.py:1110: error: Item "str" of "Union[str, BinaryIO, Mat]" has no attribute "shape" [union-attr]
formfyxer/pdf_wrangling.py:1110: error: Item "BinaryIO" of "Union[str, BinaryIO, Mat]" has no attribute "shape" [union-attr]
formfyxer/pdf_wrangling.py:1158: error: Item "str" of "Union[str, BinaryIO, Mat]" has no attribute "shape" [union-attr]
formfyxer/pdf_wrangling.py:1158: error: Item "BinaryIO" of "Union[str, BinaryIO, Mat]" has no attribute "shape" [union-attr]
formfyxer/tests/test_lit_explorer.py:47: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked]
looks like the problem is that we re-use the variable img
-- starts as a string and gets turned into a cv2 object. so typing is messed up.
def get_possible_radios(img: Union[str, BinaryIO, cv2.Mat]):
"""Even though it's called "radios", it just gets things shaped like circles, not
doing any semantic analysis yet."""
if isinstance(img, str):
# 0 is for the flags: means nothing special is being used
img = cv2.imread(img, 0)
if isinstance(img, BinaryIO):
img = cv2.imdecode(np.frombuffer(img.read(), np.uint8), 0)
rows = img.shape[0]