fix: Guard against attribute errors in TesseractOcrModel __del__ (#1494)
This moves the initialization of the `reader` and `script_readers` attributes to before we attempt to import tesserocr, so that when later accessing these attributes in the garbage collection method `__del__` the attributes exist. This requires changing the typing of the `script_readers` dict value to `Any` because we cannot yet reference its actual strong type, since it's a tesserocr value. This prevents throwing an exception during garbage collection for cases where the TesseractOcrModel instance didn't properly initialize, like when it throws an `ImportError` during its initializer. Signed-off-by: Ben Browning <bbrownin@redhat.com>
B
Ben Browning committed
4ab7e9ddfb9d8fd0abc483efb70e701447a602c5
Parent: cc45396
Committed by GitHub <noreply@github.com>
on 4/30/2025, 3:51:33 PM