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

error: Duplicate argument "self" in function definition #632

Open
rbtz-openai opened this issue Sep 8, 2024 · 2 comments
Open

error: Duplicate argument "self" in function definition #632

rbtz-openai opened this issue Sep 8, 2024 · 2 comments

Comments

@rbtz-openai
Copy link

rbtz-openai commented Sep 8, 2024

I'm using mypy-protobuf to generate types for the envoy protos and getting the following error:

envoy/config/core/v3/config_source_pb2.pyi:109: error: Duplicate argument "self" in function definition

This is due to the original protobuf having an oneof field with a self as a value:

 oneof config_source_specifier {
    option (validate.required) = true;
    string path = 1 [deprecated = true, (envoy.annotations.deprecated_at_minor_version) = "3.0"];
    PathConfigSource path_config_source = 8;
    ApiConfigSource api_config_source = 2;
    AggregatedConfigSource ads = 3;
    SelfConfigSource self = 5;
  }

A snippet from the generated pyi:

class ConfigSource(_message.Message):
    __slots__ = ("authorities", "path", "path_config_source", "api_config_source", "ads", "self", "initial_fetch_timeout", "resource_api_version")
    ...
    path_config_source: PathConfigSource
    api_config_source: ApiConfigSource
    ads: AggregatedConfigSource
    self: SelfConfigSource
    ...
    def __init__(self, authorities: _Optional[_Iterable[_Union[_authority_pb2.Authority, _Mapping]]] = ..., path: _Optional[str] = ..., path_config_source: _Optional[_Union[PathConfigSource, _Mapping]] = ..., api_config_source: _Optional[_Union[ApiConfigSource, _Mapping]] = ..., ads: _Optional[_Union[AggregatedConfigSource, _Mapping]] = ..., self: _Optional[_Union[SelfConfigSource, _Mapping]] = ..., initial_fetch_timeout: _Optional[_Union[_duration_pb2.Duration, _Mapping]] = ..., resource_api_version: _Optional[_Union[ApiVersion, str]] = ...) -> None: ...

I'm using the mypy-protobuf from the buf.build sdk:

python3 -m pip install envoyproxy-envoy-community-nipunn1313-mypy==3.6.0.1.20240722201322+b1787804afc0 --extra-index-url https://buf.build/gen/python
@rbtz-openai rbtz-openai changed the title error: Duplicate argument "self" in function definition error: Duplicate argument "self" in function definition Sep 8, 2024
@rbtz-openai
Copy link
Author

cc: @nipunn1313, long time no see btw! =))

@nipunn1313
Copy link
Owner

Good to hear from you! It's probably because it's a reserved keyword. We should be able to work around it. We can take a look at what the underlying constructor chooses to do in the google generated code and match typing to that.

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

No branches or pull requests

2 participants