docs/guides/lint_rules/rules/self_import.md
⚠️ Runtime ❌ Not Fixable
MR001: Importing a module with the same name as the file.
Analyzes import statements in each cell to detect cases where the imported module name matches the current file's name (without the .py extension).
Importing a module with the same name as the file causes several issues:
This is a runtime issue because it can cause import confusion and unexpected behavior.
Problematic (in a file named requests.py):
import requests # Error: conflicts with file name
Problematic (in a file named math.py):
from math import sqrt # Error: conflicts with file name
Solution:
# Rename the file to something else, like my_requests.py
import requests # Now this works correctly
Alternative Solution:
# Use a different approach that doesn't conflict
import urllib.request # Use alternative library