pyglet / pyglet

pyglet is a cross-platform windowing and multimedia library for Python, for developing games and other visually rich applications.
http://pyglet.org
BSD 3-Clause "New" or "Revised" License
1.9k stars 308 forks source link

PyRight issue when trying to assign value to ScrollableTextLayout. #916

Open DragonMoffon opened 1 year ago

DragonMoffon commented 1 year ago

When using PyRight 1.1.320 with pyglet 2.0.9 there are issues assigning floats or ints to pyglet.text.layout.ScrollableTextLayout.view_y

It produces the error:

error: Operator "+=" not supported for types "SupportsRichComparison | int" and "float"
    Operator "+" not supported for types "SupportsDunderLT[Any]" and "float"
    Operator "+" not supported for types "SupportsDunderGT[Any]" and "float" (reportGeneralTypeIssues)

The error was picked up within the arcade library: https://github.com/pythonarcade/arcade/blob/b4f9d67ec085417ad25bc07548752de6966e7832/arcade/gui/widgets/text.py#L553-L555 But there is nothing that can be done on Arcade's side to fix the issue.

Windows 10, Nvidea RTX 3060 Ti.


platform: Windows-10-10.0.22621-SP0 release: 10 machine: AMD64

Python

implementation: CPython sys.version: 3.10.2 (tags/v3.10.2:a58ebcc, Jan 17 2022, 14:12:15) [MSC v.1929 64 bit (AMD64)] sys.maxint: 9223372036854775807 os.getcwd(): C:\Users\Playtech\Desktop\Code\Python\ArcadeFork\arcade

pyglet

pyglet.version: 2.0.9 pyglet.compat_platform: win32 pyglet.file: C:\Users\Playtech\Desktop\Code\Python\ArcadeFork\arcade\libs\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 0x000001FC3D7AD7B0> screens[0]: Win32Screen(x=0, y=0, width=2560, height=1440) screens[1]: Win32Screen(x=-2560, y=0, width=2560, height=1440) config['double_buffer'] = 1 config['stereo'] = 0 config['buffer_size'] = 32 config['aux_buffers'] = 4 config['sample_buffers'] = 0 config['samples'] = 0 config['red_size'] = 8 config['green_size'] = 8 config['blue_size'] = 8 config['alpha_size'] = 0 config['depth_size'] = 24 config['stencil_size'] = 0 config['accum_red_size'] = 16 config['accum_green_size'] = 16 config['accum_blue_size'] = 16 config['accum_alpha_size'] = 16 config['major_version'] = 3 config['minor_version'] = 3 config['forward_compatible'] = None config['opengl_api'] = 'gl' config['debug'] = None context: Win32ARBContext(id=2182868495728, share=Win32Context(id=2182874850224, share=None))

window.context._info

gl_info.get_version(): (3, 3) gl_info.get_vendor(): NVIDIA Corporation gl_info.get_renderer(): NVIDIA GeForce RTX 3060 Ti/PCIe/SSE2

pyglet.gl.glx_info

GLX not available.

pyglet.media

audio driver: <pyglet.media.drivers.xaudio2.adaptation.XAudio2Driver object at 0x000001FC3D7F1000>

pyglet.media.ffmpeg

FFmpeg not available.

pyglet.media.drivers.openal

OpenAL not available.

pyglet.input.wintab

WinTab: Wintab Digitizer Services 2.0 (Spec 2.0)

pushfoo commented 1 year ago

We also might be able to cast or ignore this on the arcade side. Fwiw, I don't see it locally when running pyright on this: https://github.com/Snipy7374/arcade/pull/1.

benmoran56 commented 1 year ago

The type hint for view_y is intended to be int, because sub-pixel scrolling of text will introduce artifacts. You can scroll by float values, but it's generally not recommended.

DragonMoffon commented 1 month ago

Anyone know if this is still even an issue? I suspect Arcade side it was just slapped with a type: ignore

benmoran56 commented 1 month ago

The type hints are still int on pyglet's side, based on the logic I posted before. This is still part of a larger discussion.