Skip to content

Adopt typed gRPC stubs from dp-grpc (dp-grpc#158) #61

Description

@craigmcchesney

dp-grpc is adding mypy-protobuf .pyi stubs to the gRPC package it syncs into src/dp_python_lib/grpc/ (osprey-dcs/dp-grpc#158). The design and cross-repo sequencing live in the dp-grpc plan: plan/tickets/158/plan.md. Its dp-python-lib handoff lists work for a dp-python-lib ticket. This is that ticket, so the dp-python-lib half has a home here rather than only in the other repo's plan.

Step 1: preparation (before the first stub-bearing sync)

Our mypy suppression (exclude plus follow_imports = "skip") does not apply to .pyi files, so the first sync that carries them would turn CI red. Fix those errors ahead of time, in forms that also pass against today's untyped stubs:

  • add types-grpcio to [dev] and drop the grpc ignore_missing_imports override; fix the mldp_client.py channel errors this exposes
  • narrow the unchecked Optionals in machine_config_client.py, the EnumDescriptor | None in query_conversions.py, and the enum ValueType in export_client.py
  • fix the cookbook snippet that rebinds the checker preamble's t1
  • add mypy-protobuf to [codegen]

This must merge before dp-grpc pushes a rel-* tag that includes the #158 implementation. dp-grpc's release checklist gates on it.

Step 5: follow-up (after the sync lands)

  • remove both halves of the dp_python_lib.grpc suppression in pyproject.toml, and update the comment in ci.yml that cites dp-grpc#158
  • type ServiceApiClientBase._stub, e.g. by making the base generic in its stub type (expect new errors to surface)
  • add a py.typed marker
  • confirm the .pyi files and py.typed are in the wheel, using the existing wheel-install CI step
  • expect the cookbook snippet checker to get stricter once the stubs are live
  • update the "Ready for typed gRPC stubs" section in doc/release-notes/NEXT.md rather than adding a second section. If the sync lands in the same cycle as step 1, that release ships the stubs, and the section should say so.

Step 5 cannot come earlier: removing the suppression while the stubs are still untyped brings back roughly 386 errors.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions