sunank200 commented on code in PR #37101: URL: https://github.com/apache/airflow/pull/37101#discussion_r1499033361
########## airflow/models/dataset.py: ########## @@ -374,12 +386,96 @@ def all_datasets(self) -> dict[str, Dataset]: class DatasetAny(DatasetBooleanCondition): - """Use to combine datasets schedule references in an "and" relationship.""" + """ + Represents a logical OR condition of datasets. + + Inherits from DatasetBooleanCondition. + """ agg_func = any + def __init__(self, *objects: Dataset | DatasetAny | DatasetAll): + """Initialize with one or more Dataset, DatasetAny, or DatasetAll instances.""" + super().__init__(*objects) + + def __or__(self, other): + if isinstance(other, (Dataset, DatasetAny, DatasetAll)): + return DatasetAny(*self.objects, other) + return NotImplemented + + def __and__(self, other): + if isinstance(other, (Dataset, DatasetAny, DatasetAll)): + return DatasetAll(self, other) + return NotImplemented + + def __repr__(self) -> str: + return f"DatasetAny({', '.join(map(str, self.objects))})" + class DatasetAll(DatasetBooleanCondition): - """Use to combine datasets schedule references in an "or" relationship.""" + """Represents a logical AND condition of datasets. Inherits from DatasetBooleanCondition.""" agg_func = all + + def __init__(self, *objects: Dataset | DatasetAny | DatasetAll): + """Initialize with one or more Dataset, DatasetAny, or DatasetAll instances.""" + super().__init__(*objects) + + def __or__(self, other): Review Comment: Changed it. ########## airflow/models/dataset.py: ########## @@ -374,12 +386,96 @@ def all_datasets(self) -> dict[str, Dataset]: class DatasetAny(DatasetBooleanCondition): - """Use to combine datasets schedule references in an "and" relationship.""" + """ + Represents a logical OR condition of datasets. + + Inherits from DatasetBooleanCondition. + """ agg_func = any + def __init__(self, *objects: Dataset | DatasetAny | DatasetAll): + """Initialize with one or more Dataset, DatasetAny, or DatasetAll instances.""" + super().__init__(*objects) + + def __or__(self, other): + if isinstance(other, (Dataset, DatasetAny, DatasetAll)): + return DatasetAny(*self.objects, other) + return NotImplemented + + def __and__(self, other): + if isinstance(other, (Dataset, DatasetAny, DatasetAll)): + return DatasetAll(self, other) + return NotImplemented + + def __repr__(self) -> str: + return f"DatasetAny({', '.join(map(str, self.objects))})" + class DatasetAll(DatasetBooleanCondition): - """Use to combine datasets schedule references in an "or" relationship.""" + """Represents a logical AND condition of datasets. Inherits from DatasetBooleanCondition.""" agg_func = all + + def __init__(self, *objects: Dataset | DatasetAny | DatasetAll): + """Initialize with one or more Dataset, DatasetAny, or DatasetAll instances.""" + super().__init__(*objects) + + def __or__(self, other): + if isinstance(other, (Dataset, DatasetAny, DatasetAll)): + return DatasetAny(self, other) + return NotImplemented + + def __and__(self, other): Review Comment: Changed it. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org