Although I prefer to use type hints when possible, using assert isinstance(...)
could be an alternative solution/work-around to achieve the same benefits (that is: proper syntax highlighting and auto-completion in the IDE).
I don't know if this works in PyCharm, but it does work in Visual Studio Code.
for x, y, z in range(5):
assert isinstance(i, int)
# Now VS Code knows the type of `i`, so syntax highlighting
# and auto-completion do work as intended :-)
Obviously, adding the assert
has an effect on the code, and this might be a Good Thing or a Bad Thing, depending on your use case.
It is definitely not the same as type-hinting, but as a side effect it seems to have the same benefits.