You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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"
Just noting that the assert False form also works when filtering out single code branches within a larger function using a library or application specific check. For example:
_WINDOWS_BUILD=hasattr(os, "add_dll_directory")
defsome_function():
if_WINDOWS_BUILD:
ifsys.platform!="win32":
assertFalse# mypy allows Windows-only API usage hereelse:
ifsys.platform=="win32":
assertFalse# mypy allows *nix-only API usage here
This is a feature request
From the docs
https://mypy.readthedocs.io/en/stable/common_issues.html#python-version-and-system-platform-checks
and
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"
The text was updated successfully, but these errors were encountered: