You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It will work when in PyCharm's Python Console, but in python source code, when define the MetaDict with existed dict as input parameter or use __setitem__ annotation assignment. This item will not listed in auto-complete list for the code afterward.
The MetaDict is not in memory. Maybe statically auto-complete need to be implement in another approach. collections.namedtuple received its field from parameter as an Iterable of string. But it can make PyCharm auto-complete works statically. May be ideas from collections.namedtuple can inspire the design of MetaDict.
Thanks for the input. I checked the source code of collections.namedtuple and they essentially create an entire class object with its namespace on the fly, which is probably why PyCharm can introspect the class from within the code editor and offer auto-complete functionality.
It is an interesting approach and if I find the time I will look deeper into it. However, I cannot promise I'll get to it anytime soon since it likely takes more time and involves a complete refactor/rewrite of MetaDict.
If you or someone else wants to give it a shot, I am always open for pull requests in the meantime.
hey! i did an experiment about collections.namedtuple. i copied the namedtuple function to my python lib file (such as my_tuple.py) , and try to use it in my other source code, but PyCharm auto-complete didnt work like the collections.namedtuple, so did the vscode. @evan0greenup
So this auto-completion seems to be done for the function collections.namedtuple of the python standard library. Pycharm only analyzes the parameters of the external call and starts to complete the work.
Due to time constraints, I haven't tested it in depth. more testing may be needed.
I think the feasible solution is to make a Pycharm plug-in, but it may be more complicated. @LarsHill
It will work when in PyCharm's Python Console, but in python source code, when define the
MetaDict
with existed dict as input parameter or use__setitem__
annotation assignment. This item will not listed in auto-complete list for the code afterward.The
MetaDict
is not in memory. Maybe statically auto-complete need to be implement in another approach.collections.namedtuple
received its field from parameter as anIterable
of string. But it can make PyCharm auto-complete works statically. May be ideas fromcollections.namedtuple
can inspire the design ofMetaDict
.What is your opinion? @LarsHill
The text was updated successfully, but these errors were encountered: