Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

grpc_servicer should use *args to pass positional parameters #335

Open
bkeryan opened this issue Jul 17, 2023 · 1 comment
Open

grpc_servicer should use *args to pass positional parameters #335

bkeryan opened this issue Jul 17, 2023 · 1 comment
Labels
tech debt Non-user-visible improvement to code or development process

Comments

@bkeryan
Copy link
Collaborator

bkeryan commented Jul 17, 2023

Tech Debt

The MeasurementService.configuration_parameter decorator describes positional parameters in order, but grpc_servicer uses inspect.signature to look up the parameter names so that it can use **kwargs to pass them:

https://github.com/ni/measurementlink-python/blob/main/ni_measurementlink_service/_internal/grpc_servicer.py#L98
https://github.com/ni/measurementlink-python/blob/main/ni_measurementlink_service/_internal/grpc_servicer.py#L245

Passing positional parameters with *args would be simpler and have slightly lower overhead.

AB#2457623

AB#3037070

@bkeryan bkeryan added the tech debt Non-user-visible improvement to code or development process label Jul 17, 2023
@bkeryan
Copy link
Collaborator Author

bkeryan commented Feb 27, 2025

This also affects whether the measurement function's parameter list is allowed to contain keyword-only parameters, positional-only parameters, *args, or **kwargs.

It could make sense to continue using inspect.signature, but build up separate args and kwargs based on parameter.kind:

  • POSITIONAL_ONLY, POSITIONAL_OR_KEYWORD -> args
  • KEYWORD_ONLY -> kwargs
  • VAR_POSITIONAL, VAR_KEYWORD -> ignored?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tech debt Non-user-visible improvement to code or development process
Projects
None yet
Development

No branches or pull requests

1 participant