The classification of an import as being non-stdlib of some kind depends on that package actually being installed.
But looking at the code in _import_type() it seems like what really happens is that if the module doesn't match the others, it's considered to be third party. This was confusing at first because based on the documentation I tried installing/uninstalling third party packages to try to fix issues:
else:
# Not future, stdlib or an application import.
# Must be 3rd party.
return IMPORT_3RD_PARTY
Next:
You will want to set the application-import-names option to a comma separated list of names that should be considered local to your application. These will be used to help categorise your import statements into the correct groups.
Also from _import_type(), it would be helpful to new users to mention that relative imports are always considered local:
if name is None:
# relative import
return IMPORT_APP
...
elif isinstance(node, ast.ImportFrom) and node.level > 0:
return IMPORT_APP_RELATIVE
I realize these are somewhat implementation details, but I think they really help new comers determine why many of the locals are properly recognized, but not others.
From the Limitations section of the docs:
But looking at the code in
_import_type()
it seems like what really happens is that if the module doesn't match the others, it's considered to be third party. This was confusing at first because based on the documentation I tried installing/uninstalling third party packages to try to fix issues:Next:
Also from
_import_type()
, it would be helpful to new users to mention that relative imports are always considered local:I realize these are somewhat implementation details, but I think they really help new comers determine why many of the locals are properly recognized, but not others.