def test_alias_typevar(self) -> None:
pyi_txt = """
from typing import TypeVar
_T = TypeVar('_T', bound=str)
SOME_GLOBAL: int
def fun(error: _T) -> _T: ...
"""
src_txt = """
"Docstring"
from __future__ import print_function
import sys
SOME_GLOBAL: int = 0
def fun(error):
return error
"""
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
"""
self.assertReapply(pyi_txt, src_txt, expected_txt)
self.assertReapplyVisible(pyi_txt, src_txt, expected_txt)
评论列表
文章目录