1. Install pyglint.
  2. Write a linter.

A checker takes a node and yields Problem objects.

class pyglint.Problem(name, text, explanation, id)[source]

A problem found by a checker.

  • name (str) – The name of the problem. Usually 2-4 words, hyphenated.
  • text – The message text for display to the user. str.format() syntax is
  • Usually one short sentence. (supported.) –
  • explanation (str) – Prose description of the problem. Usually a few sentences.

Define a Problem beforehand with CheckerGroup.problem() and reference it with CheckerGroup.check().

class pyglint.CheckerGroup(name, checkers=NOTHING, problems=NOTHING, id_prefix='E')[source]

The main object for defining linters with Pyglint.


Check for one or more pre-defined Problem s.

Parameters:node_type (Type[NodeNG]) – The checker will be invoked with each instance of the given node type that pylint finds.
problem(name, text, explanation)[source]

Define a reusable Problem.

import astroid

import pyglint

group = pyglint.CheckerGroup("mylinter")

BAD_NAME = group.problem(
    text="The name '{name}' is against the guidelines.",
    explanation="It's a good idea to have a useful and descriptive name. For example, Counter instead of ctr.",

IMPORT_FROM = group.problem(
    text="`from ... import` is not allowed.",
    explanation="Namespaces are one honkin' great idea.",

def find_short_names(checker, node):
    if len( < 4:
        yield pyglint.message(problem=BAD_NAME, node=node,

def find_import_from(checker, node):
    yield pyglint.message(problem=IMPORT_FROM, node=node)

def register(linter):
    """Register checkers."""
    checker = pyglint.make_pylint_checker(group)
  1. Register it with Pylint.
def register(linter):
    """Register checkers."""
    checker = pyglint.make_pylint_checker(chk)
  1. Run Pylint with it.

    python -m pylint --load-plugins examples.mylinter examples/

Or enable it in your Pylint configuration file.

# .pylintrc