Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
colinfang opened this issue Aug 9, 2019 · 1 comment
Closed

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

colinfang opened this issue Aug 9, 2019 · 1 comment
Labels

Comments

@colinfang
Copy link

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.

@ilevkivskyi
Copy link
Member

Related #5401, #4637

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants