If you are using pre-commit, you do not need to follow these steps. pre-commit runs Pylint for you. We highly recommend using pre-commit. For more information, check out this page: https://learn.adafruit.com/creating-and-sharing-a-circuitpython-library/check-your-code

Now that you've installed Pylint and downloaded the .pylintrc configuration file, you're ready to start linting. First thing we need is an example to check.

Download pylint_example.py using the "pylint_example.py" link below. Then, place the file in the same location as your recently downloaded .pylintrc file.

import board
import digitalio
import adafruit_lis3dh
import touchio
import time
import neopixel
import adafruit_thermistor

pixels = neopixel.NeoPixel(board.NEOPIXEL, 10, brightness=0.2)

i2c = board.I2C()
int1 = digitalio.DigitalInOut(board.ACCELEROMETER_UNTERRUPT)
lis3dh = adafruit_lis3dh.LIS3DH_I2C(i2c, int1=int1)

circuit_playground_temperature = adafruit_thermistor.Thermistor(board.TEMPERATURE, 10000, 10000, 25, 3950)

touch_A1 = touchio.TouchIn(board.A1)
touch_A2 = touchio.TouchIn(board.A2)

led = digitalio.DigitalInOut(board.D13)
led.direction = digitalio.Direction.OUTPUT

button_A = digitalio.DigitalInOut(board.BUTTON_A)
button_A.direction = digitalio.Direction.INPUT
button_A.pull = digitalio.Pull.DOWN

while True:
    x, y, z = lis3dh.acceleration

    if button_A.value:
        led.value = True
        led.value = False

    print("Temperature:", circuit_playground_temperature.temperature)
    print("Acceleration:", x, y, z)

    if touch_A1.value:
        pixels.fill((255, 0, 0))
    if touch_A2.value:
        pixels.fill((0, 0, 255))
        pixels.fill((0, 0, 0))

Pylint looks in a series of locations in order to find the configuration file. The first place it looks is the current working directory. This is the easiest way to ensure you're using the right configuration file.

Return to your terminal program or command line. From the command line, navigate to the folder containing pylint_example.py and .pylintrc. Then, run the following command:

pylint pylint_example.py

Alright! Your first error! Consider it a badge of honor. And don't worry! The next section will walk through how to read the Pylint output with a series of common errors. Time to start linting!

This guide was first published on Aug 23, 2019. It was last updated on Mar 02, 2024.

This page (Run Pylint) was last updated on Mar 02, 2024.

Text editor powered by tinymce.