Skip to content

Conversation

@RobinMcCorkell
Copy link
Contributor

@RobinMcCorkell RobinMcCorkell commented Sep 25, 2025

ServerInterceptor and GenericRpcHandler should not be generic over request/response themselves, but rather should have generic methods:

  • ServerInterceptor: a given instance of this should be able to intercept any call, and so should have a generic method over all request/continuation types rather than the instance being specialized itself
  • GenericRpcHandler (and ServiceRpcHandler): this is "An implementation of arbitrarily many RPC methods" and has a service method that takes a parameter describing the method to handle, but that parameter dictates the request/response types. The instance of the GenericRpcHandler itself does not know about the request/response types. In theory this could be described using dependent types, but since this is Python the best we can do is have the service method return a type with Anys and allow the caller to cast later

Related: #14641

@github-actions
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@RobinMcCorkell
Copy link
Contributor Author

@srittau as you reviewed the previous grpcio PR, could you review this one please?

Copy link
Collaborator

@srittau srittau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, good catch!

@srittau srittau merged commit 602da37 into python:main Sep 30, 2025
48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants