From c0ad6269087d943b4e26e4c33525260bb825fba4 Mon Sep 17 00:00:00 2001 From: Ron Mordechai Date: Thu, 6 Jun 2024 15:53:34 -0700 Subject: [PATCH] Use new mypy-protobuf for all Python GRPC builds Summary: The mypy-protobuf we use doesn't support proto3 optional fields. It's also really really outdated. The project has since been rewritten in Python. The previous diffs in the stack import it, this one moves the protobuf compiler to use the new version. Reviewed By: c-ryan747 Differential Revision: D58193786 fbshipit-source-id: e83ae25db2cc7d3ea99953d33dd44fde22cc792d --- idb/grpc/client.py | 15 +++++++++++++++ idb/grpc/crash.py | 5 ++++- idb/grpc/hid.py | 2 ++ idb/grpc/instruments.py | 4 ++++ idb/grpc/target.py | 3 +++ idb/grpc/tests/hid_tests.py | 1 + idb/grpc/xctest.py | 11 +---------- 7 files changed, 30 insertions(+), 11 deletions(-) diff --git a/idb/grpc/client.py b/idb/grpc/client.py index f4bb96399..3ae701a9f 100644 --- a/idb/grpc/client.py +++ b/idb/grpc/client.py @@ -527,6 +527,7 @@ async def approve( ApproveRequest( bundle_id=bundle_id, permissions=[APPROVE_MAP[permission] for permission in permissions], + # pyre-ignore scheme=scheme, ) ) @@ -542,6 +543,7 @@ async def revoke( RevokeRequest( bundle_id=bundle_id, permissions=[REVOKE_MAP[permission] for permission in permissions], + # pyre-ignore scheme=scheme, ) ) @@ -812,6 +814,7 @@ async def pull( src_path=src_path, # not sending the destination to remote companion # so it streams the file back + # pyre-ignore dst_path=dest_path if self.is_local else None, container=file_container_to_grpc(container), ) @@ -1067,6 +1070,7 @@ async def record_video(self, stop: asyncio.Event, output_file: str) -> None: else: self.logger.info("Starting video recording with response data") await stream.send_message( + # pyre-ignore RecordRequest(start=RecordRequest.Start(file_path=None)) ) await stop.wait() @@ -1102,6 +1106,7 @@ async def stream_video( VideoStreamRequest( start=VideoStreamRequest.Start( file_path=output_file, + # pyre-ignore fps=fps, format=VIDEO_FORMAT_MAP[format], compression_quality=compression_quality, @@ -1114,7 +1119,9 @@ async def stream_video( await stream.send_message( VideoStreamRequest( start=VideoStreamRequest.Start( + # pyre-ignore file_path=None, + # pyre-ignore fps=fps, format=VIDEO_FORMAT_MAP[format], compression_quality=compression_quality, @@ -1315,6 +1322,7 @@ async def set_preference( value=value, name=name, value_type=value_type, + # pyre-ignore domain=domain, ) ) @@ -1328,6 +1336,7 @@ async def get_locale(self) -> str: @log_and_handle_exceptions("get_setting") async def get_preference(self, name: str, domain: Optional[str]) -> str: response = await self.stub.get_setting( + # pyre-ignore GetSettingRequest(setting=AnySetting, name=name, domain=domain) ) return response.value @@ -1376,9 +1385,12 @@ async def xctrace_record( else: target = XctraceRecordRequest.Target( launch_process=XctraceRecordRequest.LauchProcess( + # pyre-ignore process_to_launch=process_to_launch, launch_args=launch_args, + # pyre-ignore target_stdin=target_stdin, + # pyre-ignore target_stdout=target_stdout, process_env=process_env, ) @@ -1387,7 +1399,9 @@ async def xctrace_record( XctraceRecordRequest( start=XctraceRecordRequest.Start( template_name=template_name, + # pyre-ignore time_limit=time_limit, + # pyre-ignore package=package, target=target, ) @@ -1406,6 +1420,7 @@ async def xctrace_record( await stream.send_message( XctraceRecordRequest( stop=XctraceRecordRequest.Stop( + # pyre-ignore timeout=stop_timeout, args=post_args, ) diff --git a/idb/grpc/crash.py b/idb/grpc/crash.py index ce988bf53..ab96e31e0 100644 --- a/idb/grpc/crash.py +++ b/idb/grpc/crash.py @@ -18,7 +18,6 @@ def _to_crash_log_info_list(response: CrashLogResponse) -> List[CrashLogInfo]: - # pyre-fixme[16]: `RepeatedCompositeFieldContainer` has no attribute `__iter__`. return [_to_crash_log_info(proto) for proto in response.list] @@ -40,8 +39,12 @@ def _to_crash_log(proto: CrashShowResponse) -> CrashLog: def _to_crash_log_query_proto(query: CrashLogQuery) -> CrashLogQueryProto: return CrashLogQueryProto( + # pyre-ignore before=query.before, + # pyre-ignore since=query.since, + # pyre-ignore bundle_id=query.bundle_id, + # pyre-ignore name=query.name, ) diff --git a/idb/grpc/hid.py b/idb/grpc/hid.py index a17d3f6ec..168a41adc 100644 --- a/idb/grpc/hid.py +++ b/idb/grpc/hid.py @@ -102,7 +102,9 @@ def swipe_to_grpc(swipe: HIDSwipe) -> GrpcHIDSwipe: return GrpcHIDSwipe( start=point_to_grpc(swipe.start), end=point_to_grpc(swipe.end), + # pyre-ignore delta=swipe.delta, + # pyre-ignore duration=swipe.duration, ) diff --git a/idb/grpc/instruments.py b/idb/grpc/instruments.py index d90a96278..122544f7d 100644 --- a/idb/grpc/instruments.py +++ b/idb/grpc/instruments.py @@ -71,9 +71,13 @@ def translate_instruments_timings( ) -> Optional[InstrumentsRunRequest.InstrumentsTimings]: return ( InstrumentsRunRequest.InstrumentsTimings( + # pyre-ignore terminate_timeout=timings.terminate_timeout, + # pyre-ignore launch_retry_timeout=timings.launch_retry_timeout, + # pyre-ignore launch_error_timeout=timings.launch_error_timeout, + # pyre-ignore operation_duration=timings.operation_duration, ) if timings diff --git a/idb/grpc/target.py b/idb/grpc/target.py index 725fa7b2f..c16901f7d 100644 --- a/idb/grpc/target.py +++ b/idb/grpc/target.py @@ -57,8 +57,11 @@ def screen_dimensions_to_grpc(dimensions: ScreenDimensions) -> GrpcScreenDimensi return GrpcScreenDimensions( width=dimensions.width, height=dimensions.height, + # pyre-ignore density=dimensions.density, + # pyre-ignore width_points=dimensions.width_points, + # pyre-ignore height_points=dimensions.height_points, ) diff --git a/idb/grpc/tests/hid_tests.py b/idb/grpc/tests/hid_tests.py index 1d148880e..1a4e2f164 100644 --- a/idb/grpc/tests/hid_tests.py +++ b/idb/grpc/tests/hid_tests.py @@ -66,6 +66,7 @@ def test_swipe(self) -> None: swipe=GrpcHIDSwipe( start=GrpcPoint(x=1, y=2), end=GrpcPoint(x=3, y=4), + # pyre-ignore delta=delta, duration=0.5, ) diff --git a/idb/grpc/xctest.py b/idb/grpc/xctest.py index 38a0b65a9..8bbabd0e4 100644 --- a/idb/grpc/xctest.py +++ b/idb/grpc/xctest.py @@ -125,6 +125,7 @@ def make_request( mode = Mode( ui=UI( app_bundle_id=app_bundle_id, + # pyre-ignore test_host_app_bundle_id=test_host_app_bundle_id, ) ) @@ -191,9 +192,6 @@ def make_results( ], crashed=result.status == XctestRunResponse.TestRunInfo.CRASHED, ) - # pyre-fixme[16]: Item `RepeatedCompositeFieldContainer` of - # `Union[RepeatedCompositeFieldContainer[], List[typing.Any]]` has no - # attribute `__iter__`. for result in response.results or [] ] @@ -212,7 +210,6 @@ def make_failure_info(result: XctestRunResponse.TestRunInfo) -> TestRunFailureIn + " " + result.failure_info.failure_message ) - # pyre-fixme[16]: `RepeatedCompositeFieldContainer` has no attribute `__iter__`. for other_failure in result.other_failures: message = ( message @@ -247,16 +244,10 @@ def translate_activity( uniform_type_identifier=attachment.uniform_type_identifier, user_info_json=attachment.user_info_json, ) - # pyre-fixme[16]: Item `RepeatedCompositeFieldContainer` of - # `Union[RepeatedCompositeFieldContainer[], List[typing.Any]]` has no - # attribute `__iter__`. for attachment in activity.attachments or [] ], sub_activities=[ translate_activity(sub_activity) - # pyre-fixme[16]: Item `RepeatedCompositeFieldContainer` of - # `Union[RepeatedCompositeFieldContainer[], List[typing.Any]]` has no - # attribute `__iter__`. for sub_activity in activity.sub_activities or [] ], )