Support moving and renaming a module with a file destination

Ouverte
#917 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 2 jours

Personne n'a encore pris cette issue.

Évaluation

Difficulté
5/5
Temps estimé
Plus d'une semaine
Accessibilité débutants
38/100
Type d'issue
Fonctionnalité
Clarté
Clairement spécifiée
Activité
Active
Stack technique
python
Domaine
devtools

Piste de recherche

Start by reading MoveModule.get_changes() and the existing move and rename refactorings to determine whether composing them already supports this workflow. If extending MoveModule, define destination and collision semantics, then cover normal, from, aliased, relative, and in-module imports with regression tests. Done means renamed file destinations rewrite imports consistently; assess the separate find_relative_module() change with its own reproducer and test.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

Proposal

Consider extending MoveModule.get_changes() to accept a destination file, so callers can move and rename a module in one refactoring, for example:

old_package/module.py → new_package/renamed.py

Currently, MoveModule requires a folder destination. Commit https://github.com/python-rope/rope/commit/e7bfd4f5f4cb798f5b96ba7111e07e16254958f7 experiments with accepting file destinations and adjusting import rewriting. The feature idea seems worth considering, but the patch needs further work rather than merging unchanged.

Suggested scope

  • Define destination-file semantics, including whether the file must not yet exist, collision handling, and how package moves differ from module moves.
  • Update import rewriting consistently for both unchanged and renamed module basenames. The experimental patch's special case for from old_package import module only handles a destination with the same basename.
  • Cover normal imports, from-imports, aliases, relative imports, and imports inside the moved module with regression tests.
  • Avoid the patch's broad except Exception handler, which hides the underlying failure.

First assess whether composing the existing move and rename refactorings already provides this behaviour reliably. If so, a convenience API or documentation may be preferable to extending MoveModule.

Separate concern

The same commit changes find_relative_module() to fall back to the project root when folder is false. That change should not be included without a separate reproducer and regression test establishing the intended relative-import behaviour.

This suggestion is based on source review of the commit and the current implementation, not behavioural testing of the patch.

Langage dominant
Python
Étoiles
2.2k
Forks
197
Merge moyen
1 j 20 h
PR mergées (30 j)
7

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de python-rope/rope

Toutes les issues de python-rope/rope

Issues similaires

Plus d'issues Python

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.