Rename Method allows changing datamodels function names.

Aperta
#832 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 7 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
Mezza giornata
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
python
Ambito
tooling

Direzione di ricerca

Start with the rename refactoring in rope's refactor package, where the rename method is applied to a function definition, and check how it treats special methods such as __new__. Reproduce with the Singleton snippet in the issue to see that the definition is renamed while the super().__new__ call is left alone. The issue does not say whether dunder methods should be refused or renamed differently, so confirm the intended behavior with the maintainers before changing code.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug

Rename Method allows changing datamodels function names.

Steps to reproduce the behavior:

  1. Code before refactoring:
class Singleton:
    _instancia = None

    def __new__(cls):
        if cls._instancia is None:
            cls._instancia = super().__new__(cls)
        return cls._instancia

a = Singleton()
b = Singleton()
print(a is b)
  1. Apply the rename method to Singleton.__new__

  2. Code after refactoring:

class Singleton:
    _instancia = None

    def get_instance(cls):
        if cls._instancia is None:
            cls._instancia = super().__new__(cls)
        return cls._instancia

a = Singleton()
b = Singleton()
print(a is b)
Lingua principale
Python
Stelle
2.2k
Fork
197
Merge medio
2g 13h
PR unite (30g)
5

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di python-rope/rope

Tutte le issue di python-rope/rope

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.