Python Completion List only shows static module items

SyntaxEditor Python Language Add-on for WPF Forum

Posted 2 years ago by Jack
Version: 22.1.0
Platform: .NET 4.8
Environment: Windows 10 (64-bit)


It seems that the python completion list does not show all items for modules.  For example, consider the standard python module - it does show functions that are defined in the module such as "walk" or "renames" but it does not show functions that are added at runtime when the module is imported such as "symlink", "rmdir", "read".  (if one looks in one can observe this distinction between the two sets). Compare this to say the built in python IDLE which shows everything the os module would have at runtime once imported.

Is there a way to add these missing functions?  i.e. show all functions that would be in os.__dict__? Either by overriding a class, etc?


Comments (1)

Posted 2 years ago by Actipro Software Support - Cleveland, OH, USA

Hi Jack,

The Python Languages Add-on has a syntax parser but it doesn't contain a Python interpreter, so unfortunately it won't know about functions dynamically-added at run-time.

While there isn't really a way to alter the data our parser reads from the .py files, you can have control over what shows for IntelliPrompt.  For instance, you can unregister the PythonCompletionProvider service from the language service and then make a class that inherits PythonCompletionProvider, and override its OnSessionOpening method.  That method fires right before a completion session is opened, and has all the items it will show, along with a contextual object (in this case a PythonContext object).  You might be able to look at that object and see if it's for an imported "os" module, and if so, add more completion items.  Then register your custom completion provider as a syntax language service.

Actipro Software Support

The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.