fix: support gazelle generation_mode:update_only by jbedard · Pull Request #2708 · bazel-contrib/rules_python

@@ -134,12 +134,20 @@ type Configs map[string]*Config

// ParentForPackage returns the parent Config for the given Bazel package.
func (c *Configs) ParentForPackage(pkg string) *Config {

Choose a reason for hiding this comment

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

Since map is a reference type, could you please update the receiver arg to be a type of c Configs please?

func (c *Configs) ParentForPackage(pkg string) *Config {
func (c Configs) ParentForPackage(pkg string) *Config {
if dir == "" {
return nil
}
pkg = dir

Choose a reason for hiding this comment

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

Could you add a unit test for this new logic? Just testing the Configs in isolation would be sufficient.

Right now it is a little bit hard to read and having tests would help understand what this has to do.

Choose a reason for hiding this comment

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

I've added a few basic tests for this method.

There should probably be some additional full tests for update_only and mixing that with the different python_generation_mode modes but I'm not familiar enough with it to do in this initial PR.