Package: pylsp-rope
pylsp-ropeExtended refactoring capabilities for Python LSP Server usingRope.This is a plugin forPython LSP
Server, so you also need to
have it installed.python-lsp-server already has basic built-in support for using Rope, but it's
currently limited to just renaming and completion. Installing this plugin adds
more refactoring functionality to python-lsp-server.InstallationTo use this plugin, you need to install this plugin in the same virtualenv as
python-lsp-server itself.pipinstallpylsp-ropeThen runpylspas usual, the plugin will be auto-discovered by
python-lsp-server if you've installed it to the right environment. On Vim,
refer toRope in Vim or
Neovim. For
other editors, refer to your IDE/text editor's documentation on how to setup a
language server.ConfigurationThere is no configuration yet.FeaturesThis plugin adds the following features to python-lsp-server:extract method (codeAction)extract variable (codeAction)inline method/variable/parameter (codeAction)use function (codeAction)method to method object (codeAction)convert local variable to field (codeAction)organize imports (codeAction)introduce parameter (codeAction)generate variable/function/class from undefined variable (codeAction)more to come...Refer toRope documentationfor more details on how these refactoring works.UsageExtract methodVariants:Extract methodExtract global methodExtract method including similar statementsExtract global method including similar statementsWhen CodeAction is triggered and the cursor is on any block of code, extract
that expression into a method. Optionally, similar statements can also be
extracted.Extract variableVariants:Extract variableExtract global variableExtract variable including similar statementsExtract global variable including similar statementsWhen CodeAction is triggered and the cursor is on a expression, extract that
expression into a variable. Optionally, similar statements can also be
extracted.InlineWhen CodeAction is triggered and the cursor is on a resolvable Python variable,
replace all calls to that method with the method body.Use functionWhen CodeAction is triggered and the cursor is on the function name of adefstatement, try to replace code whose AST matches the selected function with a
call to the function.Method to method objectWhen CodeAction is triggered and the cursor is on the function name of adefstatement, create a callable class to replace that method. You may want to
inline the method afterwards to remove the indirection.Convert local variable to fieldWhen CodeAction is triggered wand the cursor is on a local variable inside a
method, convert that local variable to an attribute.Organize importTrigger CodeAction anywhere in a Python file to organize imports.Introduce parameterWhen CodeAction is triggered and the cursor is selecting a Python variable or
attribute, make that variable/attribute a parameter.Generate codeVariants:Generate variableGenerate functionGenerate classGenerate moduleGenerate packageWhen CodeAction is triggered and the cursor is on an undefined Python
variable, generate an empty variable/function/class/module/package for that
name.CaveatSupport for working on unsaved document is currently experimental.This plugin is in early development, so expect some bugs. Please report inGithub issue trackerif you had any issues with the plugin.DevelopingSeeCONTRIBUTING.md.CreditsThis package was created withCookiecutterfromlieryan/cookiecutter-pylsp-pluginproject template.