basedpyright
basedpyright copied to clipboard
"TypeVar constraint type cannot be generic" false positive / incorrect error message when generic defaults reference each other
Description
Code sample in basedpyright playground
class Foo[T = Bar]:...
class Bar[T = Foo]:...
def foo[T: Bar](): ... # TypeVar constraint type cannot be generic (reportGeneralTypeIssues)
it's unclear to me whether there should actually be an error here (i think probably yes) but the error message is wrong
i would have expected the Bar here to be Bar[Any], unless i'm missing something
it would be Bar[Foo[Bar[Foo[...]]]], so i guess that would turn into Bar[Any] because it would otherwise be an infinite recursion that can't be resolved?
oh, hmmmm, i did miss that 😅
we can't have infinitly recursive types? i thought they were supported?
type L = list[L]