How can I make the autocomplete know about pseudofields in a class?
已回答
For example, my model Object has a pseudo-field called photos of type List[ObjectPhoto]. The field is generated by the ORM library I use, so there is no manually written @property or something in the code. So, PyCharm never understands that the expression object.photos[0] is of type ObjectPhoto and does not show any useful completion.
How can I document this pseudo field for PyCharm?
请先登录再写评论。
Hi Max,
It can be achieved by using type hints. You could either create a separate .pyi stub with an auxiliary definition of this class that contains all such generated fields or just put them directly in the original class itself. I mean something like the following:
Thank you. I didn't know about the stub files at all.