Open
Description
This is a feature request
From the docs
https://mypy.readthedocs.io/en/stable/common_issues.html#python-version-and-system-platform-checks
More specifically, mypy will understand the use of sys.version_info and sys.platform checks
within if/elif/else statements.
and
As a special case, you can also use one of these checks in a top-level (unindented) assert; this makes mypy skip the rest of the file.
It would be nice if this kind of code would also typecheck on mac/linux.
Currently the option is to refactor such that you can define the entire function within an if sys.platform == "win32"
class A:
def func_on_win_only() -> str:
assert sys.platform == "win32"
return sys.getwindowsversion()