From 2f889550cbddb29c4d86f724d818637256562385 Mon Sep 17 00:00:00 2001 From: Eklavya Sharma Date: Sun, 24 Jul 2016 19:28:37 +0530 Subject: [PATCH] tools/check-templates: Use __init__ in Record. Initialize Record by using __init__ instead of setting attributes in validate. This is needed because mypy complains when we set new attributes outside __init__. --- tools/check-templates | 15 +++++++-------- tools/run-mypy | 1 - 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/tools/check-templates b/tools/check-templates index 9369d22b28..ef9dd32dfd 100755 --- a/tools/check-templates +++ b/tools/check-templates @@ -17,13 +17,16 @@ except ImportError as e: sys.exit(1) class Record(object): - pass + def __init__(self, func): + self.depth = 0 + self.i = 0 + self.line = 1 + self.col = 1 + self.matcher = func def validate(fn, check_indent=True): text = open(fn).read() - state = Record() - def NoStartTag(end_tag): raise Exception(''' No start tag @@ -60,11 +63,7 @@ def validate(fn, check_indent=True): state.depth -= 1 state.matcher = f - state.depth = 0 - state.i = 0 - state.line = 1 - state.col = 1 - state.matcher = NoStartTag + state = Record(NoStartTag) def advance(n): for _ in range(n): diff --git a/tools/run-mypy b/tools/run-mypy index 754c7de5df..31c26a1b49 100755 --- a/tools/run-mypy +++ b/tools/run-mypy @@ -59,7 +59,6 @@ api/integrations/twitter/twitter-search-bot bots/check-mirroring bots/gcal-bot bots/githook-post-receive -tools/check-templates tools/compile-handlebars-templates tools/deprecated/inject-messages/inject-messages tools/deprecated/review