I am using Python 2.7 and want to do some refactoring using rope (via python-mode in vim).
I have a class containing the method I want to refactor and another class which has an instance attribute containing an instance of the first class.
Assume I want to change the name of Car.get_n_wheels() in the following example:
class Car(object):
def __init__(self, n_wheels):
self._n_wheels = n_wheels
def get_n_wheels(self):
return self._n_wheels
class Garage(object):
def __init__(self, car):
self._car = car # with this line print_n_wheels is not refactored
# self._car = Car(4) # with this line print_n_wheels is refactored
def print_n_wheels(self):
''''getter'''
print self._car.get_n_wheels()
The last line is changed only if I explicitly enforce that _car is a car by creating a new Car object, but I want to hand a finished car object to the constructor.
Is there any way to tell rope what is the (expected) type of an instance variable?