asweigart / pyautogui

A cross-platform GUI automation Python module for human beings. Used to programmatically control the mouse & keyboard.
BSD 3-Clause "New" or "Revised" License
10.18k stars 1.23k forks source link

Please add Type Hints #645

Open Avasam opened 2 years ago

Avasam commented 2 years ago

This should probably be done through type stubs. Here are auto generated ones (I've already filled in FAILSAFE and hotkey since it's what I use): https://github.com/python/typeshed/tree/master/stubs/PyAutoGUI

Avasam commented 2 years ago

3rd party pyautogui type stubs (by myself) have been added to typeshed https://github.com/python/typeshed/pull/8654 & https://github.com/python/typeshed/pull/8684

It'd be best if the stubs were part of pyautogui itself. You should be able to use them directly from typeshed (and they should be fairly accurate). Although they also wouldn't be removed from typeshed until a PyPI release of pyautogui includes the stubs.

Ultimately, the best scenario is to have inline typing directly, as it reduces chances of desync between stubs and implementation, and allows for easy type-checking in the CI and during development. However, due to the Python2 support requirement, inline type comments may be annoying, and will be more complicated to support multiple Python version while trying to keep typing as accurate as possible depending on what said version supports.

Avasam commented 1 year ago

https://github.com/asweigart/pyscreeze/issues/87