From 827583c14a3717cf80b8896dca3da8187c488e18 Mon Sep 17 00:00:00 2001 From: basile Date: Tue, 7 Mar 2023 15:35:21 -0500 Subject: [PATCH 1/3] fix with statement for python 3.8 compat --- .../video_capture/neon_backend/background.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/pupil_src/shared_modules/video_capture/neon_backend/background.py b/pupil_src/shared_modules/video_capture/neon_backend/background.py index a3299c14e..dd1721793 100644 --- a/pupil_src/shared_modules/video_capture/neon_backend/background.py +++ b/pupil_src/shared_modules/video_capture/neon_backend/background.py @@ -75,15 +75,12 @@ def _event_loop( ipc_push_url: str, topic_prefix: str = "shared_camera.", ): - with ( - NetworkInterface( + with NetworkInterface( topic_prefix=topic_prefix, ipc_pub_url=ipc_pub_url, ipc_sub_url=ipc_sub_url, ipc_push_url=ipc_push_url, - ) as network, - contextlib.suppress(KeyboardInterrupt), - ): + ) as network, contextlib.suppress(KeyboardInterrupt): process_started_event.set() camera_model = cm.Camera_Model.from_file( From 33d15bbd60f04259a27048755e8b10d84ffdf092 Mon Sep 17 00:00:00 2001 From: basile Date: Tue, 7 Mar 2023 15:54:33 -0500 Subject: [PATCH 2/3] black --- .../video_capture/neon_backend/background.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pupil_src/shared_modules/video_capture/neon_backend/background.py b/pupil_src/shared_modules/video_capture/neon_backend/background.py index dd1721793..69c0fffd7 100644 --- a/pupil_src/shared_modules/video_capture/neon_backend/background.py +++ b/pupil_src/shared_modules/video_capture/neon_backend/background.py @@ -75,12 +75,12 @@ def _event_loop( ipc_push_url: str, topic_prefix: str = "shared_camera.", ): - with NetworkInterface( - topic_prefix=topic_prefix, - ipc_pub_url=ipc_pub_url, - ipc_sub_url=ipc_sub_url, - ipc_push_url=ipc_push_url, - ) as network, contextlib.suppress(KeyboardInterrupt): + with NetworkInterface( + topic_prefix=topic_prefix, + ipc_pub_url=ipc_pub_url, + ipc_sub_url=ipc_sub_url, + ipc_push_url=ipc_push_url, + ) as network, contextlib.suppress(KeyboardInterrupt): process_started_event.set() camera_model = cm.Camera_Model.from_file( From 8d88d3a97f3a6a64b948c9951bb6af8190c64e24 Mon Sep 17 00:00:00 2001 From: basile Date: Mon, 27 Mar 2023 16:17:18 -0400 Subject: [PATCH 3/3] use typing.get_type_hints for all python3 versions --- .../gaze_mapping/notifications.py | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/pupil_src/shared_modules/gaze_mapping/notifications.py b/pupil_src/shared_modules/gaze_mapping/notifications.py index a265fd332..504acfb7a 100644 --- a/pupil_src/shared_modules/gaze_mapping/notifications.py +++ b/pupil_src/shared_modules/gaze_mapping/notifications.py @@ -15,23 +15,7 @@ from typing_extensions import Self, TypedDict -if sys.version_info < (3, 9): - - def get_type_hints(cls): - return cls.__annotations__ - -else: - # Starting in Python 3.10, __annotations__ does no longer contain the annotations - # of the parent class. `_SerializedNamedTupleMixin.sanitize_serialized_dict` - # depends on the earlier implementation. - # We do not use `inspect.get_annotations()` as a replacement for two reasons: - # 1. It also does not include the base classes' annoations - # 2. The annotations might not be evaluated yet, containing `typing.ForwardRef` - # instances - # - # `typing.get_type_hints` implements the desired behavior but is only available in - # Python 3.9 or newer - from typing import get_type_hints +from typing import get_type_hints # TODO: Consider extending this pattern for notifications through the entire codebase and/or replace with dataclasses with Python 3.7