I often have a situation where I make the assignment with exec, like so:
...
exec(
"someClassInstance = someMapper({someInfo})".format(someInfo=someInfo),
globals(),
)
Where someClassInfo
is an instance of SomeClass
.
and then I use someClassInstance
, like so:
...
someVar = someClassInstance.someMethod() # type: ignore
All of that works just fine and I accomplish what I want.
But, from a reading perspective and from the IDE's (in my case, emacs+pyright) perspective, the (non-run-time) type of someClassInstance is not known.
So, I add that "# type: ignore".
But, instead, I want to somehow use python 3's type hinting to make it known that someClassInstance is of type SomeClass (or one of its ancestors).
Is that possible?