Show modules without packages in intelli prompt

SyntaxEditor Python Language Add-on for WPF Forum

Posted 2 years ago by Tobias Lingemann - Software Devolpment Engineer, Vector Informatik GmbH
Version: 21.1.3
Platform: .NET 4.8
Environment: Windows 10 (64-bit)
Avatar

Hi,

to show a python module in the intelli prompt, currently all parent folders (up to the search path) need to have a "__init__.py" file, which makes it a package.

But as we understand the current specification, this is no longer required. We also verified this with Visual Studio Code and the Python 3.9 interpreter. Both do not require the "__init__.py" file to show or use files in sub-folders.

Image the following file structure:
SubFolderA
  - FileA
SubFolderB
  - SubFolderB2
    - FileB
FileC

If I open FileC, I can import "SubFolderA.FileA" or "SubFolderB.SubFolderB2.FileB".


Best regards, Tobias Lingemann.

Comments (3)

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

Hi Tobias,

Thanks for letting us know about that.  It appears support for that was added sometime in the Python v3 lifetime.  We will update our add-on to support it as well.


Actipro Software Support

Posted 2 years ago by Tobias Lingemann - Software Devolpment Engineer, Vector Informatik GmbH
Avatar

Hi,

I have tested the feature with the current 21.1 release and think it is incomplete. Yes, the "__init__.py" file is no longer required, but namspace packages have another nice feature. You can merge the namespaces from multiple search paths. See PEP 420. There "project1" and "project2" are configured as search paths. When typing "parent.child." intelli should show both files "one" and "two".


Best regards, Tobias Lingemann.

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

Hi Tobias,

Supporting multiple directories for a single namespace package is something we don't yet support since it will require numerous API changes in the package-related interfaces and classes.  Right now, it only shows IntelliPrompt for the first match that was made.  In the PEP 420 example, if the search paths were added in the order of "project1" and then "project2", it will currently resolve "parent" to the "parent" folder in project1's hierarchy.

We have a note to look into improving this on the TODO list for the next round of updates for the Python Languages Add-on.  I'll log your request for that feature.


Actipro Software Support

The latest build of this product (v24.1.2) was released 1 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.