Show only imported modules in intelli

SyntaxEditor Python Language Add-on for WPF Forum

Posted 10 months ago by Tobias Lingemann - Software Devolpment Engineer, Vector Informatik GmbH
Avatar

Hi,

the intelli prompt automatically shows all modules that are available for import.
Other editors like VsCode only show them if they have a corresponding import statement.

I think this would be a nice-to-have feature which reduces the risk for runtime errors.


Best regards, Tobias Lingemann.

Comments (5)

Posted 10 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Tobias,

Can you provide a concrete example with one of our samples and tell us the document code to use, so that we can ensure we're looking at the same thing?  Thanks!


Actipro Software Support

Posted 10 months ago by Tobias Lingemann - Software Devolpment Engineer, Vector Informatik GmbH
Avatar

Sorry, I thought this would be self explanatory. The editor in the sample browser doesn't really help, since only one document can be loaded and you can't configure the search paths there.

Basically to use a function from another Python module, you have to import it first. For example:

import package.module

def MyFunction():
  package.module.function()

If the import statement is missing, the function cannot be used and a runtime error occurs. So it would be better to not show it in the intelli, unless there is a coressponing import statement. Currently the intelli shows them always, since they can be used.

To be clear, I don't see this as a bug, but it would be a nice-to-have feature for the future.


Best regards, Tobias Lingemann.

Posted 10 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Tobias,

The reason I ask is that I am trying a very basic sample like this:

#import json.decoder

json.decoder.py_scanstring

If the import is uncommented, I get IntelliPrompt on all the identifiers on the last line.  If I have the imported commented out like above, I get no IntelliPrompt.

Can you alter the code above to tell us how to reproduce what you see?  Thanks!


Actipro Software Support

Posted 10 months ago by Tobias Lingemann - Software Devolpment Engineer, Vector Informatik GmbH
Avatar

Hi,

the problem starts when you have mutliple packages within the same root-package.
For example I have one import "import a.b" and now the intelli shows everything inside of "a".
To use "a.a" I would need an additional import for that. To use "a.b.c" I would also need an additional import.

In our case this would look like this:

import a.b
import a.b.c

def func():
  a.b.d.method() # fails
  pass

The challenge is probally that sometimes the import statement is hidden in an "__init__.py" file, in which case the current behavior is correct. So you would have to scan and parse these files too.


Best regards, Tobias Lingemann.

Posted 10 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Tobias,

Thank you for the details.  We will log the information on this issue.


Actipro Software Support

The latest build of this product (v22.1.4) was released 22 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.