Skip to content

Use dataclass wrappers for nodes instead of modifying nodes directly in pyreverse #7850

Open
@qequ

Description

@qequ

Bug description

when the Linker works over astroid nodes and set attributes for them , e.g. when setting instance_attrs_type

  node.instance_attrs_type = collections.defaultdict(list)

when trying to type hint this attributes like

  node.instance_attrs_type: defaultdict[str, list[...]] = collections.defaultdict(list)

mypy throws an error like this

Type cannot be declared in assignment to non-self attribute [misc]

CC: @DudeNr33

Configuration

No response

Command used

tested with mypy on pre-commit

Pylint output

(no pylint related)

Expected behavior

being able to type hint new attributes for the nodes

Pylint version

(tested with source code)

OS / Environment

ubuntu 20.04

Additional dependencies

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions