robotcode
robotcode copied to clipboard
[Enhancement] Support New RF 7.2 Library Import Behavior via @library Decorator
Describe the bug When developing custom Python libraries for Robot Framework using the RobotCode VS Code extension, we observe that keyword navigation using "Ctrl+Click" to jump to keyword definitions breaks under the following circumstances:
- The Python library file name uses lower_snake_case (e.g.,
my_library.py), compliant with PEP 8 module naming. - The class inside the file uses CapWords (PascalCase) (e.g.,
MyLibrary), compliant with PEP 8 class naming. - The class is decorated with Robot Framework's official
@librarydecorator (introduced in RF 3.2) to explicitly mark it as a Robot Framework library.
Despite these supported and recommended patterns, RobotCode fails to resolve and allow "Ctrl+Click" navigation from Robot Framework test cases to keyword implementations inside the Python file.
Steps To Reproduce
- Create a Python file
my_library.pydefining a class with a different PascalCase name, decorated with@library, e.g.:
from robot.api.deco import library, keyword
@library(scope='GLOBAL', version='1.0')
class MyLibrary:
@keyword
def example_keyword(self):
"""An example keyword."""
pass
- Import this library in a Robot Framework file:
*** Settings ***
Library path/to/my_library.py
- Use the keyword
Example Keywordin a test case. - Attempt to "Ctrl+Click" on the keyword name in VS Code with RobotCode extension enabled.
Expected behavior
- RobotCode should support "Ctrl+Click" navigation to keywords implemented in a Python class decorated with
@library, even if the class name does not match the Python file name. - RobotCode should correctly recognize keywords in the library regardless of filename/classname casing differences, as long as the
@librarydecorator is applied or the explicit class name is specified in the import. - This would allow teams to use PEP 8 compliant file and class naming conventions without sacrificing IDE support.
Actual behavior
- "Ctrl+Click" navigation does not work; RobotCode does not resolve the keyword definition inside the class decorated with
@library. - The issue disappears if the Python file and class have matching PascalCase names (e.g., file
MyLibrary.pyand classMyLibrary), even though that violates Python PEP 8 module naming conventions.
Additional context
- The Robot Framework
@librarydecorator (available since version 3.2) is intended to explicitly mark classes as libraries, aiding recognition even when file and class names differ. - The official Robot Framework User Guide and API documentation explain the use of
@libraryand@keyworddecorators to declare libraries and keywords clearly. - Despite this, RobotCode's keyword resolution and navigation do not seem to utilize this metadata fully, causing mismatches in IDE navigation support.
- This limitation hinders adoption of PEP 8 compliant Python naming conventions in Robot Framework libraries without losing useful IDE features.
Environment
- VS Code Version: 1.102.3 (user setup)
- RobotCode Version: 1.7.0
- OS: Windows 11 Enterprise
- Python Version: 3.13.5
- Robot Framework Version: 7.2.2
- Robocop Version: 6.4.0
- Robotidy Version: 4.17.0