问题
My goal is to have autocomplete in the Pycharm Editor (in Python Console it works fine) for arguments used by pytransition module. (Some background info about the module here)
The idea is to use the recipe mentioned on PyCharm forum in regard to dynamic code: related pyi stub file with type annotations for the class.
That works well if I define the attribute like this:
# class.pyi
class Model(object):
evaporate = None
# class.py
But that doesn't work if I try to define the attributes dynamically, in the manner described here:
# class.pyi
class Model(object):
for x in ['ionize', 'melt']:
locals()[x] = None
What could be the reason and how to overcome that?
来源:https://stackoverflow.com/questions/60209508/type-annotations-with-pyi-file-in-pycharm-doesnt-work-for-dynamic-attributes