from parent import child1
if __name__ == "__main__":
child1.greet()
child1.py
from . import child2
def greet():
child2.greet()
child2.py
def greet():
print('hi from child2')
The first line of child1.py has the following error regardless of the directory from which vim is run:
[pylint E0402] [E] Attempted relative import beyond top-level package (relative-beyond-top-level). However running python main.py prints hi from child2 as you would expect.
It seems that pylint always considers the current file to be a top-level module. Is there a way to configure this?
Given a directory structure as follows:
with the following contents:
main.py
child1.py
child2.py
The first line of
child1.py
has the following error regardless of the directory from which vim is run:[pylint E0402] [E] Attempted relative import beyond top-level package (relative-beyond-top-level)
. However runningpython main.py
printshi from child2
as you would expect.It seems that pylint always considers the current file to be a top-level module. Is there a way to configure this?