python-rope / rope

a python refactoring library
GNU Lesser General Public License v3.0
1.96k stars 164 forks source link

Implement preferred_import_style #788

Open lieryan opened 7 months ago

lieryan commented 7 months ago

Description

Added a new setting (imports.preferred_import_style) that controls how rope inserts new import statements.

It can be set to:

Credit: the solution here is based on nicoolas25's work on #696, but implements the config settings in a slightly different way.

Checklist (delete if not relevant):

codecov[bot] commented 7 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 94.98%. Comparing base (54433b8) to head (0789b81).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #788 +/- ## ========================================== + Coverage 94.97% 94.98% +0.01% ========================================== Files 135 135 Lines 26405 26480 +75 ========================================== + Hits 25077 25152 +75 Misses 1328 1328 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

lheckemann commented 3 days ago

Just tested this, it works nicely and results in much smaller diffs :) thanks!

nip3o commented 1 day ago

@lieryan it would be pretty awesome to be able to use this. Is there something that prevents it from being merged? Anything we could contribute with?