Python language server settings


#1

Ranorex Webtestit offers many cool language-specific features, such as autocomplete, syntax error checking, jump-to-definition, and more. Using these features as we type our code is possible thanks to the Language Server Protocol.

To make as many users as possible happy, Ranorex Webtestit now allows passing some configuration parameters to two features enabled by default for Python language.

The first feature is autocompletion based on the Jedi library that automatically inserts parameters + brackets when autocompleting a function, similarly to Java language.
The autocomplete feature provides not only completions as you type or edit the code, but also other actions. These actions, however, are not enabled by default; you need to set them manually (more on how to do it below).

autocomplete

Another Python language server feature that is enabled by default in Ranorex Webtestit is code linting with pylint, pycodestyle and pyflakes, allowing us to check the source code for errors. In case there’s an error in code, a specific part of the code would be highlighted. After hovering that part, the lint feature would display the type of error.

errorGif

If you don’t need any of these two language server features, you can disable them easily. You will find the Language Server settings in the Preferences dialog after opening a Python project in Ranorex Webtestit.
Clicking the ‘Edit in webtestit.json’ button will open webtestit.json file, allowing you to make changes.

To disable the autocomplete feature, enter the following line to JSON file and set "include_params" to ‘false’:

"languageServer": {
  "python": {
    "plugins": {
      "jedi_completion": {
        "include_params": false
      }
    }
  }
}

Similarly, if you want to disable pylint feature, add the following line to the JSON file, and set "enabled" to ‘false’:

"languageServer": {
  "python": {
    "plugins": {
       "pylint": {
         "enabled": false
      }
     }
   }
 }

The autocomplete and pylint are the two features that are enabled by default, but they’re not the only features that can be used in Ranorex Webtestit. You can enable all other Python language server settings by adding them to webtestit.json file.

For example, if you want to enable Go to definition, add the following line of code to JSON file:

"languageServer": {
  "python": {
    "plugins": {
      "jedi_definition": {
        "enabled": true
      }
    }
  }
}

The same approach can be used to add hover (e.g. jedi_hover), references (e.g. jedi_references), signature help, symbols, and other Python language server actions that may be useful to you.

Most of these actions are Boolean, so switching from true to false would enable or disable them. However, some actions may require different configurations, for example, an enum or an array.

Of course, it’s understandable if you get stuck with all these language server actions and settings. Luckily, our helpful staff is here to answer all the questions you may have. :wink:


Release notes v1.11.0