neoclide / coc-python

Python extension for coc.nvim, fork of vscode-python
574 stars 51 forks source link

Pylint considers current file to be top-level package #218

Open eulertour opened 4 years ago

eulertour commented 4 years ago

Given a directory structure as follows:

main.py
parent/
    child1.py
    child2.py

with the following contents: main.py

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?