tools: Remove assert in template linter.

Currently, in the case where `--modified` is not passed, the linter asserts
that it's checking at least 10 files.  Removing this (somewhat arbitrary)
check makes it easier to:

- Add support for specifying files to check via command line arguments
- Reason about cases where `check-templates` is called from `lint-all`
This commit is contained in:
Elliott Jin 2017-03-19 12:46:01 -07:00 committed by Tim Abbott
parent 12eeb27442
commit 0d677042e7
1 changed files with 6 additions and 10 deletions

View File

@ -40,11 +40,11 @@ def check_our_files():
ftypes=['handlebars', 'html'],
group_by_ftype=True, exclude=EXCLUDED_FILES))
check_handlebar_templates(by_lang['handlebars'], args.modified)
check_html_templates(by_lang['html'], args.modified, args.all_dups)
check_handlebar_templates(by_lang['handlebars'])
check_html_templates(by_lang['html'], args.all_dups)
def check_html_templates(templates, modified_only, all_dups):
# type: (Iterable[str], bool, bool) -> None
def check_html_templates(templates, all_dups):
# type: (Iterable[str], bool) -> None
# Our files with .html extensions are usually for Django, but we also
# have a few static .html files.
# The file base.html has a bit of funny HTML that we can't parse here yet.
@ -98,8 +98,6 @@ def check_html_templates(templates, modified_only, all_dups):
print('Exiting--please clean up all duplicates before running this again.')
sys.exit(1)
if not modified_only:
assert len(templates) >= 10 # sanity check that we are actually doing work
for fn in templates:
# Many of our Django templates have strange indentation. The
# indentation errors are often harmless, even stylistically
@ -196,12 +194,10 @@ def check_html_templates(templates, modified_only, all_dups):
if not validate_indent_html(fn):
sys.exit(1)
def check_handlebar_templates(templates, modified_only):
# type: (Iterable[str], bool) -> None
def check_handlebar_templates(templates):
# type: (Iterable[str]) -> None
# Check all our handlebars templates.
templates = [fn for fn in templates if fn.endswith('.handlebars')]
if not modified_only:
assert len(templates) >= 10 # sanity check that we are actually doing work
for fn in templates:
validate(fn=fn, check_indent=True)