robotframework-lsp icon indicating copy to clipboard operation
robotframework-lsp copied to clipboard

Keyword incorrectly treated as ambiguous

Open JonathanRoth13 opened this issue 2 years ago • 0 comments

Describe the bug Errors around keyword arguments are erroneously displayed.

To Reproduce The root directory of my repository is /onboarding-service-integration-testing There is a python module /onboarding-service-integration-testing/tests/authenticate.py which includes the following functions:

def authenticate(username, password):
    .....
    
def authenticate_as_service_account():
    return authenticate(AUTH_USERNAME, AUTH_PASSWORD)

def authenticate_as_teacher_or_student(username):
    return authenticate(username, USER_PASSWORD)

There is a resource file /onboarding-service-integration-testing/tests/authenticate.resource that contains the following code

*** Settings ***
Library     authenticate.py


*** Keywords ***
Authenticate
    [Arguments]    ${email}=${empty}
    IF    "${email}" == "${empty}"
        ${status_code}    ${token}=    Authenticate as Service Account
    ELSE
        Log    ${email}
        ${status_code}    ${token}=    Authenticate as Teacher or Student    ${email}
    END
    Should Be Equal As Integers    ${status_code}    200
    Set Test Variable    ${token}    ${token}

Finally, there is a robot file /onboarding-service-integration-testing/tests/classes/tests.robot that references authentication.resource and not authentication.py

*** Settings ***
Library         Collections
Library         miscellaneous.py
Resource        authenticate.resource
Resource        keywords.resource
Variables       variables.py


*** Test Cases ***
Service Account
    Set Suite Variable    ${school_a_name}    Onboarding Service Integration Testing School C-A
    Set Suite Variable    ${school_b_name}    Onboarding Service Integration Testing School C-B
    ${exp_grades}=    Create List    KG    01
    Set Suite Variable    ${exp_grades}    ${exp_grades}
    Authenticate
    # create a new class in school a
    ${class_key}=    Hit Endpoint    active    ${school_a_key}    school    A1-Class-Title    KG,01
    Verify Class Exists With Expected Attributes
    ...    ${class_key}    active    A1-Class-Title    ${school_a_name}    ${exp_grades}
    # specify class key error
    ${random_guid}=    Get Random Uuid
    Should Not Be Able To Specify A Class Key In Post
    ...    ${random_guid}    active    ${school_a_key}    school    A1-Class-Title    KG,01

When I edit this file, the bug is seen. Please see screenshots.

I have some additional configurations in .config/nvim/after/plugin/lspconfig.lua

require('lspconfig').robotframework_ls.setup{
    settings = {
        robot = {
            language_server = {
                python = "/opt/homebrew/bin/python3"
            },
            pythonpath = {"/Users/joroth/Repositories/onboarding-service-integration-testing","/Users/joroth/Repositories/onboarding-service-integration-testing/tests"},
            lint = {
                ignoreVariables = {"token"}
            },
            python = {
                executable="/Users/joroth/.venv/osit/bin/python3",
                env = {
                    AUTH_USERNAME = "xxxxx",
                    AUTH_PASSWORD = "xxxxx",
                    ENVIRONMENT = "xxxxx"
                }
            }
        }
    }
}

Expected behavior I expect no syntax errors. However my editor displays messages like "mandatory argument missing: username"

Screenshots screenshots

Versions:

  • OS: macOs 13.4.1 (c) (22F770820d)
  • Robot Framework Version: Robot Framework 6.0.2
  • Robot Framework Language Server Version: 1.11.0
  • Client Version: NVIM v0.9.2

Logs logs

JonathanRoth13 avatar Sep 20 '23 21:09 JonathanRoth13