pytype icon indicating copy to clipboard operation
pytype copied to clipboard

TypeVar bound in different module is ignored

Open mrahtz opened this issue 4 years ago • 0 comments

If a TypeVar is defined with a bound argument, but the TypeVar is in a different module to the one being checked, the bound seems to be ignored. For example:

lib.py:

from typing import Generic, TypeVar
class Axis: pass
A1 = TypeVar('A1', bound=Axis)
class Tensor1(Generic[A1]):
  pass

main.py:

from lib import Tensor1
class A: pass
x: Tensor1[A] = Tensor1()
$ pytype main.py
Computing dependencies
Analyzing 1 sources with 1 local dependencies
ninja: Entering directory `/tmp/tmp/.pytype'
[2/2] check main
Leaving directory '/tmp/tmp/.pytype'
Success: no errors found

(Tested with pytype 2020.09.29.)

Thanks!

mrahtz avatar Nov 09 '20 10:11 mrahtz