You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to request a new feature for isort that automatically converts relative imports to absolute imports within a Python project. This feature would enhance code readability and maintainability, especially in large projects with complex directory structures.
Problem Statement
In large and complex Python projects, relative imports can make the codebase harder to navigate and understand, especially for newcomers. Enforcing absolute imports contributes to cleaner and more understandable code. Currently, developers have to manually adjust imports or rely on code review practices to enforce the use of absolute imports, which can be time-consuming and error-prone.
Proposed Solution
I propose adding an option to isort that, when enabled, converts all relative imports in a project to absolute imports based on the project's root directory. This could be implemented as a command-line flag (e.g., --absolute-imports) that can be used in conjunction with the existing isort command to also maybe check on the CI level.
Use Case
This feature would be particularly useful in projects that prioritize code readability and maintainability, making it easier to enforce a consistent import style across the entire codebase. It would also be beneficial for projects looking to migrate from relative to absolute imports as part of refactoring efforts.
Thank you for considering this feature request. I believe it would make a valuable addition to isort and greatly benefit the Python community.
The text was updated successfully, but these errors were encountered:
Description
I would like to request a new feature for
isort
that automatically converts relative imports to absolute imports within a Python project. This feature would enhance code readability and maintainability, especially in large projects with complex directory structures.Problem Statement
In large and complex Python projects, relative imports can make the codebase harder to navigate and understand, especially for newcomers. Enforcing absolute imports contributes to cleaner and more understandable code. Currently, developers have to manually adjust imports or rely on code review practices to enforce the use of absolute imports, which can be time-consuming and error-prone.
Proposed Solution
I propose adding an option to
isort
that, when enabled, converts all relative imports in a project to absolute imports based on the project's root directory. This could be implemented as a command-line flag (e.g.,--absolute-imports
) that can be used in conjunction with the existingisort
command to also maybe check on the CI level.Use Case
This feature would be particularly useful in projects that prioritize code readability and maintainability, making it easier to enforce a consistent import style across the entire codebase. It would also be beneficial for projects looking to migrate from relative to absolute imports as part of refactoring efforts.
Thank you for considering this feature request. I believe it would make a valuable addition to
isort
and greatly benefit the Python community.The text was updated successfully, but these errors were encountered: