Skip to content

Not enough type inference in __init__ with --check-untyped-defs #7309

Closed

Description

@colinfang

mypy v0.720

using --check-untyped-defs

class Foo: pass

class A:
    def __init__(self) 
        self.f1 = Foo()
       # Any
        reveal_type(self.f1)

        self.f2: Foo = Foo()
        # Foo
        reveal_type(self.f2)

class B:
    def __init__(self) -> None:
        self.f1 = Foo()
       # Foo
        reveal_type(self.f1)

I would expect --check-untyped-defs would make A behave like B. However, some type inference seems missing if __init__ is not annotated.

Activity

  1. ilevkivskyi commented on Aug 9, 2019

    @ilevkivskyi
    Member

    Related #5401, #4637

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions