Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 6 additions & 1 deletion mypy/stubgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
from mypy.stubdoc import parse_all_signatures, find_unique_signatures, Sig
from mypy.options import Options as MypyOptions
from mypy.types import (
Type, TypeStrVisitor, CallableType,
Type, TypeStrVisitor, CallableType, AnyType,
UnboundType, NoneType, TupleType, TypeList,
)
from mypy.visitor import NodeVisitor
Expand Down Expand Up @@ -166,6 +166,11 @@ def __init__(self, stubgen: 'StubGenerator') -> None:
super().__init__()
self.stubgen = stubgen

def visit_any(self, t: AnyType) -> str:
s = super().visit_any(t)
self.stubgen.import_tracker.require_name(s)
return s

def visit_unbound_type(self, t: UnboundType) -> str:
s = t.name
self.stubgen.import_tracker.require_name(s)
Expand Down
20 changes: 20 additions & 0 deletions test-data/unit/stubgen.test
Original file line number Diff line number Diff line change
Expand Up @@ -1460,3 +1460,23 @@ def f(x):
from typing import Any

def f(x: Any): ...

[case testFunctionPartiallyAnnotated]
def f(x) -> None:
pass

def g(x, y: str):
pass

class A:
def f(self, x) -> None:
pass

[out]
from typing import Any

def f(x: Any) -> None: ...
def g(x: Any, y: str) -> Any: ...

class A:
def f(self, x: Any) -> None: ...