Skip to content
Comments & Pragmas
step 1/5

Reading — step 1 of 5

Read

~1 min readLexical Analysis

Comments & Pragmas

Comments are normally skipped, BUT linters use them for:

  • Suppressions: # noqa: E501 disables rule E501 on this line.
  • File-level: # pylint: disable=missing-docstring for whole file.
  • Region: # pylint: disable-next=foo, # pylint: enable=foo.
  • TODO scanning: highlight # TODO, # FIXME, # HACK.

Implementation:

python

When emitting a diagnostic:

python

TODO scanner:

python

Suppressions are powerful but easy to abuse — every # noqa is a place where you've turned off the linter. Best practice: be specific (# noqa: E501) and add a comment WHY.

Discussion

Ask a question, share an insight, or help someone who’s stuck.

Sign in to post a comment or reply.

Loading…