rope icon indicating copy to clipboard operation
rope copied to clipboard

Add prefer_global_from_import

Open nicoolas25 opened this issue 2 years ago • 1 comments

Description

Adding a prefer_global_from_import configuration option for pick the "global" form of import over the module one.

- from pkg import mod1
- mod1.AClass()
+ from pkg.mod1 import AClass
+ AClass()

Checklist (delete if not relevant):

  • [x] I have added tests that prove my fix is effective or that my feature works
  • [x] I have updated CHANGELOG.md

nicoolas25 avatar Jun 10 '23 07:06 nicoolas25

Hi @nicoolas25, thank you for the contribution.

Adding this configuration would imply that there will be two conflicting configuration options with the prefer_module_from_imports and prefer_global_from_imports and both can't be set to True at the same time.

I think the config options should've been merged.

The prefer_module_from_imports config option should be deprecated and the new config option, e.g. preferred_import_style should have string values like auto, normal-import, from-module, from-global, etc. This new config option should take precedence over the legacy value.

lieryan avatar Jun 12 '23 23:06 lieryan