Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add prefer_global_from_import #696

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nicoolas25
Copy link

@nicoolas25 nicoolas25 commented Jun 10, 2023

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):

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

@lieryan
Copy link
Member

lieryan commented Jun 12, 2023

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 lieryan mentioned this pull request Apr 4, 2024
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants