Skip to content

[Enhancement] Support New RF 7.2 Library Import Behavior via @library Decorator #484

@khorovatin

Description

@khorovatin

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 @library decorator (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

  1. Create a Python file my_library.py defining 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
  1. Import this library in a Robot Framework file:
*** Settings ***
Library    path/to/my_library.py
  1. Use the keyword Example Keyword in a test case.
  2. 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 @library decorator 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.py and class MyLibrary), even though that violates Python PEP 8 module naming conventions.

Additional context

  • The Robot Framework @library decorator (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 @library and @keyword decorators 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    Status

    Ready

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions