The following issues were found

examples/bluetooth/ble_simple_central.py
50 issues
Unable to import 'bluetooth'
Error

Line: 4 Column: 1

              # This example finds and connects to a peripheral running the
# UART service (e.g. ble_simple_peripheral.py).

import bluetooth
import random
import struct
import time
import micropython


            

Reported by Pylint.

Unable to import 'micropython'
Error

Line: 8 Column: 1

              import random
import struct
import time
import micropython

from ble_advertising import decode_services, decode_name

from micropython import const


            

Reported by Pylint.

Unable to import 'micropython'
Error

Line: 12 Column: 1

              
from ble_advertising import decode_services, decode_name

from micropython import const

_IRQ_CENTRAL_CONNECT = const(1)
_IRQ_CENTRAL_DISCONNECT = const(2)
_IRQ_GATTS_WRITE = const(3)
_IRQ_GATTS_READ_REQUEST = const(4)

            

Reported by Pylint.

Module 'time' has no 'sleep_ms' member
Error

Line: 217 Column: 9

              
    # Wait for connection...
    while not central.is_connected():
        time.sleep_ms(100)
        if not_found:
            return

    print("Connected")


            

Reported by Pylint.

Module 'time' has no 'sleep_ms' member
Error

Line: 239 Column: 9

                      except:
            print("TX failed")
        i += 1
        time.sleep_ms(400 if with_response else 30)

    print("Disconnected")


if __name__ == "__main__":

            

Reported by Pylint.

Unused import random
Error

Line: 5 Column: 1

              # UART service (e.g. ble_simple_peripheral.py).

import bluetooth
import random
import struct
import time
import micropython

from ble_advertising import decode_services, decode_name

            

Reported by Pylint.

Unused import struct
Error

Line: 6 Column: 1

              
import bluetooth
import random
import struct
import time
import micropython

from ble_advertising import decode_services, decode_name


            

Reported by Pylint.

Unused import micropython
Error

Line: 8 Column: 1

              import random
import struct
import time
import micropython

from ble_advertising import decode_services, decode_name

from micropython import const


            

Reported by Pylint.

Unused variable 'rssi'
Error

Line: 76 Column: 40

              
    def _irq(self, event, data):
        if event == _IRQ_SCAN_RESULT:
            addr_type, addr, adv_type, rssi, adv_data = data
            if adv_type in (_ADV_IND, _ADV_DIRECT_IND) and _UART_SERVICE_UUID in decode_services(
                adv_data
            ):
                # Found a potential device, remember it and stop scanning.
                self._addr_type = addr_type

            

Reported by Pylint.

Attribute '_addr_type' defined outside __init__
Error

Line: 81 Column: 17

                              adv_data
            ):
                # Found a potential device, remember it and stop scanning.
                self._addr_type = addr_type
                self._addr = bytes(
                    addr
                )  # Note: addr buffer is owned by caller so need to copy it.
                self._name = decode_name(adv_data) or "?"
                self._ble.gap_scan(None)

            

Reported by Pylint.

tests/misc/rge_sm.py
50 issues
Unused variable 'i'
Error

Line: 43 Column: 13

                              break

    def solveNSteps(self, nSteps):
        for i in range(nSteps):
            if not self.iterate():
                break

    def series(self):
        return zip(*self.Trajectory)

            

Reported by Pylint.

Redefining built-in 'range'
Error

Line: 89 Column: 64

                      r += step


def phaseDiagram(system, trajStart, trajPlot, h=0.1, tend=1.0, range=1.0):
    tstart = 0.0
    for i in drange(0, range, 0.1 * range):
        for j in drange(0, range, 0.1 * range):
            rk = RungeKutta(system, trajStart(i, j), tstart, h)
            rk.solve(tend)

            

Reported by Pylint.

Unreachable code
Error

Line: 102 Column: 13

                          print()
            # draw the arrow
            continue
            l = (len(rk.Trajectory) - 1) / 3
            if l > 0 and 2 * l < len(rk.Trajectory):
                p1 = rk.Trajectory[l]
                p2 = rk.Trajectory[2 * l]
                x1, y1 = trajPlot(p1)
                x2, y2 = trajPlot(p2)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # evolve the RGEs of the standard model from electroweak scale up
# by dpgeorge

import math


class RungeKutta(object):
    def __init__(self, functions, initConditions, t0, dh, save=True):
        self.Trajectory, self.save = [[t0] + initConditions], save

            

Reported by Pylint.

Class 'RungeKutta' inherits from object, can be safely removed from bases in python3
Error

Line: 7 Column: 1

              import math


class RungeKutta(object):
    def __init__(self, functions, initConditions, t0, dh, save=True):
        self.Trajectory, self.save = [[t0] + initConditions], save
        self.functions = [lambda *args: 1.0] + list(functions)
        self.N, self.dh = len(self.functions), dh
        self.coeff = [1.0 / 6.0, 2.0 / 6.0, 2.0 / 6.0, 1.0 / 6.0]

            

Reported by Pylint.

Missing class docstring
Error

Line: 7 Column: 1

              import math


class RungeKutta(object):
    def __init__(self, functions, initConditions, t0, dh, save=True):
        self.Trajectory, self.save = [[t0] + initConditions], save
        self.functions = [lambda *args: 1.0] + list(functions)
        self.N, self.dh = len(self.functions), dh
        self.coeff = [1.0 / 6.0, 2.0 / 6.0, 2.0 / 6.0, 1.0 / 6.0]

            

Reported by Pylint.

Too many arguments (6/5)
Error

Line: 8 Column: 5

              

class RungeKutta(object):
    def __init__(self, functions, initConditions, t0, dh, save=True):
        self.Trajectory, self.save = [[t0] + initConditions], save
        self.functions = [lambda *args: 1.0] + list(functions)
        self.N, self.dh = len(self.functions), dh
        self.coeff = [1.0 / 6.0, 2.0 / 6.0, 2.0 / 6.0, 1.0 / 6.0]
        self.InArgCoeff = [0.0, 0.5, 0.5, 1.0]

            

Reported by Pylint.

Attribute name "Trajectory" doesn't conform to snake_case naming style
Error

Line: 9 Column: 9

              
class RungeKutta(object):
    def __init__(self, functions, initConditions, t0, dh, save=True):
        self.Trajectory, self.save = [[t0] + initConditions], save
        self.functions = [lambda *args: 1.0] + list(functions)
        self.N, self.dh = len(self.functions), dh
        self.coeff = [1.0 / 6.0, 2.0 / 6.0, 2.0 / 6.0, 1.0 / 6.0]
        self.InArgCoeff = [0.0, 0.5, 0.5, 1.0]


            

Reported by Pylint.

Attribute name "N" doesn't conform to snake_case naming style
Error

Line: 11 Column: 9

                  def __init__(self, functions, initConditions, t0, dh, save=True):
        self.Trajectory, self.save = [[t0] + initConditions], save
        self.functions = [lambda *args: 1.0] + list(functions)
        self.N, self.dh = len(self.functions), dh
        self.coeff = [1.0 / 6.0, 2.0 / 6.0, 2.0 / 6.0, 1.0 / 6.0]
        self.InArgCoeff = [0.0, 0.5, 0.5, 1.0]

    def iterate(self):
        step = self.Trajectory[-1][:]

            

Reported by Pylint.

Attribute name "dh" doesn't conform to snake_case naming style
Error

Line: 11 Column: 17

                  def __init__(self, functions, initConditions, t0, dh, save=True):
        self.Trajectory, self.save = [[t0] + initConditions], save
        self.functions = [lambda *args: 1.0] + list(functions)
        self.N, self.dh = len(self.functions), dh
        self.coeff = [1.0 / 6.0, 2.0 / 6.0, 2.0 / 6.0, 1.0 / 6.0]
        self.InArgCoeff = [0.0, 0.5, 0.5, 1.0]

    def iterate(self):
        step = self.Trajectory[-1][:]

            

Reported by Pylint.

drivers/display/lcd160cr_test.py
49 issues
Unable to import 'framebuf'
Error

Line: 4 Column: 1

              # Driver test for official MicroPython LCD160CR display
# MIT license; Copyright (c) 2017 Damien P. George

import time, math, framebuf, lcd160cr


def get_lcd(lcd):
    if type(lcd) is str:
        lcd = lcd160cr.LCD160CR(lcd)

            

Reported by Pylint.

Unable to import 'pyb'
Error

Line: 43 Column: 9

              def test_features(lcd, orient=lcd160cr.PORTRAIT):
    # if we run on pyboard then use ADC and RTC features
    try:
        import pyb

        adc = pyb.ADCAll(12, 0xF0000)
        rtc = pyb.RTC()
    except:
        adc = None

            

Reported by Pylint.

Module 'time' has no 'ticks_us' member
Error

Line: 76 Column: 10

              
    # initialise loop parameters
    tx = ty = 0
    t0 = time.ticks_us()

    for i in range(300):
        # update position of cross-hair
        t, tx2, ty2 = lcd.get_touch()
        if t:

            

Reported by Pylint.

Module 'time' has no 'ticks_us' member
Error

Line: 130 Column: 14

                          )

        # compute the frame rate
        t1 = time.ticks_us()
        dt = time.ticks_diff(t1, t0)
        t0 = t1

        # show the frame rate
        lcd.set_pos(2, 9)

            

Reported by Pylint.

Module 'time' has no 'ticks_diff' member
Error

Line: 131 Column: 14

              
        # compute the frame rate
        t1 = time.ticks_us()
        dt = time.ticks_diff(t1, t0)
        t0 = t1

        # show the frame rate
        lcd.set_pos(2, 9)
        lcd.write("%.2f fps" % (1000000 / dt))

            

Reported by Pylint.

No exception type(s) specified
Error

Line: 17 Column: 5

                  data = [adc.read_core_temp(), adc.read_core_vbat(), 3.3]
    try:
        data[2] = adc.read_vref()
    except:
        pass
    for i in range(3):
        lcd.set_text_color((825, 1625, 1600)[i], 0)
        if lcd.h == 160:
            lcd.set_font(2)

            

Reported by Pylint.

No exception type(s) specified
Error

Line: 47 Column: 5

              
        adc = pyb.ADCAll(12, 0xF0000)
        rtc = pyb.RTC()
    except:
        adc = None
        rtc = None

    # set orientation and clear screen
    lcd = get_lcd(lcd)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # Driver test for official MicroPython LCD160CR display
# MIT license; Copyright (c) 2017 Damien P. George

import time, math, framebuf, lcd160cr


def get_lcd(lcd):
    if type(lcd) is str:
        lcd = lcd160cr.LCD160CR(lcd)

            

Reported by Pylint.

Imports from package time are not grouped
Error

Line: 4 Column: 1

              # Driver test for official MicroPython LCD160CR display
# MIT license; Copyright (c) 2017 Damien P. George

import time, math, framebuf, lcd160cr


def get_lcd(lcd):
    if type(lcd) is str:
        lcd = lcd160cr.LCD160CR(lcd)

            

Reported by Pylint.

Multiple imports on one line (time, math, framebuf, lcd160cr)
Error

Line: 4 Column: 1

              # Driver test for official MicroPython LCD160CR display
# MIT license; Copyright (c) 2017 Damien P. George

import time, math, framebuf, lcd160cr


def get_lcd(lcd):
    if type(lcd) is str:
        lcd = lcd160cr.LCD160CR(lcd)

            

Reported by Pylint.

examples/rp2/pio_uart_rx.py
49 issues
Unable to import 'machine'
Error

Line: 12 Column: 1

              #   - using the second core via _thread

import _thread
from machine import Pin, UART
from rp2 import PIO, StateMachine, asm_pio

UART_BAUD = 9600

HARD_UART_TX_PIN = Pin(4, Pin.OUT)

            

Reported by Pylint.

Unable to import 'rp2'
Error

Line: 13 Column: 1

              
import _thread
from machine import Pin, UART
from rp2 import PIO, StateMachine, asm_pio

UART_BAUD = 9600

HARD_UART_TX_PIN = Pin(4, Pin.OUT)
PIO_RX_PIN = Pin(3, Pin.IN, Pin.PULL_UP)

            

Reported by Pylint.

Undefined variable 'rp2'
Error

Line: 24 Column: 17

              @asm_pio(
    autopush=True,
    push_thresh=8,
    in_shiftdir=rp2.PIO.SHIFT_RIGHT,
    fifo_join=PIO.JOIN_RX,
)
def uart_rx_mini():
    # fmt: off
    # Wait for start bit

            

Reported by Pylint.

Undefined variable 'pin'
Error

Line: 30 Column: 13

              def uart_rx_mini():
    # fmt: off
    # Wait for start bit
    wait(0, pin, 0)
    # Preload bit counter, delay until eye of first data bit
    set(x, 7)                 [10]
    # Loop 8 times
    label("bitloop")
    # Sample data

            

Reported by Pylint.

Undefined variable 'wait'
Error

Line: 30 Column: 5

              def uart_rx_mini():
    # fmt: off
    # Wait for start bit
    wait(0, pin, 0)
    # Preload bit counter, delay until eye of first data bit
    set(x, 7)                 [10]
    # Loop 8 times
    label("bitloop")
    # Sample data

            

Reported by Pylint.

Undefined variable 'x'
Error

Line: 32 Column: 9

                  # Wait for start bit
    wait(0, pin, 0)
    # Preload bit counter, delay until eye of first data bit
    set(x, 7)                 [10]
    # Loop 8 times
    label("bitloop")
    # Sample data
    in_(pins, 1)
    # Each iteration is 8 cycles

            

Reported by Pylint.

Value 'set(x, 7)' is unsubscriptable
Error

Line: 32 Column: 5

                  # Wait for start bit
    wait(0, pin, 0)
    # Preload bit counter, delay until eye of first data bit
    set(x, 7)                 [10]
    # Loop 8 times
    label("bitloop")
    # Sample data
    in_(pins, 1)
    # Each iteration is 8 cycles

            

Reported by Pylint.

Undefined variable 'label'
Error

Line: 34 Column: 5

                  # Preload bit counter, delay until eye of first data bit
    set(x, 7)                 [10]
    # Loop 8 times
    label("bitloop")
    # Sample data
    in_(pins, 1)
    # Each iteration is 8 cycles
    jmp(x_dec, "bitloop")     [6]
    # fmt: on

            

Reported by Pylint.

Undefined variable 'pins'
Error

Line: 36 Column: 9

                  # Loop 8 times
    label("bitloop")
    # Sample data
    in_(pins, 1)
    # Each iteration is 8 cycles
    jmp(x_dec, "bitloop")     [6]
    # fmt: on



            

Reported by Pylint.

Undefined variable 'in_'
Error

Line: 36 Column: 5

                  # Loop 8 times
    label("bitloop")
    # Sample data
    in_(pins, 1)
    # Each iteration is 8 cycles
    jmp(x_dec, "bitloop")     [6]
    # fmt: on



            

Reported by Pylint.

ports/nrf/boards/make-pins.py
49 issues
Redefining built-in 'str'
Error

Line: 139 Column: 9

                      return "pin_{:s}_af".format(self.cpu_pin_name())

    def adc_num_str(self):
        str = ""
        for adc_num in range(1, 4):
            if self.adc_num & (1 << (adc_num - 1)):
                if len(str) > 0:
                    str += " | "
                str += "PIN_ADC"

            

Reported by Pylint.

No exception type(s) specified
Error

Line: 222 Column: 17

                          for row in rows:
                try:
                    pin_num = parse_pin(row[pinname_col])
                except:
                    continue
                pin = Pin(pin_num)
                for af_idx in range(af_col, len(row)):
                    if af_idx < af_col_end:
                        pin.parse_af(af_idx - af_col, row[af_idx])

            

Reported by Pylint.

No exception type(s) specified
Error

Line: 238 Column: 17

                          for row in rows:
                try:
                    pin_num = parse_pin(row[1])
                except:
                    continue
                pin = self.find_pin(pin_num)
                if pin:
                    pin.set_is_board_pin()
                    self.board_pins.append(NamedPin(row[0], pin))

            

Reported by Pylint.

Duplicate string formatting argument 'label', consider passing as named argument
Error

Line: 259 Column: 13

                              )
        print("};")
        print(
            "MP_DEFINE_CONST_DICT(pin_{:s}_pins_locals_dict, pin_{:s}_pins_locals_dict_table);".format(
                label, label
            )
        )

    def print_const_table(self):

            

Reported by Pylint.

Module name "make-pins" doesn't conform to snake_case naming style
Error

Line: 1 Column: 1

              #!/usr/bin/env python
"""Creates the pin file for the nRF5."""

from __future__ import print_function

import argparse
import sys
import csv


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 25 Column: 1

                  return int(pin_str)


def split_name_num(name_num):
    num = None
    for num_idx in range(len(name_num) - 1, -1, -1):
        if not name_num[num_idx].isdigit():
            name = name_num[0 : num_idx + 1]
            num_str = name_num[num_idx + 1 :]

            

Reported by Pylint.

Class 'AlternateFunction' inherits from object, can be safely removed from bases in python3
Error

Line: 37 Column: 1

                  return name, num


class AlternateFunction(object):
    """Holds the information associated with a pins alternate function."""

    def __init__(self, idx, af_str):
        self.idx = idx
        self.af_str = af_str

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 58 Column: 5

                          if self.pin_type in pin_types:
                self.supported = True

    def is_supported(self):
        return self.supported

    def ptr(self):
        """Returns the numbered function (i.e. USART6) for this AF."""
        if self.fn_num is None:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 67 Column: 5

                          return self.func
        return "{:s}{:d}".format(self.func, self.fn_num)

    def mux_name(self):
        return "AF{:d}_{:s}".format(self.idx, self.ptr())

    def print(self):
        """Prints the C representation of this AF."""
        if self.supported:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 85 Column: 5

                          )
        )

    def qstr_list(self):
        return [self.mux_name()]


class Pin(object):
    """Holds the information associated with a pin."""

            

Reported by Pylint.

examples/bluetooth/ble_temperature_central.py
48 issues
Unable to import 'bluetooth'
Error

Line: 3 Column: 1

              # This example finds and connects to a BLE temperature sensor (e.g. the one in ble_temperature.py).

import bluetooth
import random
import struct
import time
import micropython

from ble_advertising import decode_services, decode_name

            

Reported by Pylint.

Unable to import 'micropython'
Error

Line: 7 Column: 1

              import random
import struct
import time
import micropython

from ble_advertising import decode_services, decode_name

from micropython import const


            

Reported by Pylint.

Unable to import 'micropython'
Error

Line: 11 Column: 1

              
from ble_advertising import decode_services, decode_name

from micropython import const

_IRQ_CENTRAL_CONNECT = const(1)
_IRQ_CENTRAL_DISCONNECT = const(2)
_IRQ_GATTS_WRITE = const(3)
_IRQ_GATTS_READ_REQUEST = const(4)

            

Reported by Pylint.

Module 'time' has no 'sleep_ms' member
Error

Line: 243 Column: 9

              
    # Wait for connection...
    while not central.is_connected():
        time.sleep_ms(100)
        if not_found:
            return

    print("Connected")


            

Reported by Pylint.

Module 'time' has no 'sleep_ms' member
Error

Line: 252 Column: 9

                  # Explicitly issue reads, using "print" as the callback.
    while central.is_connected():
        central.read(callback=print)
        time.sleep_ms(2000)

    # Alternative to the above, just show the most recently notified value.
    # while central.is_connected():
    #     print(central.value())
    #     time.sleep_ms(2000)

            

Reported by Pylint.

Unused import random
Error

Line: 4 Column: 1

              # This example finds and connects to a BLE temperature sensor (e.g. the one in ble_temperature.py).

import bluetooth
import random
import struct
import time
import micropython

from ble_advertising import decode_services, decode_name

            

Reported by Pylint.

Unused import micropython
Error

Line: 7 Column: 1

              import random
import struct
import time
import micropython

from ble_advertising import decode_services, decode_name

from micropython import const


            

Reported by Pylint.

Unused variable 'rssi'
Error

Line: 89 Column: 40

              
    def _irq(self, event, data):
        if event == _IRQ_SCAN_RESULT:
            addr_type, addr, adv_type, rssi, adv_data = data
            if adv_type in (_ADV_IND, _ADV_DIRECT_IND) and _ENV_SENSE_UUID in decode_services(
                adv_data
            ):
                # Found a potential device, remember it and stop scanning.
                self._addr_type = addr_type

            

Reported by Pylint.

Attribute '_addr_type' defined outside __init__
Error

Line: 94 Column: 17

                              adv_data
            ):
                # Found a potential device, remember it and stop scanning.
                self._addr_type = addr_type
                self._addr = bytes(
                    addr
                )  # Note: addr buffer is owned by caller so need to copy it.
                self._name = decode_name(adv_data) or "?"
                self._ble.gap_scan(None)

            

Reported by Pylint.

Attribute '_addr' defined outside __init__
Error

Line: 95 Column: 17

                          ):
                # Found a potential device, remember it and stop scanning.
                self._addr_type = addr_type
                self._addr = bytes(
                    addr
                )  # Note: addr buffer is owned by caller so need to copy it.
                self._name = decode_name(adv_data) or "?"
                self._ble.gap_scan(None)


            

Reported by Pylint.

ports/nrf/examples/powerup.py
47 issues
Unable to import 'machine'
Error

Line: 40 Column: 1

              #     p = PowerUp3()

import time
from machine import ADC
from machine import Pin
from ubluepy import Peripheral, Scanner, constants


def bytes_to_str(bytes):

            

Reported by Pylint.

Unable to import 'machine'
Error

Line: 41 Column: 1

              
import time
from machine import ADC
from machine import Pin
from ubluepy import Peripheral, Scanner, constants


def bytes_to_str(bytes):
    string = ""

            

Reported by Pylint.

Unable to import 'ubluepy'
Error

Line: 42 Column: 1

              import time
from machine import ADC
from machine import Pin
from ubluepy import Peripheral, Scanner, constants


def bytes_to_str(bytes):
    string = ""
    for b in bytes:

            

Reported by Pylint.

Module 'time' has no 'sleep_ms' member
Error

Line: 191 Column: 13

              
        while True:

            time.sleep_ms(100)

            # read out new angle
            new_angle = self.read_stick_x()
            if new_angle < 256:
                if new_angle > right_threshold:

            

Reported by Pylint.

Redefining built-in 'bytes'
Error

Line: 45 Column: 18

              from ubluepy import Peripheral, Scanner, constants


def bytes_to_str(bytes):
    string = ""
    for b in bytes:
        string += chr(b)
    return string


            

Reported by Pylint.

Attribute 'char_batt_lvl' defined outside __init__
Error

Line: 115 Column: 9

                      service_batt = s[3]
        service_control = s[4]

        self.char_batt_lvl = service_batt.getCharacteristics()[0]
        self.char_control_speed = service_control.getCharacteristics()[0]
        self.char_control_angle = service_control.getCharacteristics()[2]

    def battery_level(self):
        return int(self.char_batt_lvl.read()[0])

            

Reported by Pylint.

Attribute 'char_control_speed' defined outside __init__
Error

Line: 116 Column: 9

                      service_control = s[4]

        self.char_batt_lvl = service_batt.getCharacteristics()[0]
        self.char_control_speed = service_control.getCharacteristics()[0]
        self.char_control_angle = service_control.getCharacteristics()[2]

    def battery_level(self):
        return int(self.char_batt_lvl.read()[0])


            

Reported by Pylint.

Attribute 'char_control_angle' defined outside __init__
Error

Line: 117 Column: 9

              
        self.char_batt_lvl = service_batt.getCharacteristics()[0]
        self.char_control_speed = service_control.getCharacteristics()[0]
        self.char_control_angle = service_control.getCharacteristics()[2]

    def battery_level(self):
        return int(self.char_batt_lvl.read()[0])

    def speed(self, new_speed=None):

            

Reported by Pylint.

Attribute 'old_angle' defined outside __init__
Error

Line: 149 Column: 13

              
    def rudder_center(self):
        if self.old_angle != 0:
            self.old_angle = 0
            self.angle(0)

    def rudder_left(self, angle):
        steps = angle // self.interval_size_left
        new_angle = 60 - steps

            

Reported by Pylint.

Attribute 'old_angle' defined outside __init__
Error

Line: 158 Column: 13

              
        if self.old_angle != new_angle:
            self.angle(new_angle)
            self.old_angle = new_angle

    def rudder_right(self, angle):
        steps = angle // self.interval_size_right
        new_angle = -steps


            

Reported by Pylint.

tools/mpremote/mpremote/main.py
46 issues
Attempted relative import beyond top-level package
Error

Line: 23 Column: 1

              import os, sys
import serial.tools.list_ports

from . import pyboardextended as pyboard
from .console import Console, ConsolePosix

_PROG = "mpremote"

_BUILTIN_COMMAND_EXPANSIONS = {

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 24 Column: 1

              import serial.tools.list_ports

from . import pyboardextended as pyboard
from .console import Console, ConsolePosix

_PROG = "mpremote"

_BUILTIN_COMMAND_EXPANSIONS = {
    # Device connection shortcuts.

            

Reported by Pylint.

Unused ConsolePosix imported from console
Error

Line: 24 Column: 1

              import serial.tools.list_ports

from . import pyboardextended as pyboard
from .console import Console, ConsolePosix

_PROG = "mpremote"

_BUILTIN_COMMAND_EXPANSIONS = {
    # Device connection shortcuts.

            

Reported by Pylint.

Use of exec detected.
Security

Line: 96
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b102_exec_used.html

                      config_data = f.read()
    prev_cwd = os.getcwd()
    os.chdir(path)
    exec(config_data, config.__dict__)
    os.chdir(prev_cwd)

    return config



            

Reported by Bandit.

Use of exec
Error

Line: 96 Column: 5

                      config_data = f.read()
    prev_cwd = os.getcwd()
    os.chdir(path)
    exec(config_data, config.__dict__)
    os.chdir(prev_cwd)

    return config



            

Reported by Pylint.

Global variable '_command_expansions' undefined at the module level
Error

Line: 103 Column: 5

              

def prepare_command_expansions(config):
    global _command_expansions

    _command_expansions = {}

    for command_set in (_BUILTIN_COMMAND_EXPANSIONS, config.commands):
        for cmd, sub in command_set.items():

            

Reported by Pylint.

Redefining built-in 'dir'
Error

Line: 243 Column: 13

                          _list_recursive(src_files, path)
        known_dirs = {""}
        pyb.exec_("import uos")
        for dir, file in src_files:
            dir_parts = dir.split("/")
            for i in range(len(dir_parts)):
                d = "/".join(dir_parts[: i + 1])
                if d not in known_dirs:
                    pyb.exec_("try:\n uos.mkdir('%s')\nexcept OSError as e:\n print(e)" % d)

            

Reported by Pylint.

Unused variable 'ret'
Error

Line: 356 Column: 13

                  try:
        pyb.exec_raw_no_follow(buf)
        if follow:
            ret, ret_err = pyb.follow(timeout=None, data_consumer=pyboard.stdout_write_bytes)
            if ret_err:
                pyboard.stdout_write_bytes(ret_err)
                ret_val = 1
    except pyboard.PyboardError as er:
        print(er)

            

Reported by Pylint.

Multiple imports on one line (os, sys)
Error

Line: 20 Column: 1

                  mpremote repl                    -- enter REPL
"""

import os, sys
import serial.tools.list_ports

from . import pyboardextended as pyboard
from .console import Console, ConsolePosix


            

Reported by Pylint.

Line too long (337/100)
Error

Line: 52 Column: 1

                  "rmdir": "fs rmdir",
    "df": [
        "exec",
        "import uos\nprint('mount \\tsize \\tused \\tavail \\tuse%')\nfor _m in [''] + uos.listdir('/'):\n _s = uos.stat('/' + _m)\n if not _s[0] & 1 << 14: continue\n _s = uos.statvfs(_m)\n if _s[0]:\n  _size = _s[0] * _s[2]; _free = _s[0] * _s[3]; print(_m, _size, _size - _free, _free, int(100 * (_size - _free) / _size), sep='\\t')",
    ],
    # Other shortcuts.
    "reset t_ms=100": [
        "exec",
        "--no-follow",

            

Reported by Pylint.

ports/teensy/make-pins.py
46 issues
Redefining built-in 'str'
Error

Line: 148 Column: 9

                      return "pin_{:s}_af".format(self.cpu_pin_name())

    def adc_num_str(self):
        str = ""
        for adc_num in range(1, 4):
            if self.adc_num & (1 << (adc_num - 1)):
                if len(str) > 0:
                    str += " | "
                str += "PIN_ADC"

            

Reported by Pylint.

No exception type(s) specified
Error

Line: 226 Column: 17

                          for row in rows:
                try:
                    (port_num, pin_num) = parse_port_pin(row[pinname_col])
                except:
                    continue
                pin = Pin(port_num, pin_num)
                for af_idx in range(af_col, len(row)):
                    if af_idx >= af_col:
                        pin.parse_af(af_idx - af_col, row[af_idx])

            

Reported by Pylint.

No exception type(s) specified
Error

Line: 240 Column: 17

                          for row in rows:
                try:
                    (port_num, pin_num) = parse_port_pin(row[1])
                except:
                    continue
                pin = self.find_pin(port_num, pin_num)
                if pin:
                    pin.set_is_board_pin()
                    self.board_pins.append(NamedPin(row[0], pin))

            

Reported by Pylint.

Duplicate string formatting argument 'label', consider passing as named argument
Error

Line: 261 Column: 13

                              )
        print("};")
        print(
            "MP_DEFINE_CONST_DICT(pin_{:s}_pins_locals_dict, pin_{:s}_pins_locals_dict_table);".format(
                label, label
            )
        )

    def print(self):

            

Reported by Pylint.

Module name "make-pins" doesn't conform to snake_case naming style
Error

Line: 1 Column: 1

              #!/usr/bin/env python
"""Creates the pin file for the Teensy."""

from __future__ import print_function

import argparse
import sys
import csv


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 33 Column: 1

                  return (port, int(pin_str))


def split_name_num(name_num):
    num = None
    for num_idx in range(len(name_num) - 1, -1, -1):
        if not name_num[num_idx].isdigit():
            name = name_num[0 : num_idx + 1]
            num_str = name_num[num_idx + 1 :]

            

Reported by Pylint.

Class 'AlternateFunction' inherits from object, can be safely removed from bases in python3
Error

Line: 45 Column: 1

                  return name, num


class AlternateFunction(object):
    """Holds the information associated with a pins alternate function."""

    def __init__(self, idx, af_str):
        self.idx = idx
        self.af_str = af_str

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 66 Column: 5

                          if self.pin_type in pin_types:
                self.supported = True

    def is_supported(self):
        return self.supported

    def ptr(self):
        """Returns the numbered function (i.e. USART6) for this AF."""
        if self.fn_num is None:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 75 Column: 5

                          return self.func
        return "{:s}{:d}".format(self.func, self.fn_num)

    def mux_name(self):
        return "AF{:d}_{:s}".format(self.idx, self.ptr())

    def print(self):
        """Prints the C representation of this AF."""
        if self.supported:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 93 Column: 5

                          )
        )

    def qstr_list(self):
        return [self.mux_name()]


class Pin(object):
    """Holds the information associated with a pin."""

            

Reported by Pylint.

ports/stm32/mboot/mboot.py
46 issues
Module 'time' has no 'ticks_ms' member
Error

Line: 35 Column: 17

                          raise Exception("no I2C mboot device found")

    def wait_response(self):
        start = time.ticks_ms()
        while 1:
            try:
                self.i2c.readfrom_into(self.addr, self.buf1)
                n = self.buf1[0]
                break

            

Reported by Pylint.

Module 'time' has no 'sleep_us' member
Error

Line: 42 Column: 17

                              n = self.buf1[0]
                break
            except OSError as er:
                time.sleep_us(500)
            if time.ticks_diff(time.ticks_ms(), start) > 5000:
                raise Exception("timeout")
        if n >= 129:
            raise Exception(n)
        if n == 0:

            

Reported by Pylint.

Module 'time' has no 'ticks_ms' member
Error

Line: 43 Column: 32

                              break
            except OSError as er:
                time.sleep_us(500)
            if time.ticks_diff(time.ticks_ms(), start) > 5000:
                raise Exception("timeout")
        if n >= 129:
            raise Exception(n)
        if n == 0:
            return b""

            

Reported by Pylint.

Module 'time' has no 'ticks_diff' member
Error

Line: 43 Column: 16

                              break
            except OSError as er:
                time.sleep_us(500)
            if time.ticks_diff(time.ticks_ms(), start) > 5000:
                raise Exception("timeout")
        if n >= 129:
            raise Exception(n)
        if n == 0:
            return b""

            

Reported by Pylint.

Module 'time' has no 'ticks_ms' member
Error

Line: 129 Column: 18

                      local_sha = hashlib.sha256()
        print("Deploying %s to location 0x%08x" % (filename, addr))
        with open(filename, "rb") as f:
            t0 = time.ticks_ms()
            while True:
                n = f.readinto(buf)
                if n == 0:
                    break


            

Reported by Pylint.

Module 'time' has no 'ticks_ms' member
Error

Line: 166 Column: 18

                              ntotal = addr - start_addr
                if ntotal % 2048 == 0 or ntotal == fsize:
                    print("\r% 3u%% % 7u bytes   " % (100 * ntotal // fsize, ntotal), end="")
            t1 = time.ticks_ms()
        print()
        print("rate: %.2f KiB/sec" % (1024 * ntotal / (t1 - t0) / 1000))

        local_sha = local_sha.digest()
        print("Local SHA256: ", "".join("%02x" % x for x in local_sha))

            

Reported by Pylint.

Consider explicitly re-raising using the 'from' keyword
Error

Line: 32 Column: 13

                      try:
            self.i2c.writeto(addr, b"")
        except OSError:
            raise Exception("no I2C mboot device found")

    def wait_response(self):
        start = time.ticks_ms()
        while 1:
            try:

            

Reported by Pylint.

Unused variable 'er'
Error

Line: 41 Column: 13

                              self.i2c.readfrom_into(self.addr, self.buf1)
                n = self.buf1[0]
                break
            except OSError as er:
                time.sleep_us(500)
            if time.ticks_diff(time.ticks_ms(), start) > 5000:
                raise Exception("timeout")
        if n >= 129:
            raise Exception(n)

            

Reported by Pylint.

Redefining built-in 'id'
Error

Line: 77 Column: 9

                  def getlayout(self):
        self.i2c.writeto(self.addr, struct.pack("<B", I2C_CMD_GETLAYOUT))
        layout = self.wait_response()
        id, flash_addr, layout = layout.split(b"/")
        assert id == b"@Internal Flash  "
        flash_addr = int(flash_addr, 16)
        pages = []
        for chunk in layout.split(b","):
            n, sz = chunk.split(b"*")

            

Reported by Pylint.

Unused variable 'i'
Error

Line: 86 Column: 17

                          n = int(n)
            assert sz.endswith(b"Kg")
            sz = int(sz[:-2]) * 1024
            for i in range(n):
                pages.append((flash_addr, sz))
                flash_addr += sz
        return pages

    def pageerase(self, addr):

            

Reported by Pylint.