pyglet.input documentation should declare return typehints
Describe the bug
The function stubs here describe return types, but do not have a return type annotation: https://github.com/pyglet/pyglet/blob/515d7a52a63fc20d76109f06a02f059459ec03b8/pyglet/input/init.py#L81-L136
This means typecheckers and IDE tooling infer the return types to be None.
Related to https://github.com/pythonarcade/arcade/pull/1754 and other tickets where we're trying to adopt pyright in arcade.
System Information:
Details
Platform
------------------------------------------------------------------------------
platform: Windows-10-10.0.22621-SP0
release: 10
machine: AMD64
Python
implementation: CPython
sys.version: 3.11.2 (tags/v3.11.2:878ead1, Feb 7 2023, 16:38:35) [MSC v.1934 64 bit (AMD64)]
sys.maxint: 9223372036854775807
os.getcwd(): C:\Users\cspot\Documents\dev@pythonarcade\arcade\fix-pyright-errors
pyglet
pyglet.version: 2.0.7
pyglet.compat_platform: win32
pyglet.file: C:\Users\cspot\Documents\dev@pythonarcade\arcade\fix-pyright-errors.venv\Lib\site-packages\pyglet_init_.py
pyglet.options['audio'] = ('xaudio2', 'directsound', 'openal', 'pulse', 'silent')
pyglet.options['debug_font'] = False
pyglet.options['debug_gl'] = True
pyglet.options['debug_gl_trace'] = False
pyglet.options['debug_gl_trace_args'] = False
pyglet.options['debug_gl_shaders'] = False
pyglet.options['debug_graphics_batch'] = False
pyglet.options['debug_lib'] = False
pyglet.options['debug_media'] = False
pyglet.options['debug_texture'] = False
pyglet.options['debug_trace'] = False
pyglet.options['debug_trace_args'] = False
pyglet.options['debug_trace_depth'] = 1
pyglet.options['debug_trace_flush'] = True
pyglet.options['debug_win32'] = False
pyglet.options['debug_input'] = False
pyglet.options['debug_x11'] = False
pyglet.options['shadow_window'] = True
pyglet.options['vsync'] = None
pyglet.options['xsync'] = True
pyglet.options['xlib_fullscreen_override_redirect'] = False
pyglet.options['search_local_libs'] = True
pyglet.options['win32_gdi_font'] = False
pyglet.options['headless'] = False
pyglet.options['headless_device'] = 0
pyglet.options['win32_disable_shaping'] = False
pyglet.options['dw_legacy_naming'] = False
pyglet.options['win32_disable_xinput'] = False
pyglet.options['com_mta'] = False
pyglet.options['osx_alt_loop'] = False
pyglet.window
display: <pyglet.canvas.win32.Win32Display object at 0x000002E2ABCDE290>
screens[0]: Win32Screen(x=0, y=0, width=1920, height=1200)
config['double_buffer'] = 1
config['stereo'] = 0
config['buffer_size'] = 32
config['aux_buffers'] = 0
window.context._info
gl_info.get_version(): (3, 3)
gl_info.get_vendor(): Intel
gl_info.get_renderer(): Intel(R) Iris(R) Xe Graphics
pyglet.gl.glx_info
GLX not available.
pyglet.media
audio driver: <pyglet.media.drivers.xaudio2.adaptation.XAudio2Driver object at 0x000002E2ACB99B10>
pyglet.media.ffmpeg
FFmpeg not available.
pyglet.media.drivers.openal
OpenAL not available.
pyglet.input.wintab
WinTab not available.
How To Reproduce A small code example that illustrates the bug is very useful to help triage.
import pyglet.input
foo: list[pyglet.input.Joystick] = pyglet.input.get_joysticks()
# When using a typechecker, you will get a diagnostic for the line above
# Note that this is *not* a runtime exception, it is a typechecker diagnostic
Duplicate of https://github.com/pyglet/pyglet/issues/643 and https://github.com/pyglet/pyglet/issues/809 ?
This is now fixed in the latest point releases.
@Avasam we did a first pass of typing across most (all?) of the public API. If you still see any concerns with your projects, please let us know.