The following issues were found
tests/basics/iter1.py
13 issues
Line: 7
Column: 14
class NotIterable:
pass
try:
for i in NotIterable():
pass
except TypeError:
print('TypeError')
# this class has no __next__ implementation
Reported by Pylint.
Line: 13
Column: 1
print('TypeError')
# this class has no __next__ implementation
class NotIterable:
def __iter__(self):
return self
try:
print(all(NotIterable()))
except TypeError:
Reported by Pylint.
Line: 14
Column: 5
# this class has no __next__ implementation
class NotIterable:
def __iter__(self):
return self
try:
print(all(NotIterable()))
except TypeError:
print('TypeError')
Reported by Pylint.
Line: 25
Column: 24
pass
class myiter:
def __init__(self, i):
self.i = i
def __iter__(self):
return self
Reported by Pylint.
Line: 1
Column: 1
# test user defined iterators
# this class is not iterable
class NotIterable:
pass
try:
for i in NotIterable():
pass
except TypeError:
Reported by Pylint.
Line: 4
Column: 1
# test user defined iterators
# this class is not iterable
class NotIterable:
pass
try:
for i in NotIterable():
pass
except TypeError:
Reported by Pylint.
Line: 4
Column: 1
# test user defined iterators
# this class is not iterable
class NotIterable:
pass
try:
for i in NotIterable():
pass
except TypeError:
Reported by Pylint.
Line: 13
Column: 1
print('TypeError')
# this class has no __next__ implementation
class NotIterable:
def __iter__(self):
return self
try:
print(all(NotIterable()))
except TypeError:
Reported by Pylint.
Line: 13
Column: 1
print('TypeError')
# this class has no __next__ implementation
class NotIterable:
def __iter__(self):
return self
try:
print(all(NotIterable()))
except TypeError:
Reported by Pylint.
Line: 21
Column: 1
except TypeError:
print('TypeError')
class MyStopIteration(StopIteration):
pass
class myiter:
def __init__(self, i):
self.i = i
Reported by Pylint.
drivers/dht/dht.py
13 issues
Line: 6
Column: 1
try:
from esp import dht_readinto
except:
from pyb import dht_readinto
class DHTBase:
def __init__(self, pin):
Reported by Pylint.
Line: 1
Column: 1
# DHT11/DHT22 driver for MicroPython on ESP8266
# MIT license; Copyright (c) 2016 Damien P. George
try:
from esp import dht_readinto
except:
from pyb import dht_readinto
Reported by Pylint.
Line: 10
Column: 1
from pyb import dht_readinto
class DHTBase:
def __init__(self, pin):
self.pin = pin
self.buf = bytearray(5)
def measure(self):
Reported by Pylint.
Line: 10
Column: 1
from pyb import dht_readinto
class DHTBase:
def __init__(self, pin):
self.pin = pin
self.buf = bytearray(5)
def measure(self):
Reported by Pylint.
Line: 15
Column: 5
self.pin = pin
self.buf = bytearray(5)
def measure(self):
buf = self.buf
dht_readinto(self.pin, buf)
if (buf[0] + buf[1] + buf[2] + buf[3]) & 0xFF != buf[4]:
raise Exception("checksum error")
Reported by Pylint.
Line: 22
Column: 1
raise Exception("checksum error")
class DHT11(DHTBase):
def humidity(self):
return self.buf[0]
def temperature(self):
return self.buf[2]
Reported by Pylint.
Line: 23
Column: 5
class DHT11(DHTBase):
def humidity(self):
return self.buf[0]
def temperature(self):
return self.buf[2]
Reported by Pylint.
Line: 26
Column: 5
def humidity(self):
return self.buf[0]
def temperature(self):
return self.buf[2]
class DHT22(DHTBase):
def humidity(self):
Reported by Pylint.
Line: 30
Column: 1
return self.buf[2]
class DHT22(DHTBase):
def humidity(self):
return (self.buf[0] << 8 | self.buf[1]) * 0.1
def temperature(self):
t = ((self.buf[2] & 0x7F) << 8 | self.buf[3]) * 0.1
Reported by Pylint.
Line: 31
Column: 5
class DHT22(DHTBase):
def humidity(self):
return (self.buf[0] << 8 | self.buf[1]) * 0.1
def temperature(self):
t = ((self.buf[2] & 0x7F) << 8 | self.buf[3]) * 0.1
if self.buf[2] & 0x80:
Reported by Pylint.
extmod/uasyncio/event.py
13 issues
Line: 4
Column: 1
# MicroPython uasyncio module
# MIT license; Copyright (c) 2019-2020 Damien P. George
from . import core
# Event class for primitive events that can be waited on, set, and cleared
class Event:
def __init__(self):
self.state = False # False=unset; True=set
Reported by Pylint.
Line: 20
Column: 13
# Note: This must not be called from anything except the thread running
# the asyncio loop (i.e. neither hard or soft IRQ, or a different thread).
while self.waiting.peek():
core._task_queue.push_head(self.waiting.pop_head())
self.state = True
def clear(self):
self.state = False
Reported by Pylint.
Line: 57
Column: 23
async def wait(self):
if not self._flag:
yield core._io_queue.queue_read(self)
self._flag = 0
except ImportError:
pass
Reported by Pylint.
Line: 1
Column: 1
# MicroPython uasyncio module
# MIT license; Copyright (c) 2019-2020 Damien P. George
from . import core
# Event class for primitive events that can be waited on, set, and cleared
class Event:
def __init__(self):
self.state = False # False=unset; True=set
Reported by Pylint.
Line: 7
Column: 1
from . import core
# Event class for primitive events that can be waited on, set, and cleared
class Event:
def __init__(self):
self.state = False # False=unset; True=set
self.waiting = core.TaskQueue() # Queue of Tasks waiting on completion of this event
def is_set(self):
Reported by Pylint.
Line: 12
Column: 5
self.state = False # False=unset; True=set
self.waiting = core.TaskQueue() # Queue of Tasks waiting on completion of this event
def is_set(self):
return self.state
def set(self):
# Event becomes set, schedule any tasks waiting on it
# Note: This must not be called from anything except the thread running
Reported by Pylint.
Line: 15
Column: 5
def is_set(self):
return self.state
def set(self):
# Event becomes set, schedule any tasks waiting on it
# Note: This must not be called from anything except the thread running
# the asyncio loop (i.e. neither hard or soft IRQ, or a different thread).
while self.waiting.peek():
core._task_queue.push_head(self.waiting.pop_head())
Reported by Pylint.
Line: 23
Column: 5
core._task_queue.push_head(self.waiting.pop_head())
self.state = True
def clear(self):
self.state = False
async def wait(self):
if not self.state:
# Event not set, put the calling task on the event's waiting queue
Reported by Pylint.
Line: 26
Column: 5
def clear(self):
self.state = False
async def wait(self):
if not self.state:
# Event not set, put the calling task on the event's waiting queue
self.waiting.push_head(core.cur_task)
# Set calling task's data to the event's queue so it can be removed if needed
core.cur_task.data = self.waiting
Reported by Pylint.
Line: 43
Column: 5
try:
import uio
class ThreadSafeFlag(uio.IOBase):
def __init__(self):
self._flag = 0
def ioctl(self, req, flags):
if req == 3: # MP_STREAM_POLL
Reported by Pylint.
tests/extmod/uasyncio_event_fair.py
13 issues
Line: 11
Column: 9
import asyncio
except ImportError:
print("SKIP")
raise SystemExit
async def task1(id):
for i in range(4):
print("sleep", id)
Reported by Pylint.
Line: 14
Column: 17
raise SystemExit
async def task1(id):
for i in range(4):
print("sleep", id)
await asyncio.sleep(0)
Reported by Pylint.
Line: 15
Column: 9
async def task1(id):
for i in range(4):
print("sleep", id)
await asyncio.sleep(0)
async def task2(id, ev):
Reported by Pylint.
Line: 20
Column: 17
await asyncio.sleep(0)
async def task2(id, ev):
for i in range(4):
ev.set()
ev.clear()
print("wait", id)
await ev.wait()
Reported by Pylint.
Line: 21
Column: 9
async def task2(id, ev):
for i in range(4):
ev.set()
ev.clear()
print("wait", id)
await ev.wait()
Reported by Pylint.
Line: 1
Column: 1
# Test fairness of Event.set()
# That tasks which continuously wait on events don't take over the scheduler
try:
import uasyncio as asyncio
except ImportError:
try:
import asyncio
except ImportError:
Reported by Pylint.
Line: 14
Column: 1
raise SystemExit
async def task1(id):
for i in range(4):
print("sleep", id)
await asyncio.sleep(0)
Reported by Pylint.
Line: 14
Column: 1
raise SystemExit
async def task1(id):
for i in range(4):
print("sleep", id)
await asyncio.sleep(0)
Reported by Pylint.
Line: 20
Column: 1
await asyncio.sleep(0)
async def task2(id, ev):
for i in range(4):
ev.set()
ev.clear()
print("wait", id)
await ev.wait()
Reported by Pylint.
Line: 20
Column: 1
await asyncio.sleep(0)
async def task2(id, ev):
for i in range(4):
ev.set()
ev.clear()
print("wait", id)
await ev.wait()
Reported by Pylint.
tests/basics/class_inherit1.py
13 issues
Line: 7
Column: 23
self.x = x
def f(self):
print(self.x, self.y)
class B(A):
def __init__(self, x, y):
A.__init__(self, x)
print('B init', x, y)
Reported by Pylint.
Line: 1
Column: 1
class A:
def __init__(self, x):
print('A init', x)
self.x = x
def f(self):
print(self.x, self.y)
class B(A):
Reported by Pylint.
Line: 1
Column: 1
class A:
def __init__(self, x):
print('A init', x)
self.x = x
def f(self):
print(self.x, self.y)
class B(A):
Reported by Pylint.
Line: 1
Column: 1
class A:
def __init__(self, x):
print('A init', x)
self.x = x
def f(self):
print(self.x, self.y)
class B(A):
Reported by Pylint.
Line: 1
Column: 1
class A:
def __init__(self, x):
print('A init', x)
self.x = x
def f(self):
print(self.x, self.y)
class B(A):
Reported by Pylint.
Line: 4
Column: 9
class A:
def __init__(self, x):
print('A init', x)
self.x = x
def f(self):
print(self.x, self.y)
class B(A):
Reported by Pylint.
Line: 6
Column: 5
print('A init', x)
self.x = x
def f(self):
print(self.x, self.y)
class B(A):
def __init__(self, x, y):
A.__init__(self, x)
Reported by Pylint.
Line: 6
Column: 5
print('A init', x)
self.x = x
def f(self):
print(self.x, self.y)
class B(A):
def __init__(self, x, y):
A.__init__(self, x)
Reported by Pylint.
Line: 9
Column: 1
def f(self):
print(self.x, self.y)
class B(A):
def __init__(self, x, y):
A.__init__(self, x)
print('B init', x, y)
self.y = y
Reported by Pylint.
Line: 9
Column: 1
def f(self):
print(self.x, self.y)
class B(A):
def __init__(self, x, y):
A.__init__(self, x)
print('B init', x, y)
self.y = y
Reported by Pylint.
tests/inlineasm/asmdiv.py
13 issues
Line: 1
Column: 2
@micropython.asm_thumb
def sdiv(r0, r1):
sdiv(r0, r0, r1)
@micropython.asm_thumb
def udiv(r0, r1):
udiv(r0, r0, r1)
Reported by Pylint.
Line: 3
Column: 5
@micropython.asm_thumb
def sdiv(r0, r1):
sdiv(r0, r0, r1)
@micropython.asm_thumb
def udiv(r0, r1):
udiv(r0, r0, r1)
Reported by Pylint.
Line: 6
Column: 2
sdiv(r0, r0, r1)
@micropython.asm_thumb
def udiv(r0, r1):
udiv(r0, r0, r1)
print(sdiv(1234, 3))
Reported by Pylint.
Line: 8
Column: 5
@micropython.asm_thumb
def udiv(r0, r1):
udiv(r0, r0, r1)
print(sdiv(1234, 3))
print(sdiv(-1234, 3))
print(sdiv(1234, -3))
Reported by Pylint.
Line: 3
Column: 5
@micropython.asm_thumb
def sdiv(r0, r1):
sdiv(r0, r0, r1)
@micropython.asm_thumb
def udiv(r0, r1):
udiv(r0, r0, r1)
Reported by Pylint.
Line: 8
Column: 5
@micropython.asm_thumb
def udiv(r0, r1):
udiv(r0, r0, r1)
print(sdiv(1234, 3))
print(sdiv(-1234, 3))
print(sdiv(1234, -3))
Reported by Pylint.
Line: 1
Column: 1
@micropython.asm_thumb
def sdiv(r0, r1):
sdiv(r0, r0, r1)
@micropython.asm_thumb
def udiv(r0, r1):
udiv(r0, r0, r1)
Reported by Pylint.
Line: 2
Column: 1
@micropython.asm_thumb
def sdiv(r0, r1):
sdiv(r0, r0, r1)
@micropython.asm_thumb
def udiv(r0, r1):
udiv(r0, r0, r1)
Reported by Pylint.
Line: 2
Column: 1
@micropython.asm_thumb
def sdiv(r0, r1):
sdiv(r0, r0, r1)
@micropython.asm_thumb
def udiv(r0, r1):
udiv(r0, r0, r1)
Reported by Pylint.
Line: 2
Column: 1
@micropython.asm_thumb
def sdiv(r0, r1):
sdiv(r0, r0, r1)
@micropython.asm_thumb
def udiv(r0, r1):
udiv(r0, r0, r1)
Reported by Pylint.
tests/basics/builtin_hasattr.py
12 issues
Line: 35
Column: 8
# ensure that non-AttributeError exceptions propagate out of hasattr
try:
hasattr(c, "raise")
except Exception as er:
print(er)
try:
hasattr(1, b'123')
except TypeError:
Reported by Pylint.
Line: 1
Column: 1
class A:
var = 132
def __init__(self):
self.var2 = 34
def meth(self, i):
return 42 + i
Reported by Pylint.
Line: 1
Column: 1
class A:
var = 132
def __init__(self):
self.var2 = 34
def meth(self, i):
return 42 + i
Reported by Pylint.
Line: 1
Column: 1
class A:
var = 132
def __init__(self):
self.var2 = 34
def meth(self, i):
return 42 + i
Reported by Pylint.
Line: 1
Column: 1
class A:
var = 132
def __init__(self):
self.var2 = 34
def meth(self, i):
return 42 + i
Reported by Pylint.
Line: 8
Column: 5
def __init__(self):
self.var2 = 34
def meth(self, i):
return 42 + i
a = A()
print(hasattr(a, "var"))
Reported by Pylint.
Line: 8
Column: 5
def __init__(self):
self.var2 = 34
def meth(self, i):
return 42 + i
a = A()
print(hasattr(a, "var"))
Reported by Pylint.
Line: 19
Column: 1
print(hasattr(a, "_none_such"))
print(hasattr(list, "foo"))
class C:
def __getattr__(self, attr):
if attr == "exists":
return attr
elif attr == "raise":
Reported by Pylint.
Line: 19
Column: 1
print(hasattr(a, "_none_such"))
print(hasattr(list, "foo"))
class C:
def __getattr__(self, attr):
if attr == "exists":
return attr
elif attr == "raise":
Reported by Pylint.
Line: 19
Column: 1
print(hasattr(a, "_none_such"))
print(hasattr(list, "foo"))
class C:
def __getattr__(self, attr):
if attr == "exists":
return attr
elif attr == "raise":
Reported by Pylint.
ports/esp8266/modules/flashbdev.py
12 issues
Line: 1
Column: 1
import esp
class FlashBdev:
SEC_SIZE = 4096
def __init__(self, start_sec, blocks):
self.start_sec = start_sec
self.blocks = blocks
Reported by Pylint.
Line: 7
Column: 24
class FlashBdev:
SEC_SIZE = 4096
def __init__(self, start_sec, blocks):
self.start_sec = start_sec
self.blocks = blocks
def readblocks(self, n, buf, off=0):
# print("readblocks(%s, %x(%d), %d)" % (n, id(buf), len(buf), off))
Reported by Pylint.
Line: 1
Column: 1
import esp
class FlashBdev:
SEC_SIZE = 4096
def __init__(self, start_sec, blocks):
self.start_sec = start_sec
self.blocks = blocks
Reported by Pylint.
Line: 4
Column: 1
import esp
class FlashBdev:
SEC_SIZE = 4096
def __init__(self, start_sec, blocks):
self.start_sec = start_sec
self.blocks = blocks
Reported by Pylint.
Line: 11
Column: 5
self.start_sec = start_sec
self.blocks = blocks
def readblocks(self, n, buf, off=0):
# print("readblocks(%s, %x(%d), %d)" % (n, id(buf), len(buf), off))
esp.flash_read((n + self.start_sec) * self.SEC_SIZE + off, buf)
def writeblocks(self, n, buf, off=None):
# print("writeblocks(%s, %x(%d), %d)" % (n, id(buf), len(buf), off))
Reported by Pylint.
Line: 11
Column: 5
self.start_sec = start_sec
self.blocks = blocks
def readblocks(self, n, buf, off=0):
# print("readblocks(%s, %x(%d), %d)" % (n, id(buf), len(buf), off))
esp.flash_read((n + self.start_sec) * self.SEC_SIZE + off, buf)
def writeblocks(self, n, buf, off=None):
# print("writeblocks(%s, %x(%d), %d)" % (n, id(buf), len(buf), off))
Reported by Pylint.
Line: 15
Column: 5
# print("readblocks(%s, %x(%d), %d)" % (n, id(buf), len(buf), off))
esp.flash_read((n + self.start_sec) * self.SEC_SIZE + off, buf)
def writeblocks(self, n, buf, off=None):
# print("writeblocks(%s, %x(%d), %d)" % (n, id(buf), len(buf), off))
# assert len(buf) <= self.SEC_SIZE, len(buf)
if off is None:
esp.flash_erase(n + self.start_sec)
off = 0
Reported by Pylint.
Line: 15
Column: 5
# print("readblocks(%s, %x(%d), %d)" % (n, id(buf), len(buf), off))
esp.flash_read((n + self.start_sec) * self.SEC_SIZE + off, buf)
def writeblocks(self, n, buf, off=None):
# print("writeblocks(%s, %x(%d), %d)" % (n, id(buf), len(buf), off))
# assert len(buf) <= self.SEC_SIZE, len(buf)
if off is None:
esp.flash_erase(n + self.start_sec)
off = 0
Reported by Pylint.
Line: 23
Column: 5
off = 0
esp.flash_write((n + self.start_sec) * self.SEC_SIZE + off, buf)
def ioctl(self, op, arg):
# print("ioctl(%d, %r)" % (op, arg))
if op == 4: # MP_BLOCKDEV_IOCTL_BLOCK_COUNT
return self.blocks
if op == 5: # MP_BLOCKDEV_IOCTL_BLOCK_SIZE
return self.SEC_SIZE
Reported by Pylint.
Line: 23
Column: 5
off = 0
esp.flash_write((n + self.start_sec) * self.SEC_SIZE + off, buf)
def ioctl(self, op, arg):
# print("ioctl(%d, %r)" % (op, arg))
if op == 4: # MP_BLOCKDEV_IOCTL_BLOCK_COUNT
return self.blocks
if op == 5: # MP_BLOCKDEV_IOCTL_BLOCK_SIZE
return self.SEC_SIZE
Reported by Pylint.
tests/net_inet/ssl_errors.py
12 issues
Line: 8
Column: 1
try:
import uerrno as errno, usocket as socket, ussl as ssl
except:
import errno, socket, ssl
def test(addr, hostname, block=True):
print("---", hostname or addr)
Reported by Pylint.
Line: 12
Column: 10
import errno, socket, ssl
def test(addr, hostname, block=True):
print("---", hostname or addr)
s = socket.socket()
s.setblocking(block)
try:
s.connect(addr)
Reported by Pylint.
Line: 26
Column: 17
try:
if sys.implementation.name == "micropython":
s = ssl.wrap_socket(s, do_handshake=block)
else:
s = ssl.wrap_socket(s, do_handshake_on_connect=block)
print("wrap: True")
except OSError:
print("wrap: error")
Reported by Pylint.
Line: 28
Column: 17
if sys.implementation.name == "micropython":
s = ssl.wrap_socket(s, do_handshake=block)
else:
s = ssl.wrap_socket(s, do_handshake_on_connect=block)
print("wrap: True")
except OSError:
print("wrap: error")
if not block:
Reported by Pylint.
Line: 1
Column: 1
# test that socket.connect() on a non-blocking socket raises EINPROGRESS
# and that an immediate write/send/read/recv does the right thing
import sys
try:
import uerrno as errno, usocket as socket, ussl as ssl
except:
import errno, socket, ssl
Reported by Pylint.
Line: 7
Column: 5
import sys
try:
import uerrno as errno, usocket as socket, ussl as ssl
except:
import errno, socket, ssl
def test(addr, hostname, block=True):
Reported by Pylint.
Line: 9
Column: 5
try:
import uerrno as errno, usocket as socket, ussl as ssl
except:
import errno, socket, ssl
def test(addr, hostname, block=True):
print("---", hostname or addr)
s = socket.socket()
Reported by Pylint.
Line: 12
Column: 1
import errno, socket, ssl
def test(addr, hostname, block=True):
print("---", hostname or addr)
s = socket.socket()
s.setblocking(block)
try:
s.connect(addr)
Reported by Pylint.
Line: 14
Column: 5
def test(addr, hostname, block=True):
print("---", hostname or addr)
s = socket.socket()
s.setblocking(block)
try:
s.connect(addr)
print("connected")
except OSError as e:
Reported by Pylint.
Line: 19
Column: 5
try:
s.connect(addr)
print("connected")
except OSError as e:
if e.errno != errno.EINPROGRESS:
raise
print("EINPROGRESS")
try:
Reported by Pylint.
tests/basics/async_with_return.py
12 issues
Line: 1
Column: 1
# test async with, escaped by a return
class AContext:
async def __aenter__(self):
print('enter')
return 1
async def __aexit__(self, exc_type, exc, tb):
print('exit', exc_type, exc)
Reported by Pylint.
Line: 3
Column: 1
# test async with, escaped by a return
class AContext:
async def __aenter__(self):
print('enter')
return 1
async def __aexit__(self, exc_type, exc, tb):
print('exit', exc_type, exc)
Reported by Pylint.
Line: 7
Column: 5
async def __aenter__(self):
print('enter')
return 1
async def __aexit__(self, exc_type, exc, tb):
print('exit', exc_type, exc)
async def f1():
async with AContext():
print('body')
Reported by Pylint.
Line: 10
Column: 1
async def __aexit__(self, exc_type, exc, tb):
print('exit', exc_type, exc)
async def f1():
async with AContext():
print('body')
return
o = f1()
Reported by Pylint.
Line: 10
Column: 1
async def __aexit__(self, exc_type, exc, tb):
print('exit', exc_type, exc)
async def f1():
async with AContext():
print('body')
return
o = f1()
Reported by Pylint.
Line: 15
Column: 1
print('body')
return
o = f1()
try:
o.send(None)
except StopIteration:
print('finished')
Reported by Pylint.
Line: 21
Column: 1
except StopIteration:
print('finished')
async def f2():
try:
async with AContext():
print('body')
return
finally:
Reported by Pylint.
Line: 21
Column: 1
except StopIteration:
print('finished')
async def f2():
try:
async with AContext():
print('body')
return
finally:
Reported by Pylint.
Line: 29
Column: 1
finally:
print('finally')
o = f2()
try:
o.send(None)
except StopIteration:
print('finished')
Reported by Pylint.
Line: 35
Column: 1
except StopIteration:
print('finished')
async def f3():
try:
try:
async with AContext():
print('body')
return
Reported by Pylint.