In trying to upgrade the Twisted package from 20.3.0 to 21.2.0.
After the upgrade, when running Mypy I'm getting the following errors when accessing the reactor (from twisted.internet import reactor):
error: Module has no attribute "run" [attr-defined]
error: Module has no attribute "running" [attr-defined]
error: Module has no attribute "running" [attr-defined]
error: Module has no attribute "callLater" [attr-defined]
error: Module has no attribute "callInThread" [attr-defined]
error: Module has no attribute "callFromThread" [attr-defined]
error: Module has no attribute "spawnProcess" [attr-defined]
error: Module has no attribute "spawnProcess" [attr-defined]
When running Mypy with reveal_type(reactor):
Revealed type is '_importlib_modulespec.ModuleType'
I'm trying to understand what is the best way to handle this situation without just ignoring the errors so I can have the type checking when using the reactor.
Is there a better way to import the reactor? Is there a way to mark the type of the reactor for Mypy? should I cast it to a type every time before using it?