Skip to content

Detect package when analysing import statements #36

@lfurrer

Description

@lfurrer

In parallel to an issue over at AtomLinter, SublimeLinter-pylint produces spurious error messages when analysing dotted relative import statements inside a Python package.

For example, consider the following package (directory) structure:

working directory
| - package
|   | - foo
|   |   | - bar.py
|   |   | - baz.py

In the module bar.py, it's totally fine (AFAIK) to write:

from . import baz

However, if you simply run

pylint package/foo/bar.py

it will show an error "Attempted relative import beyond top-level package", because it doesn't recognize bar.py is part of a package.
This is also what I see in the editor when SublimeLinter-pylint is enabled.

In order for pylint to acknowledge the package structure, you have to run

pylint package.foo.bar

Is there any way for SublimeLinter to detect packages and adjust the calls to pylint accordingly?
Or is there at least a way to tell SublimeLinter-pylint where the package root is?

Please note: This is all Python 3.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions