Reputation: 83
I'm working on a project with many different Django apps.
I want to use isort
on this project but the imports from Django apps (from myapp1.mymodule import myfunction
) are seen by isort
as third-party imports.
How can I make isort
recognize them as first-party imports?
I could add in the isort
configuration (in the .cfg
): known_first_party=myapp1,myapp2...
but I'll have to maintain this list.
Is there a better way?
Upvotes: 8
Views: 2819
Reputation: 1434
You can use the src_paths
option to specify the project folder. You do not need to maintain a known_first_party
list. See the related source code:
if (
_is_module(module_path)
or _is_package(module_path)
or _src_path_is_module(src_path, root_module_name)
):
return (sections.FIRSTPARTY, f"Found in one of the configured src_paths: {src_path}.")
Upvotes: 7