MR001: self-import¶
⚠️ Runtime ❌ Not Fixable
MR001: Importing a module with the same name as the file.
What it does¶
Analyzes import statements in each cell to detect cases where the imported module name matches the current file's name (without the .py extension).
Why is this bad?¶
Importing a module with the same name as the file causes several issues: - Python may attempt to import the current file instead of the intended module - This can lead to circular import errors or unexpected behavior - It makes the code confusing and hard to debug - It can prevent the notebook from running correctly
This is a runtime issue because it can cause import confusion and unexpected behavior.
Examples¶
Problematic (in a file named requests.py
):
Problematic (in a file named math.py
):
Solution:
Alternative Solution: