def test_alias_many(self) -> None:
pyi_txt = """
from typing import TypeVar
_T = TypeVar('_T', bound=str)
_EitherStr = Union[str, bytes]
_MaybeStrings = List[Optional[_EitherStr]]
SOME_GLOBAL: int
def fun(error: _T) -> _T: ...
def fun2(errors: _MaybeStrings) -> None: ...
"""
src_txt = """
"Docstring"
from __future__ import print_function
import sys
SOME_GLOBAL: int = 0
def fun(error):
return error
@decorator
def fun2(errors) -> None:
for error in errors:
if not error:
continue
print(error, file=sys.stderr)
"""
expected_txt = """
"Docstring"
from __future__ import print_function
import sys
from typing import TypeVar
SOME_GLOBAL: int = 0
_T = TypeVar('_T', bound=str)
def fun(error: _T) -> _T:
return error
_EitherStr = Union[str, bytes]
_MaybeStrings = List[Optional[_EitherStr]]
@decorator
def fun2(errors: _MaybeStrings) -> None:
for error in errors:
if not error:
continue
print(error, file=sys.stderr)
"""
self.assertReapply(pyi_txt, src_txt, expected_txt)
self.assertReapplyVisible(pyi_txt, src_txt, expected_txt)
评论列表
文章目录