diff --git a/dbt_common/behavior_flags.py b/dbt_common/behavior_flags.py index 3dc9ce8..3a85022 100644 --- a/dbt_common/behavior_flags.py +++ b/dbt_common/behavior_flags.py @@ -39,6 +39,10 @@ def setting(self) -> bool: def setting(self, value: bool) -> None: self._setting = value + @property + def no_warn(self) -> bool: + return self._setting + def __bool__(self) -> bool: return self.setting diff --git a/tests/unit/test_behavior_flags.py b/tests/unit/test_behavior_flags.py index a40ea52..b719faf 100644 --- a/tests/unit/test_behavior_flags.py +++ b/tests/unit/test_behavior_flags.py @@ -103,3 +103,22 @@ def test_behavior_flags_emit_correct_deprecation(event_catcher) -> None: assert msg.info.name == "BehaviorDeprecationEvent" assert msg.data.flag_name == "flag_false" assert msg.data.flag_source == __name__ # defaults to the calling module + + +def test_behavior_flags_no_deprecation_event_on_no_warn(event_catcher) -> None: + behavior = register( + behavior_flags=[ + {"name": "flag_false", "default": False}, + ], + user_flags={}, + ) + + # trigger the evaluation with no_warn, no event should fire + if behavior.flag_false.no_warn: + pass + assert len(event_catcher.caught_events) == 0 + + # trigger the evaluation, an event should fire + if behavior.flag_false: + pass + assert len(event_catcher.caught_events) == 1