Inline method refactoring passes the wrong parameter to the inlined function body
Maintainer thường phản hồi trong vòng 7 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 45/100
Hướng nghiên cứu
Start from the reproduction in the issue: apply Inline Method to PatternParser.parse in en/parsers.py and check the call in test.py's test_parse. The bad output is self.assertEqual(pattern_parse(__0__self.parser.text), ...), where the argument should stay self.text. Done when the inlined call passes the original argument and the test passes. The payload names no rope source files, so locate the inline refactoring code yourself.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Inline method refactoring passes the wrong parameter to the inlined function body
Steps to reproduce the behavior:
- Code before refactoring:
structure
-- en
---- __init.py__
---- parsers.py
-- test
---- __init.py__
---- test.py
en.__init.py__:
class Parser(object):
def __init__(self, lexicon={}, default=("NN", "NNP", "CD"), language=None):
self.lexicon = lexicon
self.default = default
self.language = language
def parse(self, s, tokenize=True, tags=True, chunks=True, relations=False, lemmata=False, encoding="utf-8", **kwargs):
pass
parser = Parser(
default=("NN", "NNP", "CD"),
language="en"
)
def parse(s, *args, **kwargs):
return parser.parse(s, *args, **kwargs)
en.parsers.py:
from abc import abstractmethod
from en import parse as pattern_parse
class BaseParser(object):
@abstractmethod
def parse(self, text):
return
class PatternParser(BaseParser):
def parse(self, text):
return pattern_parse(text)
test.test.py:
import unittest
from en import parse as pattern_parse
import en.parsers as parsers
class TestPatternParser(unittest.TestCase):
def setUp(self):
self.parser = PatternParser()
self.text = "And now for something completely different."
def test_parse(self):
self.assertEqual(self.parser.parse(self.text), pattern_parse(self.text))
-
Apply the Inline Method refactoring to 'PatternParser.parse'
-
Expected code after refactoring:
en.__init.py__:
class Parser(object):
def __init__(self, lexicon={}, default=("NN", "NNP", "CD"), language=None):
self.lexicon = lexicon
self.default = default
self.language = language
def parse(self, s, tokenize=True, tags=True, chunks=True, relations=False, lemmata=False, encoding="utf-8", **kwargs):
pass
parser = Parser(
default=("NN", "NNP", "CD"),
language="en"
)
def parse(s, *args, **kwargs):
return parser.parse(s, *args, **kwargs)
en.parsers.py:
from abc import abstractmethod
from en import parse as pattern_parse
class BaseParser(object):
@abstractmethod
def parse(self, text):
return
class PatternParser(BaseParser):
pass
test.test.py:
import unittest
from en import parse as pattern_parse
import en.parsers as parsers
class TestPatternParser(unittest.TestCase):
def setUp(self):
self.parser = PatternParser()
self.text = "And now for something completely different."
def test_parse(self):
self.assertEqual(pattern_parse(self.text), pattern_parse(self.text))
The transformation changes the attribute that is passed to the original function.
The result is: self.assertEqual(pattern_parse(__0__self.parser.text), pattern_parse(self.text))
Causing test fail
- Ngôn ngữ chính
- Python
- Star
- 2.2k
- Fork
- 197
- Merge trung bình
- 2 ngày 13 giờ
- Pull request đã merge (30 ngày)
- 5
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của python-rope/rope
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 88/100
python-rope/rope#927 ·
Maintainer thường phản hồi trong vòng 7 ngày
-
Extract raises IndexError or ModuleSyntaxError instead of RefactoringError for an empty or whitespace-only regionCó thể đã có người làm @aliassar đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
python-rope/rope#926 ·
Maintainer thường phản hồi trong vòng 7 ngày
-
simplify.real_code blanks t-strings, so renames inside them edit the wrong offsetCó thể đã có người làm @sean0407 đã nhận 10 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
python-rope/rope#913 ·
Maintainer thường phản hồi trong vòng 7 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 30/100
python-rope/rope#925 ·
Maintainer thường phản hồi trong vòng 7 ngày
-
Extract method/variable and introduce parameter don't check whether the new name is already in useĐang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 62/100
python-rope/rope#924 ·
Maintainer thường phản hồi trong vòng 7 ngày
Tất cả issue của python-rope/rope
Issue tương tự
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 78/100
QuantConnect/Documentation#2838 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
awslabs/route53-dynamic-dns-with-lambda#67 · 1 bình luận ·
-
`SubAgents` returns a child run's `DeferredToolRequests` to the parent as a successful tool resultĐang mởbug pkg:harness
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
pydantic/pydantic-ai#12405 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
good first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
good first issue help wanted
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100