Oops, you're right, thank you. I just assumed this behaviour of "#type: ignore" for some reason, and didn't even check it, shame on me. So, your answer has almost solved my problem. The only issue left is (in case of existing optional_module), mypy gives the following error:
main.py:2: error: Unused "type: ignore" comment [unused-ignore]
import optional_module # type: ignore[import-not-found]
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I see it's the result of enabled flag warn_unused_ignores in my config. I can just turn it off, but wouldn't like to do it globally. Is it possible to disable it just for my instance, without altering the global mypy INI file?