KEMBAR78
self.__class__.__name__ has type Any in class derived from Any · Issue #4058 · python/mypy · GitHub
Skip to content

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

@gvanrossum

Description

@gvanrossum

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

from typing import Any, Type, TypeVar
T = TypeVar('T')
class C(Any):
    def bar(self: T) -> Type[T]: ...
    def foo(self) -> None:
        reveal_type(self.bar())  # Type[C], as expected
        reveal_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