Skip to content
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

type ignore under --strict should respect python version checks #10787

Closed
nipunn1313 opened this issue Jul 9, 2021 · 1 comment
Closed

type ignore under --strict should respect python version checks #10787

nipunn1313 opened this issue Jul 9, 2021 · 1 comment
Labels
bug mypy got something wrong

Comments

@nipunn1313
Copy link
Contributor

Bug Report

Using this feature:
https://mypy.readthedocs.io/en/stable/common_issues.html#python-version-and-system-platform-checks
Expecting to be able to # type: ignore conditionally by python version.

To Reproduce

import sys
from typing import Text
x = "hi"  # type: str
y = "hi"  # type: Text
if sys.version_info[0] >= 3:
    x = y
else:
    x = y  # type: ignore

https://mypy-play.net/?mypy=latest&python=3.10&flags=strict&gist=831f7b62f21f6c34b2ef4b490b22e0a0

Expected Behavior

Expected no errors when run targeting both python 3.10 and 2.7

Actual Behavior

Under targeting python 3.10, we see

main.py:8: error: unused "type: ignore" comment
Found 1 error in 1 file (checked 1 source file)
@nipunn1313 nipunn1313 added the bug mypy got something wrong label Jul 9, 2021
@hauntsaninja
Copy link
Collaborator

hauntsaninja commented Jul 9, 2021

Dupe of #8823 (workarounds mentioned in that issue)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

2 participants