How to use: Tuple -> Collections.unmodifiableList(ArrayList)

29 views
Skip to first unread message

Felix Schulte-Langforth

unread,
Jan 10, 2022, 11:04:31 AM1/10/22
to Jep Project

Hello everyone,

i'm new to JEP but integrated it more or less successfully to my project.

Following Setup:
- I have the following function signature in my python code: 
  def
coolFunction(self, some_id: int) -> typing.Tuple | None:
- In my Java test class, I created a JEP SubInterpreter and exec some python code which creates the object that obtain this coolFunction.

My problem is that I do not know how to deal with the python Tuple. From https://github.com/ninia/jep/wiki/How-Jep-Works I know it must be Collections.unmodifiableList(ArrayList).

So I tried a lot (even stuff that is nonsense) but I was no successful casting the python Tuple to something I can work on. My last try:

List result = (List) ((PyCallable) client.getAttr("coolFunction")).callAs(List.class, id);

-> which results in:
"jep.JepException: <class 'TypeError'>: Expected java.util.List but received a set.
[...]
Caused by: jep.JepException: <class 'TypeError'>: Expected java.util.List but received a set.
        at jep.python.PyCallable.call(Native Method)
        at jep.python.PyCallable.callAs(PyCallable.java:107)
"

Best regards
Felix
Reply all
Reply to author
Forward
0 new messages