From 8d40e442fd6054a38474415b1525e8d83ee5441e Mon Sep 17 00:00:00 2001 From: Jade Abraham Date: Thu, 31 Oct 2024 16:28:38 -0700 Subject: [PATCH] force a default of None Signed-off-by: Jade Abraham --- test/chplcheck/RuleSettings/RuleSettings.1.good | 4 ++-- test/chplcheck/RuleSettings/RuleSettings.2.good | 4 ++-- test/chplcheck/RuleSettings/RuleSettings.3.good | 4 ++-- test/chplcheck/RuleSettings/RuleSettings.8.good | 4 ++-- test/chplcheck/RuleSettings/rules.py | 10 ++++------ tools/chplcheck/src/rule_types.py | 2 ++ 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/test/chplcheck/RuleSettings/RuleSettings.1.good b/test/chplcheck/RuleSettings/RuleSettings.1.good index b06c3f49a450..845e0ae17960 100644 --- a/test/chplcheck/RuleSettings/RuleSettings.1.good +++ b/test/chplcheck/RuleSettings/RuleSettings.1.good @@ -1,2 +1,2 @@ -In One: Local=None, Global='default' -In Two: Local=None, Global='different default' +In One: Local=None, Global=None +In Two: Local=None, Global=None diff --git a/test/chplcheck/RuleSettings/RuleSettings.2.good b/test/chplcheck/RuleSettings/RuleSettings.2.good index 270f4e537b70..ca929f196f73 100644 --- a/test/chplcheck/RuleSettings/RuleSettings.2.good +++ b/test/chplcheck/RuleSettings/RuleSettings.2.good @@ -1,2 +1,2 @@ -In One: Local='x', Global='default' -In Two: Local=None, Global='different default' +In One: Local='x', Global=None +In Two: Local=None, Global=None diff --git a/test/chplcheck/RuleSettings/RuleSettings.3.good b/test/chplcheck/RuleSettings/RuleSettings.3.good index 2cd141cf89bf..e1c3f99aa98c 100644 --- a/test/chplcheck/RuleSettings/RuleSettings.3.good +++ b/test/chplcheck/RuleSettings/RuleSettings.3.good @@ -1,2 +1,2 @@ -In One: Local=None, Global='default' -In Two: Local='y', Global='different default' +In One: Local=None, Global=None +In Two: Local='y', Global=None diff --git a/test/chplcheck/RuleSettings/RuleSettings.8.good b/test/chplcheck/RuleSettings/RuleSettings.8.good index ca29340a076b..dce8a660d4f2 100644 --- a/test/chplcheck/RuleSettings/RuleSettings.8.good +++ b/test/chplcheck/RuleSettings/RuleSettings.8.good @@ -1,2 +1,2 @@ -In One: Local='y', Global='default' -In Two: Local=None, Global='different default' +In One: Local='y', Global=None +In Two: Local=None, Global=None diff --git a/test/chplcheck/RuleSettings/rules.py b/test/chplcheck/RuleSettings/rules.py index 4fa0f0df420f..7fbf7b2b308d 100644 --- a/test/chplcheck/RuleSettings/rules.py +++ b/test/chplcheck/RuleSettings/rules.py @@ -1,7 +1,7 @@ - from chapel import AstNode from typing import Optional + def var_string(**kwargs): s = [] for k, v in kwargs.items(): @@ -9,17 +9,15 @@ def var_string(**kwargs): s.append(f"{k}={val}") return ", ".join(s) + def rules(driver): @driver.basic_rule(AstNode, settings=[".Local", "Global"]) - def One(context, node, Local: Optional[str]=None, Global: str="default"): - + def One(c, n, Local: Optional[str] = None, Global: Optional[str] = None): print(f"In One:", var_string(Local=Local, Global=Global)) return True @driver.advanced_rule(settings=[".Local", "Global"]) - def Two(context, node, Local: Optional[str]=None, Global: str="different default"): - + def Two(c, n, Local: Optional[str] = None, Global: Optional[str] = None): print(f"In Two:", var_string(Local=Local, Global=Global)) yield from [] - diff --git a/tools/chplcheck/src/rule_types.py b/tools/chplcheck/src/rule_types.py index e405d37a78e7..f2f601439a2b 100644 --- a/tools/chplcheck/src/rule_types.py +++ b/tools/chplcheck/src/rule_types.py @@ -207,6 +207,8 @@ def get_settings_kwargs(self): # either they have no specific rule name, or they match this rule setting_kwargs = {} for setting in self.settings: + # default to None if the setting is not in the driver's settings + setting_kwargs[setting.setting_name] = None # if setting is in the driver's settings, use that value # otherwise, use the default value (ie pass nothing in the kwargs) driver_setting = self.driver.config.rule_settings.get(setting)