Rename Method refactoring allowed for methods defined to implement container objects
Les mainteneurs répondent en général sous 7 jours
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 3/5
- Temps estimé
- Une demi-journée
- Accessibilité débutants
- 35/100
Piste de recherche
Start by reproducing the report with the main.py and test.py from the issue, using Rename Method on StringlikeMixin.len with the new name 'text'. The open question is whether Rope should warn or refuse when a method implements a container protocol like len, and the issue does not settle that. Done means agreeing that behaviour with maintainers and then covering it with a test.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Rename Method refactoring allowed for methods defined to implement container objects
It would be nice if Rope sent an alert to the user to avoid incompatible parameter type errors when using the "len()" function.
Steps to reproduce the behavior:
- Code before refactoring:
structure
-- main
---- main.py
-- test
---- test.py
main.py:
implements_to_string = lambda x: x
@implements_to_string
class StringlikeMixin(object):
def __len__(self):
return len(self._strkey())
class BaseBlob(StringlikeMixin):
def __init__(self, text):
self.raw = text
def _strkey(self):
return self.raw
class Sentence(BaseBlob):
def __init__(self, sentence, start_index=0, end_index=None, *args, **kwargs):
super(Sentence, self).__init__(sentence, *args, **kwargs)
test.py:
from unittest import TestCase
from main import main as tb
class SentenceTest(TestCase):
def setUp(self):
self.raw_sentence = 'Any place with frites and Belgian beer has my vote.'
self.sentence = tb.Sentence(self.raw_sentence)
def test_len(self):
self.assertEqual(len(self.sentence), len(self.raw_sentence))
- Apply the Rename Method refactoring with the new name 'text' to the method 'StringlikeMixin.__len__'
- Langage dominant
- Python
- Étoiles
- 2.2k
- Forks
- 197
- Merge moyen
- 2 j 13 h
- PR mergées (30 j)
- 5
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de python-rope/rope
-
Difficulté 1/5 1-3 heures Accessibilité débutants 88/100
python-rope/rope#927 ·
Les mainteneurs répondent en général sous 7 jours
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
python-rope/rope#926 ·
Les mainteneurs répondent en général sous 7 jours
-
simplify.real_code blanks t-strings, so renames inside them edit the wrong offsetPeut-être pris @sean0407 l’a pris il y a 10 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 83/100
python-rope/rope#913 ·
Les mainteneurs répondent en général sous 7 jours
-
Difficulté 4/5 3-5 jours Accessibilité débutants 30/100
python-rope/rope#925 ·
Les mainteneurs répondent en général sous 7 jours
-
Extract method/variable and introduce parameter don't check whether the new name is already in useOuverte
Difficulté 3/5 1-2 jours Accessibilité débutants 62/100
python-rope/rope#924 ·
Les mainteneurs répondent en général sous 7 jours
Toutes les issues de python-rope/rope
Issues similaires
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 66/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
yt-project/yt#5624 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
NousResearch/hermes-agent#148376 ·
Les mainteneurs répondent en général sous 1 jour
-
Analysis
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
SACGF/variantgrid#2615 ·
Les mainteneurs répondent en général sous 1 jour