google / pytype

A static type analyzer for Python code

Home Page:https://google.github.io/pytype

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PyType permits usage of two different types for one TypeVar for Sequance

Frang84 opened this issue · comments

Pytype permits one typeVar (T) for being a sequance of strings and sequance of integers.

T = TypeVar("T")
def functionTab(first: T, second: T) -> T : 
  resultList = []
  for i in first:
    resultList.append(i)
  for i in second:
    resultList.append(i)
  return resultList  

list1 : Sequence[str] = ["dog", "cat"]
list2 : Sequence[int] = [1,2,3]


functionTab(list1, list2)

OUTPUT:
Success: no errors found

Thanks for the report. I see that you've opened three issues for the same TypeVar problem with different container types, so I'm going to condense them down to one.