Skip to content

New semantic analyzer: invalid type variable produces additional error #6957

@ilevkivskyi

Description

@ilevkivskyi

This test case fails:

[case testMoreInvalidTypevarArguments]
from typing import TypeVar

defer: Yes

S = TypeVar('S', covariant=True, contravariant=True)  # E: TypeVar cannot be both covariant and contravariant

class Yes: ...
[builtins fixtures/bool.pyi]

because there is an additional (and somewhat confusing) error:

Cannot redefine 'S' as a type variable

See also #6300 and #6563 (ideally, the latter should also fix this issue).

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions