Skip to content

Generic Self Type classmethods behave incorrectly on instances #3630

Closed

Description

@rowillia

Repro:

from typing import TypeVar, Tuple, Type

T = TypeVar('T', bound='Friend')

class Friend:
    other = None  # type: Friend

    @classmethod
    def make(cls: Type[T]) -> T:
        return cls()

class SuperFriend(Friend):
    pass

reveal_type(SuperFriend.make())  # Revealed type is 'test_generic_self.SuperFriend*'
reveal_type(SuperFriend().make())  # Revealed type is '<nothing>'

Both invocations should return test_generic_self.SuperFriend*.

Activity

  1. changed the title [-]Generic Self Types behave incorrectly on instances[/-] [+]Generic Self Type classmethods behave incorrectly on instances[/+] on Jun 29, 2017
  2. ilevkivskyi commented on Jun 29, 2017

    @ilevkivskyi
    Member

    This looks like a bug to me.
    @elazarg what do you think?

  3. added
    bug
    on Jun 29, 2017
  4. elazarg commented on Jun 29, 2017

    @elazarg
    Contributor

    Yep

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpriority-1-normal

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions