Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PyCharm static auto-completion not work #4

Open
evan0greenup opened this issue Aug 4, 2022 · 2 comments
Open

PyCharm static auto-completion not work #4

evan0greenup opened this issue Aug 4, 2022 · 2 comments

Comments

@evan0greenup
Copy link

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.

What is your opinion? @LarsHill

@LarsHill
Copy link
Owner

LarsHill commented Aug 8, 2022

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.

@LincolnYe
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants