Skip to content
Lesson 3 of 10

Step 1 of 5 · Reading · ~1 min

Read

Lexical 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.

Up nextAST: Tree of CodeAST & Visitors

Discussion

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

Sign in to post a comment or reply.

Loading…