You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Another reason why I asked is a {% block content %} definition in a base template which spans more than one line (i.e., the endblock is in a subsequent line. It's not going to be executed so I was wondering if there is a way to ignore them.
I hit this too and found the actual cause — at least for {% comment %} blocks it is not a missing "ignore" feature, it is a bug in the line mapping.
In plugin.py, the token loop handles endcommentbefore the extends-skip, but the comment opener after it:
ifextendsandnotinblock:
# In an inheriting template, ignore all tags outside of# blocks.continueiftoken.contents=="comment":
comment=True
So in a template that {% extends %} something, a {% comment %} opener placed outside a {% block %} is skipped by the extends and not inblock continue and comment = True is never set. The interior lines of the comment are then processed as regular content and reported as missing — they can never execute.
Minimal repro:
{%extends"base.html"%}{% comment %}this line is reported as a missing line{% endcomment %}{%blockcontent%}covered{%endblock%}
The fix is to check for the comment opener before the extends-skip, the same way endcomment already is. I can send a PR if you want.
Activity
nedbat commentedon May 6, 2020
The plugin is written to understand comment blocks and ignore them. Can you provide us with a reproducible test case?
mschoettle commentedon May 7, 2020
I have a template file containing the above block:
And a test function like this:
The relevant part of
setup.cfgis as follows:Another reason why I asked is a
{% block content %}definition in a base template which spans more than one line (i.e., the endblock is in a subsequent line. It's not going to be executed so I was wondering if there is a way to ignore them.marcgibbons commentedon Apr 4, 2026
@nedbat I'm taking a stab at this one: getting a no pragma / exclude_lines implementation that mirrors the one for Python modules
nedbat commentedon Apr 7, 2026
Thanks, looking forward to it.
PetrDlouhy commentedon Jul 22, 2026
I hit this too and found the actual cause — at least for
{% comment %}blocks it is not a missing "ignore" feature, it is a bug in the line mapping.In
plugin.py, the token loop handlesendcommentbefore the extends-skip, but thecommentopener after it:So in a template that
{% extends %}something, a{% comment %}opener placed outside a{% block %}is skipped by theextends and not inblockcontinue andcomment = Trueis never set. The interior lines of the comment are then processed as regular content and reported as missing — they can never execute.Minimal repro:
The fix is to check for the
commentopener before the extends-skip, the same wayendcommentalready is. I can send a PR if you want.