Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename Field refactoring allows you to rename a class field with class method names #765

Closed
Tracked by #779
jonhnanthan opened this issue Feb 27, 2024 · 1 comment

Comments

@jonhnanthan
Copy link

Rename Field refactoring allows you to rename a class field with class method names
It would be nice if Rope sent an alert to the user to avoid call errors

Steps to reproduce the behavior:

  1. Code before refactoring:

structure

-- main
---- main.py
-- test
---- test.py

main.py:

from abc import abstractmethod


class BaseNPExtractor(object):
    @abstractmethod
    def extract(self, text):
        return


class PatternTagger:
    def tag(self, text):
        return []


class ConllExtractor(BaseNPExtractor):
    POS_TAGGER = PatternTagger()

    def __init__(self, parser=None):
        self.parser = parser

    def extract(self, text):
        return []

    def _parse_sentence(self, sentence):
        tagged = self.POS_TAGGER.tag(sentence)
        return self.parser.parse(tagged)

test.py:

from __future__ import unicode_literals
import unittest
from main.main import ConllExtractor


class TestConllExtractor(unittest.TestCase):

    def setUp(self):
        self.extractor = ConllExtractor()
        self.text = 'Python is '

    def test_extract(self):
        noun_phrases = self.extractor.extract(self.text)
        self.assertTrue("Python" in noun_phrases)
  1. Apply the Rename Field refactoring with the new name 'extract' to the field 'ConllExtractor.POS_TAGGER'

After the transformation, the unit test will fail.

@jonhnanthan jonhnanthan added the bug Unexpected or incorrect user-visible behavior label Feb 27, 2024
@lieryan
Copy link
Member

lieryan commented Mar 12, 2024

Closing. Ticket merged into #779.

@lieryan lieryan closed this as not planned Won't fix, can't repro, duplicate, stale Mar 12, 2024
@lieryan lieryan added enhancement and removed bug Unexpected or incorrect user-visible behavior labels Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants