PyCharm: Unable to Move Resactor Static Methods

(Environment: PyCharm 5.0.2, interpreter: Python 2.7 bundled with OSX 10.10)

Hi guys,

I was not able to figure out how to get PyCharm to allow me to refactor the Move with a static method. Is it supported? I could not find any documents indicating that this is not so.

Special behavior

I launched a new workspace and put it in a file.

class MyGreatDemonstratorClass(object): @staticmethod def some_static_method(): print "static hey" @classmethod def some_class_method(cls): print "class hey" def some_instance_method(self): print "instance hey" def unbound_method(): print "unbound hey" 
  1. I right-click on some_static_method , hover over "Refactor", press "Move"
  2. A red text appears that says "Cannot refactor using selected elements" ( img )
  3. (The same goes for some_class_method and some_instance_method , although that makes sense to me; refactoring the related method is difficult.)
  4. Repeat # 1 on unbound_method , it should work.

So my question is

  • Is @staticmethod refactoring supported in PyCharm?
  • If not, what is the recommended way to do this? Rope?
+8
source share
2 answers

maybe believe-refactoring + built-in refactoring can help

but I have not tried them

0
source

Try this one

Performing motion refactoring

To refactor Move, follow these general steps:

  • Select the character to move and do one of the following:

    • In the Refactoring menu or in the context menu, select Move .
    • Press F6 .
    • In the Project Tool window , drag the symbol to the new destination.

    The dialog that opens depends on the type of character selected.

  • Specify the move options according to the type of item being moved. See Option Descriptions in the Move dialog box.
  • Preview and apply changes.
-2
source

Source: https://habr.com/ru/post/1238895/


All Articles