Rename Method refactoring allows the use of the name of an 'internal field' to rename a public method.
According to PEP 8, special formats starting with underscores are recognized as 'internal use' indicators, and import formats ignore those names
This can cause errors related to undefined attributes or incompatible types.
It would be nice if Rope sent an alert to users in this operation type
Steps to reproduce the behavior:
import csv
from collections import OrderedDict
DEFAULT_ENCODING = 'utf-8'
class BaseFormat(object):
def init(self, fp, **kwargs):
pass
def to_iterable(self):
raise NotImplementedError('Must implement a "to_iterable" method.')
@classmethod
def detect(cls, stream):
raise NotImplementedError('Must implement a "detect" class method.')
Rename Method refactoring allows the use of the name of an 'internal field' to rename a public method. According to PEP 8, special formats starting with underscores are recognized as 'internal use' indicators, and import formats ignore those names This can cause errors related to undefined attributes or incompatible types. It would be nice if Rope sent an alert to users in this operation type
DEFAULT_ENCODING = 'utf-8'
class BaseFormat(object): def init(self, fp, **kwargs): pass
class CSV(BaseFormat): delimiter = ","
_registry = OrderedDict([ ('csv', CSV), ])
def detect(fp, max_read=1024): for Format in _registry.values(): if Format.detect(fp.read(max_read)): return Format return None
def get_registry(): return _registry
def register(name, format_class): get_registry()[name] = format_class