jnhyperion / HyperRobotFrameworkPlugin

Robot Framework plugin for PyCharm.
30 stars 4 forks source link

Support for Library imports, when it's a python package #80

Open myjniak opened 3 months ago

myjniak commented 3 months ago

Suppose we have this kind of basic python package: image where robot_interface.py contains class MyModuleB and __init__.py from robot_interface imports MyModuleB.

Robot Framework fully supports that scenario, but the plugin does not.

So, when looking for the correct class in the imported Library, the plugin would also have to look into subimports. image

Please also refer to the full example here to reproduce the issue: https://github.com/myjniak/hyper-robot-issue

jnhyperion commented 3 months ago

I also noticed this issue before, unfortunately, I didn't find a proper way to resolve it.

To me, it's an edge case, because in your module name is the same with kw class name MyModuleB and robot is using the name string to find the kw.

Suppose your modify your module name to foo:

lib
    ->   foo
                -> __init__.py
                -> robot_interface.py

when you import lib:

Library    lib.foo

robot will not find any kw. The correct import way should be:

Library    lib.foo.ModuleB
Library    lib.foo.ModuleX
myjniak commented 3 months ago

So, instead of:

Library   Package.Subpackage

we can do this:

Library   Package.Subpackage.Module.Class

I think for the sake of good IDE navigation, we will use that longer syntax for now :) Thanks for the nice hint!