Skip to content

Make return type implicitly None for type checked __init__ and __init_subclass__ #5677

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

Merged
merged 8 commits into from
Oct 1, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add overloaded tests
  • Loading branch information
onlined committed Sep 26, 2018
commit d65bb747ff597bd9f3e5dc7312fa1530fbf0632f
26 changes: 26 additions & 0 deletions test-data/unit/check-classes.test
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,19 @@ class A:
def __init__(self, x: int): pass
[out]

[case testOverloadedConstructorWithImplicitReturnValueType]
from foo import *
[file foo.pyi]
from typing import overload
class Foo:
@overload
def __init__(self, a: int):
pass

@overload
def __init__(self, a: str):
pass

[case testInitSubclassWithReturnValueType]
import typing
class A:
Expand All @@ -615,6 +628,19 @@ class A:
def __init_subclass__(cls, x: int=1): pass
[out]

[case testOverloadedConstructorWithImplicitReturnValueType]
from foo import *
[file foo.pyi]
from typing import overload
class Foo:
@overload
def __init_subclass__(cls, a: int):
pass

@overload
def __init_subclass__(cls, a: str):
pass

[case testGlobalFunctionInitWithReturnType]
import typing
a = __init__() # type: A
Expand Down