-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
[BUG] Type ignore annotation used on operating system specific code #9242
Comments
If you rewrite your checks to use If you're unwilling to do that or unable to make it work, the part about I'm closing since I believe everything here is covered by existing issues, but feel free to reply if you need help! |
Writing my function with sys.platform seems to work perfectly ! def is_user_admin() -> bool:
try:
if sys.platform == 'darwin' or sys.platform == 'linux':
return os.getuid() == 0
if sys.platform == 'win32' or sys.platform == 'cygwin':
return ctypes.windll.shell32.IsUserAnAdmin() == 1
except AttributeError:
logger.info(f"Failed to determine if current user is an admin on {sys.platform} operating system.")
raise AdminStateUnknownException Thanks a lot for your help ! Really like mypy, you're doing a great job ;) |
Hello here,
I try to type check the following code using mypy. As there are specific operating system lines of code, I have to tell to mypy to ignore them.
As expected, types are ignored but I have the following error (which seems to be legit too) running the command
python -m mypy --strict admin.py
Obviously I need those annotations cause we have developpers using Windows and other using OSX/Linux.
I try to use the
--warn-unused-ignore
parameter for the command (python -m mypy --strict admin.py --warn-unused-ignore
) but unfortunatly that doesn't seems to work and the error is still an error (breaking my CI 😱 !).I use Python 3.7.7 64-bit and mypy 0.782
The text was updated successfully, but these errors were encountered: