Skip to content

self.__class__ is Any, unless I annotate __init__, in which case it is "type" #4065

@douglas-treadwell

Description

@douglas-treadwell

Wouldn't it be better if the type of self.class was the current class?

`class Class(object):
attr = None

def __init__(self):
    # type: () -> None
    reveal_type(self.__class__)
    print(self.__class__.attr)

`

This way, the revealed type is:
Revealed type is 'builtins.type'

If I remove the # type annotation, the revealed type is:
Revealed type is 'Any'

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