style: some of the suggestions from flake8
diff --git a/serial/__init__.py b/serial/__init__.py
index 4f222f3..38c267b 100644
--- a/serial/__init__.py
+++ b/serial/__init__.py
@@ -31,8 +31,8 @@
protocol_handler_packages = [
- 'serial.urlhandler',
- ]
+ 'serial.urlhandler',
+]
def serial_for_url(url, *args, **kwargs):
diff --git a/serial/rfc2217.py b/serial/rfc2217.py
index e56eacf..049bd6b 100644
--- a/serial/rfc2217.py
+++ b/serial/rfc2217.py
@@ -493,7 +493,7 @@
# Setup the connection
# to get good performance, all parameter changes are sent first...
- if not 0 < self._baudrate < 2**32:
+ if not 0 < self._baudrate < 2 ** 32:
raise ValueError("invalid baudrate: %r" % (self._baudrate))
self._rfc2217_port_settings['baudrate'].set(struct.pack(b'!I', self._baudrate))
self._rfc2217_port_settings['datasize'].set(struct.pack(b'!B', self._bytesize))
@@ -858,7 +858,7 @@
not.
"""
#~ if self._remote_suspend_flow:
- #~ wait---
+ #~ wait---
def getModemState(self):
"""\
@@ -975,10 +975,10 @@
def check_modem_lines(self, force_notification=False):
modemstate = (
- (self.serial.getCTS() and MODEMSTATE_MASK_CTS) |
- (self.serial.getDSR() and MODEMSTATE_MASK_DSR) |
- (self.serial.getRI() and MODEMSTATE_MASK_RI) |
- (self.serial.getCD() and MODEMSTATE_MASK_CD))
+ (self.serial.getCTS() and MODEMSTATE_MASK_CTS) |
+ (self.serial.getDSR() and MODEMSTATE_MASK_DSR) |
+ (self.serial.getRI() and MODEMSTATE_MASK_RI) |
+ (self.serial.getCD() and MODEMSTATE_MASK_CD))
# check what has changed
deltas = modemstate ^ (self.last_modemstate or 0) # when last is None -> 0
if deltas & MODEMSTATE_MASK_CTS:
diff --git a/serial/serialcli.py b/serial/serialcli.py
index 1873a00..db35063 100644
--- a/serial/serialcli.py
+++ b/serial/serialcli.py
@@ -11,15 +11,11 @@
import System.IO.Ports
from serial.serialutil import *
-
-#~ def device(portnum):
- #~ """Turn a port number into a device name"""
- #~ return System.IO.Ports.SerialPort.GetPortNames()[portnum]
-
-
# must invoke function with byte array, make a helper to convert strings
# to byte arrays
sab = System.Array[System.Byte]
+
+
def as_byte_array(string):
return sab([ord(x) for x in string]) # XXX will require adaption when run with a 3.x compatible IronPython
diff --git a/serial/serialposix.py b/serial/serialposix.py
index 8c32bd9..44cadf2 100644
--- a/serial/serialposix.py
+++ b/serial/serialposix.py
@@ -56,7 +56,7 @@
# for the platform
plat = sys.platform.lower()
-if plat[:5] == 'linux': # Linux (confirmed)
+if plat[:5] == 'linux': # Linux (confirmed) # noqa
import array
# baudrate ioctls
diff --git a/serial/tools/list_ports_posix.py b/serial/tools/list_ports_posix.py
index 3f6e169..1901e60 100644
--- a/serial/tools/list_ports_posix.py
+++ b/serial/tools/list_ports_posix.py
@@ -24,7 +24,7 @@
# try to detect the OS so that a device can be selected...
plat = sys.platform.lower()
-if plat[:5] == 'linux': # Linux (confirmed)
+if plat[:5] == 'linux': # Linux (confirmed) # noqa
from serial.tools.list_ports_linux import comports
elif plat[:6] == 'darwin': # OS X (confirmed)
@@ -44,7 +44,6 @@
return [list_ports_common.ListPortInfo(d) for d in devices]
elif plat[:3] == 'bsd' or plat[:7] == 'freebsd':
-
def comports():
devices = glob.glob('/dev/cua*[!.init][!.lock]')
return [list_ports_common.ListPortInfo(d) for d in devices]
diff --git a/serial/tools/miniterm.py b/serial/tools/miniterm.py
index ac1773d..65a5031 100644
--- a/serial/tools/miniterm.py
+++ b/serial/tools/miniterm.py
@@ -72,7 +72,7 @@
self.setup()
-if os.name == 'nt':
+if os.name == 'nt': # noqa
import msvcrt
import ctypes
@@ -190,10 +190,11 @@
"""remove typical terminal control codes from input"""
REPLACEMENT_MAP = dict((x, 0x2400 + x) for x in range(32) if unichr(x) not in '\r\n\b\t')
- REPLACEMENT_MAP.update({
+ REPLACEMENT_MAP.update(
+ {
0x7F: 0x2421, # DEL
0x9B: 0x2425, # CSI
- })
+ })
def rx(self, text):
return text.translate(self.REPLACEMENT_MAP)
@@ -205,11 +206,12 @@
"""Remove all control codes, incl. CR+LF"""
REPLACEMENT_MAP = dict((x, 0x2400 + x) for x in range(32))
- REPLACEMENT_MAP.update({
+ REPLACEMENT_MAP.update(
+ {
32: 0x2423, # visual space
0x7F: 0x2421, # DEL
0x9B: 0x2425, # CSI
- })
+ })
class Printable(Transform):
@@ -264,19 +266,19 @@
# - insert newline after: a) timeout b) packet end character
EOL_TRANSFORMATIONS = {
- 'crlf': CRLF,
- 'cr': CR,
- 'lf': LF,
- }
+ 'crlf': CRLF,
+ 'cr': CR,
+ 'lf': LF,
+}
TRANSFORMATIONS = {
- 'direct': Transform, # no transformation
- 'default': NoTerminal,
- 'nocontrol': NoControls,
- 'printable': Printable,
- 'colorize': Colorize,
- 'debug': DebugIO,
- }
+ 'direct': Transform, # no transformation
+ 'default': NoTerminal,
+ 'nocontrol': NoControls,
+ 'printable': Printable,
+ 'colorize': Colorize,
+ 'debug': DebugIO,
+}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -387,9 +389,6 @@
pass
sys.stderr.write('--- software flow control: {}\n'.format('active' if self.serial.xonxoff else 'inactive'))
sys.stderr.write('--- hardware flow control: {}\n'.format('active' if self.serial.rtscts else 'inactive'))
- #~ sys.stderr.write('--- data escaping: %s linefeed: %s\n' % (
- #~ REPR_MODES[self.repr_mode],
- #~ LF_MODES[self.convert_outgoing]))
sys.stderr.write('--- serial input encoding: {}\n'.format(self.input_encoding))
sys.stderr.write('--- serial output encoding: {}\n'.format(self.output_encoding))
sys.stderr.write('--- EOL: {}\n'.format(self.eol.upper()))
@@ -641,19 +640,18 @@
--- x X disable/enable software flow control
--- r R disable/enable hardware flow control
""".format(
- version=getattr(serial, 'VERSION', 'unknown version'),
- exit=key_description(self.exit_character),
- menu=key_description(self.menu_character),
- rts=key_description('\x12'),
- dtr=key_description('\x04'),
- brk=key_description('\x02'),
- echo=key_description('\x05'),
- info=key_description('\x09'),
- upload=key_description('\x15'),
- repr=key_description('\x01'),
- filter=key_description('\x06'),
- eol=key_description('\x0c'),
- )
+ version=getattr(serial, 'VERSION', 'unknown version'),
+ exit=key_description(self.exit_character),
+ menu=key_description(self.menu_character),
+ rts=key_description('\x12'),
+ dtr=key_description('\x04'),
+ brk=key_description('\x02'),
+ echo=key_description('\x05'),
+ info=key_description('\x09'),
+ upload=key_description('\x15'),
+ repr=key_description('\x01'),
+ filter=key_description('\x06'),
+ eol=key_description('\x0c'))
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -