mirror of https://github.com/zulip/zulip.git
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:
parent
12eeb27442
commit
0d677042e7
|
@ -40,11 +40,11 @@ def check_our_files():
|
||||||
ftypes=['handlebars', 'html'],
|
ftypes=['handlebars', 'html'],
|
||||||
group_by_ftype=True, exclude=EXCLUDED_FILES))
|
group_by_ftype=True, exclude=EXCLUDED_FILES))
|
||||||
|
|
||||||
check_handlebar_templates(by_lang['handlebars'], args.modified)
|
check_handlebar_templates(by_lang['handlebars'])
|
||||||
check_html_templates(by_lang['html'], args.modified, args.all_dups)
|
check_html_templates(by_lang['html'], args.all_dups)
|
||||||
|
|
||||||
def check_html_templates(templates, modified_only, all_dups):
|
def check_html_templates(templates, all_dups):
|
||||||
# type: (Iterable[str], bool, bool) -> None
|
# type: (Iterable[str], bool) -> None
|
||||||
# Our files with .html extensions are usually for Django, but we also
|
# Our files with .html extensions are usually for Django, but we also
|
||||||
# have a few static .html files.
|
# have a few static .html files.
|
||||||
# The file base.html has a bit of funny HTML that we can't parse here yet.
|
# 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.')
|
print('Exiting--please clean up all duplicates before running this again.')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if not modified_only:
|
|
||||||
assert len(templates) >= 10 # sanity check that we are actually doing work
|
|
||||||
for fn in templates:
|
for fn in templates:
|
||||||
# Many of our Django templates have strange indentation. The
|
# Many of our Django templates have strange indentation. The
|
||||||
# indentation errors are often harmless, even stylistically
|
# 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):
|
if not validate_indent_html(fn):
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def check_handlebar_templates(templates, modified_only):
|
def check_handlebar_templates(templates):
|
||||||
# type: (Iterable[str], bool) -> None
|
# type: (Iterable[str]) -> None
|
||||||
# Check all our handlebars templates.
|
# Check all our handlebars templates.
|
||||||
templates = [fn for fn in templates if fn.endswith('.handlebars')]
|
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:
|
for fn in templates:
|
||||||
validate(fn=fn, check_indent=True)
|
validate(fn=fn, check_indent=True)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue