Inline method refactoring passes the wrong parameter to the inlined function body
メンテナーはふだん 7 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- Python
- スター
- 2.2k
- フォーク
- 197
- 平均マージ
- 2日 13時間
- マージ済み PR(30日)
- 5
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
python-rope/rope のほかの issue
-
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
python-rope/rope#927 ·
メンテナーはふだん 7 日以内に返信
-
Extract raises IndexError or ModuleSyntaxError instead of RefactoringError for an empty or whitespace-only region対応中かも @aliassar が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
python-rope/rope#926 ·
メンテナーはふだん 7 日以内に返信
-
simplify.real_code blanks t-strings, so renames inside them edit the wrong offset対応中かも @sean0407 が 11 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
python-rope/rope#913 ·
メンテナーはふだん 7 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 30/100
python-rope/rope#925 ·
メンテナーはふだん 7 日以内に返信
-
Extract method/variable and introduce parameter don't check whether the new name is already in useオープン
難易度 3/5 1〜2日 初心者へのやさしさ 62/100
python-rope/rope#924 ·
メンテナーはふだん 7 日以内に返信
python-rope/rope の issue をすべて見る
似ている issue
-
DBFS append mode silently overwrites existing files対応中かも @IlyaKhalafi が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
fsspec/filesystem_spec#2429 ·
メンテナーはふだん 1 日以内に返信
-
[Bug]: Retrieval rerank fallback statistics stay zero after provider failure対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
volcengine/OpenViking#7014 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
fedora-copr/copr#4600 ·
メンテナーはふだん 2 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
ansys/pydpf-core#3620 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信