Packages and Python built-in imports are not supported when the project has somewhere a folder with the same name
See original GitHub issueBugs:
# Original (correct) import
from collections.abc import Iterable
# Changed automatically to a wrong
from ..abc import Iterable
# Original (correct) import
from google.cloud import vision
# Changed automatically to a wrong
from .cloud import vision
Project structure:
project/
src/
collections/
foo/
bar/
google/
spam/
eggs/
As you see, if a sub-directory matches 3rd-party package or Python module, the ‘absolufy-imports’ makes mistakes.
Possible solutions
- Check that import is a 3rd-party package. Do not make such imports relative.
- Another possible solution is to allow to ignore manually specific names. For example, I will ignore names “collections” and “google”.
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Importing from builtin library when module with same name ...
No, this probably wouldn't work because python caches the module name in sys. modules , and it will not import a module with...
Read more >5. The import system — Python 3.11.1 documentation
When a regular package is imported, this __init__.py file is implicitly executed, and the objects it defines are bound to names in the...
Read more >Absolute vs Relative Imports in Python
This is a cache of all modules that have been previously imported. If the name isn't found in the module cache, Python will...
Read more >Local imports not resolving correctly · Issue #68 - GitHub
I presume you are using absolute imports. Python 2 allowed absolute imports to be resolved from the same directory as the importing file,...
Read more >how the Python import system works - Ten thousand meters
Built-in modules are C modules compiled into the python executable. ... Note that the module variable is not available after the import as ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Thank you for the update. Now all works correctly.
I’d like to think this is fixed in version 0.3.1 - could you check please?