Skip to content

E0602 (undefined-variable) - False positive #3298

Open
@arquolo

Description

@arquolo

Given:

> pylint --version
pylint 2.6.0
astroid 2.4.2
Python 3.8.5 (default, Sep  3 2020, 21:29:08) [MSC v.1916 64 bit (AMD64)]

> tree .
.
├──bug
│  ├── __init__.py
│  └── module.py
└──run_bug.py

with bug/__init__.py:

from .module import *

__all__ = module.__all__

and bug/module.py:

__all__ = ['func']

def func() -> None:
    print('works')

and run_bug.py:

from bug import func

func()

code works:

> python -c "import bug ; bug.func()"
works

and this also works:

> python run_bug.py
works

and bug is here:

> pylint bug run_bug --disable=C
************* Module bug
bug\__init__.py:3:10: E1101: Class 'module' has no '__all__' member (no-member)
bug\__init__.py:3:10: E0602: Undefined variable 'module' (undefined-variable)

Problem is that when * is imported from bug.module, module becomes imported to bug, but PyLint thinks that it doesn't.
All I wanted is to delegate filling of __all__ to submodules, like in asyncio.
Explanation is here.

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