-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Respect sys.platform platform check assertion inside functions #9025
Comments
I figured out a hacky workaround for this in #11909. Instead of having if sys.platform != "win32":
assert False |
Just noting that the _WINDOWS_BUILD = hasattr(os, "add_dll_directory")
def some_function():
if _WINDOWS_BUILD:
if sys.platform != "win32":
assert False
# mypy allows Windows-only API usage here
else:
if sys.platform == "win32":
assert False
# mypy allows *nix-only API usage here |
Actually...this seems to break within |
@adam-grant-hendry Mypy only supports testing |
Ah bummer…I kinda figured. Okay, I’ll just |
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: