Skip to content
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

win32gui.SystemParametersInfo returns values but pyi says None #13426

Open
huntfx opened this issue Jan 22, 2025 · 1 comment
Open

win32gui.SystemParametersInfo returns values but pyi says None #13426

huntfx opened this issue Jan 22, 2025 · 1 comment
Labels
stubs: false positive Type checkers report false errors

Comments

@huntfx
Copy link

huntfx commented Jan 22, 2025

https://github.com/python/typeshed/blob/main/stubs/pywin32/win32/win32gui.pyi#L451

SystemParametersInfo will return different types based on the variable given to it, but the pyi file says it returns None. Maybe Any would work in this case? The alternative would be to hardcode each variable which would be quite excessive.

>>> win32gui.SystemParametersInfo(win32con.SPI_GETWHEELSCROLLLINES)
5
>>> win32gui.SystemParametersInfo(win32con.SPI_GETDESKWALLPAPER)
'c:\\wallpapers\\horizontal\\3357822.jpg'
>>> win32gui.SystemParametersInfo(win32con.SPI_GETWORKAREA)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NotImplementedError: Action 48 is not supported yet

These are all the types/exceptions of the SPI_GET* variables:

  • int
  • bool
  • str
  • tuple
  • dict
  • PyLOGFONT
  • NotImplementedError

And for SPI_SET*:

  • None
  • TypeError
  • NotImplementedError
@srittau srittau added the stubs: false positive Type checkers report false errors label Jan 22, 2025
@srittau
Copy link
Collaborator

srittau commented Jan 22, 2025

None sounds wrong, using Any with a comment is probably the best solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stubs: false positive Type checkers report false errors
Projects
None yet
Development

No branches or pull requests

2 participants