Inline method refactoring passes the wrong parameter to the inlined function body
Los mantenedores suelen responder en 7 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 45/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
- Lenguaje dominante
- Python
- Estrellas
- 2.2k
- Forks
- 197
- Merge medio
- 2 d 13 h
- PR fusionados (30 d)
- 5
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de python-rope/rope
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 88/100
python-rope/rope#927 ·
Los mantenedores suelen responder en 7 días
-
Extract raises IndexError or ModuleSyntaxError instead of RefactoringError for an empty or whitespace-only regionPosiblemente ocupada @aliassar la tomó hace 1 día. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
python-rope/rope#926 ·
Los mantenedores suelen responder en 7 días
-
simplify.real_code blanks t-strings, so renames inside them edit the wrong offsetPosiblemente ocupada @sean0407 la tomó hace 11 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
python-rope/rope#913 ·
Los mantenedores suelen responder en 7 días
-
Dificultad 4/5 3-5 días Aptitud para principiantes 30/100
python-rope/rope#925 ·
Los mantenedores suelen responder en 7 días
-
Extract method/variable and introduce parameter don't check whether the new name is already in usePosiblemente ocupada @aliassar la tomó hoy. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 62/100
python-rope/rope#924 · 1 comentario ·
Los mantenedores suelen responder en 7 días
Todos los issues de python-rope/rope
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
autowarefoundation/autoware_carla_scenario#1485 ·
Los mantenedores suelen responder en 1 día
-
needs-area-label
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
Los mantenedores suelen responder en 2 días
-
enhancement good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
Official-Space-AI/OpenPhysGraspGen#114 ·
Los mantenedores suelen responder en 2 días
-
changelog investigate
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
ramnes/notion-sdk-py#441 ·
-
copy_tree splits same-file errors into charactersPosiblemente ocupada @Gambit-Checkmate la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 14 días