Skip to content

[question] proper type annotation for __dict__ #6523

Closed
@AMDmi3

Description

@AMDmi3

I'm wondering which is the correct way of annotating __dict__ property. Dict[str, Any] seem quite obvious and is used multiple times in typeshed, but:

from typing import Any, Dict

class Test:
    @property
    def __dict__(self) -> Dict[str, Any]:
        return {}
% mypy test.py 
test.py:5: error: Signature of "__dict__" incompatible with supertype "object"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions