From 08e44aac0d7bf0b5ad5c218f285dc79f16d06537 Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Sat, 10 Nov 2018 19:04:07 +0000 Subject: [PATCH] lint: Extract get_rules_applying_to_fn(). --- tools/linter_lib/custom_check.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/tools/linter_lib/custom_check.py b/tools/linter_lib/custom_check.py index f7247e9b1d..72b3f7e36b 100644 --- a/tools/linter_lib/custom_check.py +++ b/tools/linter_lib/custom_check.py @@ -74,15 +74,7 @@ def get_line_info_from_file(fn: str) -> List[LineTup]: line_tups.append(tup) return line_tups -def custom_check_file(fn: str, - identifier: str, - rules: RuleList, - color: Optional[Iterable[str]], - max_length: Optional[int]=None) -> bool: - failed = False - - line_tups = get_line_info_from_file(fn=fn) - +def get_rules_applying_to_fn(fn: str, rules: RuleList) -> RuleList: rules_to_apply = [] for rule in rules: excluded = False @@ -101,6 +93,19 @@ def custom_check_file(fn: str, continue rules_to_apply.append(rule) + return rules_to_apply + +def custom_check_file(fn: str, + identifier: str, + rules: RuleList, + color: Optional[Iterable[str]], + max_length: Optional[int]=None) -> bool: + failed = False + + line_tups = get_line_info_from_file(fn=fn) + + rules_to_apply = get_rules_applying_to_fn(fn=fn, rules=rules) + for rule in rules_to_apply: exclude_lines = { line for