googleapis / gapic-generator-python

Generate Python API client libraries from Protocol Buffers.
Apache License 2.0
122 stars 69 forks source link

Add support for field with name `self` #2206

Closed parthea closed 1 month ago

parthea commented 1 month ago

See message DataSourceReference in google/shopping/merchant/datasources/v1beta/datasourcetypes.proto which has field with name self.

Having a field with the name self is not supported as self is the first argument to instance methods as mentioned in PEP8 here: Always use self for the first argument to instance methods.

From google/shopping/merchant/datasources/v1beta/datasourcetypes.proto,

// Data source reference can be used to manage related data sources within the
// data source service.
message DataSourceReference {
  oneof data_source_id {
    // Self should be used to reference the primary data source itself.
    bool self = 1;

    // Optional. The name of the primary data source.
    // Format:
    // `accounts/{account}/dataSources/{datasource}`
    string primary_data_source_name = 3
        [(google.api.field_behavior) = OPTIONAL];

    // Optional. The name of the supplemental data source.
    // Format:
    // `accounts/{account}/dataSources/{datasource}`
    string supplemental_data_source_name = 2
        [(google.api.field_behavior) = OPTIONAL];
  }
}

See build log here where generated tests fail with error E TypeError: Message.__init__() got multiple values for argument 'self'