-
-
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
How can I make this # type: ignore
platform specific?
#8547
Comments
If you use a mypy-recognized platform check like |
The
The only way to |
Mypy supports what specified in PEP 484 (https://www.python.org/dev/peps/pep-0484/#version-and-platform-checking). We could perhaps extend this to cover more cases, but it's hard to decide where we should draw the line, since the platform checks could be arbitrarily creative. |
@JukkaL I'm having problems with a simple case like: if platform.system() == "Windows":
something_platform_specific() # type: ignore There are some valid cases where you might want to do this, especially for Windows where Edit: I tried with this and it worked: if platform.sys == "win32" or platform.sys == "cygwin":
something_platform_specific() |
There is an open PR #8461 to add support for |
Closing this as a dupe of other issues, basically this entire comment #9242 (comment) applies to this issue |
Found in issue on mypy: python/mypy#8547 (comment)
The project I use, runs both on Windows and Linux. The code is all platform specific, but
mypy
keeps ignoring it:# type: ignore
to lines290
and292
then,mypy
works on Linux, but it fails on Windows witherror: unused 'type: ignore' comment
# type: ignore
from the lines290
and292
then,mypy
works on Windows, but it fails on Linux witherror: Module has no attribute "STARTUPINFO" [attr-defined]
.The
STARTUPINFO
is not defined for Linux Implementations, but is is for Windows implementation. That is why both of them are both protected by aif isWin
orif _mswindows
on this project and on thesubprocess
module implementation:How can I make this
# type: ignore
platform specific?The text was updated successfully, but these errors were encountered: