robotcodedev / robotcode

RobotFramework support for Visual Studio Code
https://robotcode.io
Apache License 2.0
168 stars 13 forks source link

[QUESTION] Impossible to import many Library from same module #169

Closed massicotjgab closed 9 months ago

massicotjgab commented 9 months ago

Description Hi, In a .resource file, I try to use several "Library" import from the same python file, but only the first one is taken into account.

Files and path My "robotcode.robot.pythonPath" : [ project/Resources/Libraries, project/Resources ] My_Py_File.py location: project/Resources/Libraries/dir1/dir2/My_Py_File.py My_Resource.resource path: project/Resources/Dir/My_Resource.resource

Content

class MyClassB: def something_else()

- My .resource file

Settings

Library dir1.dir2.My_Py_File.MyClassA AS A Library dir1.dir2.My_Py_File.MyClassB AS B



***Result***

- When I put my mouse on B to check content, it give me: "A" description
- When I try to use B in file, autocompletion give me "Something" instead of "Something Else"
- All usage of `B.Something Else` failed with `MyClassA has no keyword named Something Else`

***Workaround***

Extension Robot Framework Language Server works properly with the exact same code for this case

**Desktop:**
- VS Code Version [e.g. 1.60] => 1.83.1
- RobotCode Version [e.g. 0.3.2] => 0.61.6
- OS: [e.g. Windows, Linux] => Ubuntu 22.04.3 LTS
- Python Version [e.g. 3.9.7] => 3.10.12 64-bit
- RobotFramework Version [e.g. 4.0.0] => 6.1.1
- Additional tools like robocop, robotidy => robotidy==4.3.0, robotframework-robocop==3.1.1
d-biehl commented 9 months ago

Yes, this is not supported, I need a little more time to investigate this further.

The question I ask myself, though, is why are you doing this? The way described in the documentation is one library class per file. Why would you want to have 2 in one file?

massicotjgab commented 9 months ago

Hi, Thank you for your response. Libraries and modules are basic features in Python, that’s why we use it. We used to use Robotframework Langage Server before to try the Robotcode extension, and this worked perfectly. We tried your extension because some features are better but we need this behaviour on our side. In an industrial way, we have to test many modules, boards etc, each with many features to test. So modules and libraries are very useful. In my opinion, you should think about adding it to your to-do-list. For us, I guess that means going backward to RLS.

Thank you for your quick response! Please let me know if you add this feature!

d-biehl commented 9 months ago

had a little time during a boring meeting... ;-)

Can you try the latest version of RobotCode (0.62).

What doesn't work yet and is not so easy to implement is that the classes of a module show up at the completion of library imports. For this I will create later but again a separate issue.

massicotjgab commented 9 months ago

Thank you! We tried it and it seems to work properly!

Can you explain what exactly is not implemented? I’m not sure to understand what you mean in your latest paragraph.

Thank you again, we may stay with your extension after all 🙂

d-biehl commented 9 months ago

I mean the intellisense completion, if you type a . after the module name where you load your library:

*** Settings ***
Library    my_module   # << type the `.` here

Normally I would expect a list to appear showing me the possible classes/libraries.

massicotjgab commented 9 months ago

Aaah ok! Yes it will be very useful. Thank you for your kind support!

d-biehl commented 9 months ago

ok, thanks for reporting this ;-) Then I close this issue.