The Inline Method removes an overridden method
Maintainer antworten meist innerhalb von 7 Tagen
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 35/100
Rechercherichtung
Start by running the two-class snippet in the issue (WordList overriding append and extend) and confirm the before-and-after output differs. Then apply Inline Method to WordList.extend in rope and find where the inlining step decides which calls to keep. The issue does not name rope's internal files, so locate them from that entry point. Done means the inlined code still routes each element through the overridden append, so Word objects are still created.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
The Inline Method removes an overridden method that changes the type of the stored objects.
Steps to reproduce the behavior:
- Code before refactoring:
class Word(str):
def __new__(cls, value):
print(f"criando Word({value!r})")
return super().__new__(cls, value)
class WordList(list):
def append(self, obj):
print(f"append: recebi {obj!r} (type={type(obj).__name__})")
if isinstance(obj, str) and not isinstance(obj, Word):
obj = Word(obj)
super().append(obj)
def extend(self, iterable):
print("extend (custom): chamando append para cada elemento")
for e in iterable:
self.append(e)
wl = WordList()
wl.extend(["ola", "mundo"])
print("conteúdo wl:", wl)
print("types wl:", [type(x).__name__ for x in wl])
-
Apply the inline method to
WordList.extend -
Code after refactoring:
class Word(str):
def __new__(cls, value):
print(f"criando Word({value!r})")
return super().__new__(cls, value)
class WordList(list):
def append(self, obj):
print(f"append: recebi {obj!r} (type={type(obj).__name__})")
if isinstance(obj, str) and not isinstance(obj, Word):
obj = Word(obj)
super().append(obj)
wl = WordList()
wl.extend(["ola", "mundo"])
print("conteúdo wl:", wl)
print("types wl:", [type(x).__name__ for x in wl])
- Vorherrschende Sprache
- Python
- Sterne
- 2.2k
- Forks
- 197
- Ø Merge
- 2 T. 13 Std.
- Gemergte PRs (30 T.)
- 5
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus python-rope/rope
-
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 88/100
python-rope/rope#927 ·
Maintainer antworten meist innerhalb von 7 Tagen
-
Extract raises IndexError or ModuleSyntaxError instead of RefactoringError for an empty or whitespace-only regionEvtl. vergeben @aliassar hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
python-rope/rope#926 ·
Maintainer antworten meist innerhalb von 7 Tagen
-
simplify.real_code blanks t-strings, so renames inside them edit the wrong offsetEvtl. vergeben @sean0407 hat das vor 10 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 83/100
python-rope/rope#913 ·
Maintainer antworten meist innerhalb von 7 Tagen
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 30/100
python-rope/rope#925 ·
Maintainer antworten meist innerhalb von 7 Tagen
-
Extract method/variable and introduce parameter don't check whether the new name is already in useOffen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 62/100
python-rope/rope#924 ·
Maintainer antworten meist innerhalb von 7 Tagen
Alle Issues in python-rope/rope
Ähnliche Issues
-
Backend issue lists report in-patch warnings and out-of-patch errors as not publishableEvtl. vergeben @RaphaelFakhri hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
mozilla/code-review#3794 ·
Maintainer antworten meist innerhalb von 1 Tag
-
[oblt-aw][autodoc] Update docs that still describe the security registry as emptyEvtl. vergeben @github-actions hat das heute übernommen. Offen
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 85/100
Maintainer antworten meist innerhalb von 1 Tag
-
[Bug] adb backup script reports "Done" & exits 0 when the backup failsEvtl. vergeben @bhattmanthan hat das heute übernommen. Offenrequest-issue-assignment
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
OWASP/mastg#4034 · 5 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
agent-ui bug p2
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
amd/gaia#6580 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
correction metadata
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 72/100
acl-org/acl-anthology#10768 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag