Skip to content

Commit

Permalink
Use new mypy-protobuf for all Python GRPC builds
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Ron Mordechai authored and facebook-github-bot committed Jun 6, 2024
1 parent b7b807a commit c0ad626
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 11 deletions.
15 changes: 15 additions & 0 deletions idb/grpc/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ async def approve(
ApproveRequest(
bundle_id=bundle_id,
permissions=[APPROVE_MAP[permission] for permission in permissions],
# pyre-ignore
scheme=scheme,
)
)
Expand All @@ -542,6 +543,7 @@ async def revoke(
RevokeRequest(
bundle_id=bundle_id,
permissions=[REVOKE_MAP[permission] for permission in permissions],
# pyre-ignore
scheme=scheme,
)
)
Expand Down Expand Up @@ -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),
)
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -1315,6 +1322,7 @@ async def set_preference(
value=value,
name=name,
value_type=value_type,
# pyre-ignore
domain=domain,
)
)
Expand All @@ -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
Expand Down Expand Up @@ -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,
)
Expand All @@ -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,
)
Expand All @@ -1406,6 +1420,7 @@ async def xctrace_record(
await stream.send_message(
XctraceRecordRequest(
stop=XctraceRecordRequest.Stop(
# pyre-ignore
timeout=stop_timeout,
args=post_args,
)
Expand Down
5 changes: 4 additions & 1 deletion idb/grpc/crash.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]


Expand All @@ -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,
)
2 changes: 2 additions & 0 deletions idb/grpc/hid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

Expand Down
4 changes: 4 additions & 0 deletions idb/grpc/instruments.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions idb/grpc/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

Expand Down
1 change: 1 addition & 0 deletions idb/grpc/tests/hid_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
11 changes: 1 addition & 10 deletions idb/grpc/xctest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
)
Expand Down Expand Up @@ -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 []
]

Expand All @@ -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
Expand Down Expand Up @@ -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 []
],
)
Expand Down

0 comments on commit c0ad626

Please sign in to comment.