Type of list members cannot be resolved in for loop

SyntaxEditor Python Language Add-on for WPF Forum

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

Hi,

we generate python code that the user can access in the python editor. For example here 'MyStructList' is a generated type, where the method 'copy' returns a list which contains a copy of the elements. However if we want to access the members, the intelli prompt is empty:

from sys_pars import MyStructList

def IntFieldAccess():
  for testVector in MyStructList.copy():
    print(testVector.IntField)

I have tried many different ways to access the members, with or without type hints, but none of them are working. I am also attached to the UnknownReturnTypeReferenceCallback event, but the event args only contain the name of the variable. Not even the module or offset are set. Therefore I see no way to resolve the type myself.

The generated code looks like this:

import RTPython39
from typing import Iterator, Union
class _0_MyStructList_type:
    def __init__(self, name):
        self._qualified_name = name
    class _0_MyStructList_element_type:
        def __init__(self, index: int):
            self._index = index

        @property
        def IntField(self) -> int:
            return RTPython39.get_list_parameter_value_int64("MyStructList.IntField", self._index)

    def copy(self) -> list[_0_MyStructList_element_type]:
        length = RTPython39.get_struct_list_parameter_length(self._qualified_name)
        return [_0_MyStructList_type._0_MyStructList_element_type(i) for i in range(length)]

MyStructList = _0_MyStructList_type("MyStructList")


Best regards, Tobias Lingemann.

Comments (1)

Posted 1 month ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Tobias,

At the moment, the resolver isn't looking at the type annotations for type hint data.  That is something we will put on the TODO list for possible improvement in the future.

We were able to fix the issue with the "textVector" IVariableDefinition created in this scenario not having the DeclaringModule or TypeExpressionTextRange properties filled in.  That fix will be in the next maintenance release and will hopefully help with your UnknownReturnTypeReferenceCallback logic.


Actipro Software Support

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

Add Comment

Please log in to a validated account to post comments.