Skip to content

Better support for PEP 526 instance and classvar annotations #2945

Closed
@belm0

Description

@belm0

Steps to reproduce

A class which doesn't have __init__ (it may set attributes in __new__, for example) will yield no-member when instance attributes are accessed.

I tried to resolve it with PEP 526 instance var annotations which don't have assignment (i.e. type only), but still get no-member error.

class Foo:
    bar:  int
    ...

x = Foo()
x.bar

Current behavior

E1101: Instance of 'Foo' has no 'bar' member (no-member)

Expected behavior

no warnings

pylint --version output

pylint 2.3.1
astroid 2.3.0
Python 3.7.0b3 (default, Aug 25 2018, 16:41:39)
[Clang 9.0.0 (clang-900.0.39.2)]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions