Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ilevkivskyi opened this issue Jun 7, 2019 · 1 comment · Fixed by #7093
Closed

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

ilevkivskyi opened this issue Jun 7, 2019 · 1 comment · Fixed by #7093
Assignees
Labels
bug mypy got something wrong priority-1-normal semantic-analyzer Problems that happen during semantic analysis topic-usability

Comments

@ilevkivskyi
Copy link
Member

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).

@ilevkivskyi ilevkivskyi added priority-2-low topic-usability semantic-analyzer Problems that happen during semantic analysis labels Jun 7, 2019
@JukkaL JukkaL added the bug mypy got something wrong label Jun 12, 2019
@ilevkivskyi
Copy link
Member Author

This is quite annoying when testing (namely when running tests with an extra iteration), so raising priority to normal.

@ilevkivskyi ilevkivskyi self-assigned this Jun 28, 2019
JukkaL pushed a commit that referenced this issue Jun 28, 2019
…7093)

Fixes #6957

Using the opportunity, I do a tiny refactoring. The only change in the 
logic is switching the order of things.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong priority-1-normal semantic-analyzer Problems that happen during semantic analysis topic-usability
Projects
None yet
2 participants