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__.
This commit is contained in:
Eklavya Sharma 2016-07-24 19:28:37 +05:30
parent ecf2249536
commit 2f889550cb
2 changed files with 7 additions and 9 deletions

View File

@ -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):

View File

@ -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