def merge()

in lib/metric-config-parser/metric_config_parser/project.py [0:0]


    def merge(self, other: "ProjectSpec") -> None:
        """
        Merge another project spec into the current one.

        The `other` ProjectSpec overwrites existing keys.
        """
        for key in attr.fields_dict(type(self)):
            if key == "population":
                self.population.merge(other.population)
            elif key == "metrics":
                self.metrics += other.metrics
            elif key == "alerts":
                self.alerts += other.alerts
            elif key == "metric_groups":
                self.metric_groups.merge(other.metric_groups)
            else:
                setattr(self, key, getattr(other, key) or getattr(self, key))