Regarding the Completion List for Python Language in SyntaxEditor

SyntaxEditor Python Language Add-on for WPF Forum

The latest build of this product (v25.1.3) was released 25 days ago, which was before this thread was created.
Posted 3 days ago by miles
Version: 24.1.2
Avatar
We are currently developing a Python script editor with IntelliSense functionality for a WPF application.
We would like the editor to support code completion equivalent to the `Python extension for Visual Studio Code` as much as possible.
Note that in this application, the Python standard module paths are not set in the SearchPaths of the Python project to allow operation regardless of whether Python is installed.

Question 1
 
Currently, when defining a Python script like the following, we are unable to display members defined by the type of `t` in the completion list for the loop variable ('t').
Is there any way to display members defined by the type of `t` in the completion list?

```py
# Defining a Class
class MyType:

    def __init__(self, a):
        self.propA = a

    def set_propA(self, v):
        self.propA = v

    def get_propA(self):
        return self.propA


# A list of instances of the defined class
myTypeList = [MyType(1), MyType(2), MyType(3)]

#Iterating over the elements of a list
for t in myTypeList:

    # In VSCode (Python extension), when you type "t." here,
    # the members of the MyType class appear in the completion list.
    # However, in SyntaxEditor, the members of the MyType class are not displayed.
    print(t.propA)

```

Question 2
 
Similar to Question 1, when defining a Python script like the following, we are unable to display members defined by the type of `t` in the completion list for the loop variable ('t').
Is it possible to display members defined by the element type in the completion list for loop variables even for custom collection types?

```py
from typing import Iterator

# Defining a Class
class MyType:

    def __init__(self, a):
        self.propA = a

    def set_propA(self, v):
        self.propA = v

    def get_propA(self):
        return self.propA

# Define a collection type of MyType
class MyTypeCollection:
   
    def GetItem(self, index: int) -> MyType:
        pass

    def __iter__(self) -> Iterator[MyType]:
        pass

# Create a collection
my_collection = MyTypeCollection()

#Iterating over the elements of a collection
for t in my_collection:

    # In VSCode (Python extension), when you type "t" here,
    # the members of the MyType class appear in the completion list.
    # However, in SyntaxEditor, the members of the MyType class are not displayed.
    print(t.propA)

```

Question 3
 
When defining classes with an inheritance relationship in a Python script like the following, we are unable to display parent class members in the completion list.
Is there any way to display parent class members in the completion list for elements of subclass types?

```py
# Define a base class
class BaseType:
    propA = "value"

    def execute(self):
        pass

# Define a subclass
class SubType(BaseType):
    propB = "value"

    def can_execute(self):
        return True

# Create an instance of a subclass
t = SubType()

# In VSCode (Python extension), if you type "t" here,
# members of the BaseType class will also appear in the completion list.
# However, in SyntaxEditor, members of the BaseType class are not displayed
#  (members of the SubType class are displayed).
t.execute()

```
 
Thanks in advance!

[Modified 3 days ago]

Comments (1)

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

Hi Miles,

Question 1

Since our add-on doesn't have a full Python interpreter, this would be difficult to know. In theory, couldn't you could put instances of other types in myTypeList as well, either at creation time or dynamically later?

Question 2

This one is more likely to get supported sooner. The issue right now is that our resolver doesn't yet resolve generics like Iterator[T]. We have a note to look more into that in the next round of big updates to the Python add-on, and I'll log your thread here with that.

Question 3

It seems you are on an older version and there have been updates to the add-on in v25.1 releases. At least in our latest codebase here, I am seeing the base class resolve and show its members. Perhaps try updating to the latest v25.1 release and see if that is resolved for you.


Actipro Software Support

Add Comment

Please log in to a validated account to post comments.