Skip to content

self.__class__.__name__ has type Any in class derived from Any #4058

Description

@gvanrossum

Here's something that came up in python/typeshed#1549 (comment).

fromtypingimportAny, Type, TypeVarT=TypeVar('T')
classC(Any):
defbar(self: T) ->Type[T]: ...
deffoo(self) ->None:
reveal_type(self.bar()) # Type[C], as expectedreveal_type(self.bar().__name__) # Any, but expected str

@ilevkivskyi I think you muttered something about analyze_member_access for TypeType still being broken but I'm not sure I understand.

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