Skip to content

Spurious 'undefined-variable' warning with postponed annotations enabled #8215

Open
@SamyCookie

Description

@SamyCookie

Bug description

Hello,

The following raise an unexpected warning.

from __future__ import annotations
class A:
    class B:
        pass
    class C:
        b: B  # undefined-variable

In Python 3.9, Pylint should not raise the undefined-variable warning on B if __future__.annotations has been imported.

Have a good day !

Configuration

No response

Command used

no specific parameters

Pylint output

E0602: Undefined variable 'B' (undefined-variable)

Expected behavior

No warning

Pylint version

pylint 2.16.0
astroid 2.14.1
Python 3.9.2 (default, Feb 28 2021, 17:03:44)

OS / Environment

Debian bullseye 64bit

Additional dependencies

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C: undefined-variableIssues related to 'undefined-variable' checkFalse Positive 🦟A message is emitted but nothing is wrong with the codeNeeds PRThis issue is accepted, sufficiently specified and now needs an implementation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions