Skip to content

false positive: relative-beyond-top-level with namespace modules when specific file is processed in parallel mode #10794

@felixfontein

Description

@felixfontein

Bug description

Files with content:

a/b.py      ->      B = 1
a/c/d.py    ->      from ..b import B

If I run one of:

pylint --jobs 0 --disable=all --enable=relative-beyond-top-level --source-roots . a/
pylint --jobs 1 --disable=all --enable=relative-beyond-top-level --source-roots . a/c/d.py

everything is well. But if I run:

pylint --jobs 0 --disable=all --enable=relative-beyond-top-level --source-roots . a/c/d.py

I get an error:

************* Module d
a/c/d.py:1:0: E0402: Attempted relative import beyond top-level package (relative-beyond-top-level)

(The only potentially related bug I could find is #10147, but I'm not sure whether it's really related.)

Configuration

Command used

mkdir -p a/c
echo "B = 1" > a/b.py
echo "from ..b import B" > a/c/d.py
# These ones are successful:
pylint --jobs 0 --disable=all --enable=relative-beyond-top-level --source-roots . a/
pylint --jobs 1 --disable=all --enable=relative-beyond-top-level --source-roots . a/c/d.py
# This one is not, and produces the output shown below:
pylint --jobs 0 --disable=all --enable=relative-beyond-top-level --source-roots . a/c/d.py

Pylint output

************* Module d
a/c/d.py:1:0: E0402: Attempted relative import beyond top-level package (relative-beyond-top-level)

------------------------------------------------------------------
Your code has been rated at 0.00/10 (previous run: 0.00/10, +0.00)

Expected behavior

pylint should be successful in both calls.

Pylint version

pylint 4.0.4
astroid 4.0.2
Python 3.13.11 (main, Dec  7 2025, 13:01:45) [GCC 15.2.1 20251112]

OS / Environment

No response

Additional dependencies

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions