这是indexloc提供的服务,不要输入任何密码
Skip to content

import-private-name raises for multi-root projects #10739

@kasium

Description

@kasium

Bug description

# p1/__init__.py
class _Dummy:
    pass

# p2/__init__.py
from p1 import _Dummy

Configuration

[tool.pylint.master]
load-plugins = ["pylint.extensions.private_import",]

Command used

pylint p1 p2

Pylint output

************* Module p2
p2/__init__.py(3): [C2701(import-private-name)] Imported private object (_Dummy)

Expected behavior

If a project has multiple roots, the check should understand this. Currently it's implemented using path compares in same_root_dir but I think we need a configuration in which I can supply my package roots. If any of them is the start f the import, the import should never be flagged

Pylint version

pylint 4.0.2
astroid 4.0.1
Python 3.14.0 (main, Nov 10 2025, 09:33:32) [GCC 7.5.0]

OS / Environment

Linux

Additional dependencies

Metadata

Metadata

Assignees

No one assigned

    Labels

    Discussion 🤔Needs triage 📥Just created, needs acknowledgment, triage, and proper labelling

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions