Consider the following code:

PyCharm automatically senses that this is a module that could refer to one or more backing libraries.
Is it possible to specify this manually for other module variables as well? Something like the following:
from pyqtgraph.Qt import QtWidgets
QtWidgets: Union[PyQt5.QtWidgets.pyi, PySide2.QtWidgets.pyi] # <-- I want to add this type hint
Behind the scenes, pyqtgraph is dynamically constructing dummy QtWidgets to point to one of several libraries at runtime, but PyCharm doesn't know this. Is there a way for me to manually add that type hint (QtWidgets.pyi) to a module that I import (In this case, pyqtgraph.Qt.QtWidgets)?
I posted here as well, for reference.

As you can see here, it doesn't show me hints for sys.Test, as it doesn't exist.
What you can do - you can use Stubs, aka .pyi files.
i just added a sys.pyi file, [it must be named the same as your module, pyqtgraph.pyi in your case].
it doesn't evaluate the file but uses it to gather type hintings.
the result is

And the content of sys.pyi is:
Test: bytes
You can read about stubs, Here: https://www.jetbrains.com/help/pycharm/stubs.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With