'Pylint gives error warning to working relative imports
I have the following file structure:
├── README.md
├── apps
│ ├── fire_analysis.py
│ └── rois.py
└── streamlit_app.py
File contents
- streamlit_app.py
from apps import fire_analysis
- apps/fire_analysis.py
from .apps import rois
print(rois.the_object)
- apps/rois.py
the_object = 42 # the object that I want
The code works just fine. But I am getting the E0402: Attempted relative import beyond top-level package (relative-beyond-top-level) error warning from pylint.
How to resolve this warning?
Am I doing the importing the wrong way in the fire_analysis.py?
Solution 1:[1]
It works for me to change the import of apps/fire_analysis.py to
from . import rois
telling python to search locally.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Erik Wessel |
