Skip to content

Commit

Permalink
Fixes for pylint version 1.7 (#166)
Browse files Browse the repository at this point in the history
* Started fixing new pylint 1.7 checks.

* More pylint17 fixes.

* Removed flags that are now disabled by default.

* Still more misc pylint17 fixes.

* Updated pylint freeze to 1.7.

* Guess what? Still more misc fixes.

* More fixes.

* pylint17 fixes nearly done

* Should be the last fixes for 1.7.

* pylint 1.7 fix

* Fix parameter names

* Update pylint 1.7->1.7.1

* Cleanup thorlabs_utils.py
  • Loading branch information
cgranade authored and scasagrande committed Jun 6, 2017
1 parent 065d3d2 commit 6c6dbb4
Show file tree
Hide file tree
Showing 40 changed files with 80 additions and 133 deletions.
2 changes: 1 addition & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
mock
nose
pylint==1.6.5
pylint==1.7.1
4 changes: 2 additions & 2 deletions instruments/abstract_instruments/comm/file_communicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ def address(self):
"""
if hasattr(self._filelike, 'name'):
return self._filelike.name
else:
return None

return None

@address.setter
def address(self, newval):
Expand Down
7 changes: 3 additions & 4 deletions instruments/abstract_instruments/comm/gi_gpib_communicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __init__(self, filelike, gpib_address):
if self._version <= 4:
self._eos = 10
else:
self._eos = "\n" # pylint: disable=redefined-variable-type
self._eos = "\n"

# PROPERTIES #

Expand Down Expand Up @@ -117,8 +117,8 @@ def terminator(self):
"""
if not self._eoi:
return self._terminator
else:
return 'eoi'

return 'eoi'

@terminator.setter
def terminator(self, newval):
Expand Down Expand Up @@ -203,7 +203,6 @@ def eos(self):

@eos.setter
def eos(self, newval):
# pylint: disable=redefined-variable-type
if self._version <= 4:
if isinstance(newval, (str, bytes)):
newval = ord(newval)
Expand Down
4 changes: 2 additions & 2 deletions instruments/abstract_instruments/comm/usbtmc_communicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def __init__(self, *args, **kwargs):
def address(self):
if hasattr(self._filelike, "name"):
return id(self._filelike) # TODO: replace with something more useful.
else:
return None

return None

@property
def terminator(self):
Expand Down
5 changes: 2 additions & 3 deletions instruments/abstract_instruments/function_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ def amplitude(self):

if units == self.VoltageMode.dBm:
return pq.Quantity(mag, u.dBm)
else:
return pq.Quantity(mag, pq.V), units

return pq.Quantity(mag, pq.V), units

@amplitude.setter
def amplitude(self, newval):
Expand All @@ -168,7 +168,6 @@ def amplitude(self, newval):
# OK, we have volts. Now, do we have a tuple? If not, assume Vpp.
if not isinstance(newval, tuple):
mag = newval
# pylint: disable=redefined-variable-type
units = self.VoltageMode.peak_to_peak
else:
mag, units = newval
Expand Down
6 changes: 4 additions & 2 deletions instruments/abstract_instruments/oscilloscope.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ def __exit__(self, type, value, traceback):
def __eq__(self, other):
if not isinstance(other, type(self)):
return NotImplemented
else:
return other.name == self.name

return other.name == self.name

__hash__ = None

# PROPERTIES #

Expand Down
3 changes: 0 additions & 3 deletions instruments/agilent/agilent33220a.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ class Agilent33220a(SCPIFunctionGenerator):
"""

def __init__(self, filelike):
super(Agilent33220a, self).__init__(filelike)

# ENUMS #

class Function(Enum):
Expand Down
3 changes: 0 additions & 3 deletions instruments/agilent/agilent34410a.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ class Agilent34410a(SCPIMultimeter): # pylint: disable=abstract-method
.. _Keysight website: http://www.keysight.com/
"""

def __init__(self, filelike):
super(Agilent34410a, self).__init__(filelike)

# PROPERTIES #

@property
Expand Down
6 changes: 3 additions & 3 deletions instruments/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ def walk_dict(d, path):
if not path[0]:
# If the first part of the path is empty, do nothing.
return walk_dict(d, path[1:])
else:
# Otherwise, resolve that segment and recurse.
return walk_dict(d[path[0]], path[1:])

# Otherwise, resolve that segment and recurse.
return walk_dict(d[path[0]], path[1:])

def quantity_constructor(loader, node):
"""
Expand Down
3 changes: 0 additions & 3 deletions instruments/generic_scpi/scpi_function_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ class SCPIFunctionGenerator(FunctionGenerator, SCPIInstrument):
>>> inst.frequency = 1 * pq.kHz
"""

def __init__(self, filelike):
super(SCPIFunctionGenerator, self).__init__(filelike)

# CONSTANTS #

_UNIT_MNEMONICS = {
Expand Down
3 changes: 0 additions & 3 deletions instruments/generic_scpi/scpi_instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ class SCPIInstrument(Instrument):
>>> print(inst.name)
"""

def __init__(self, filelike):
super(SCPIInstrument, self).__init__(filelike)

# PROPERTIES #

@property
Expand Down
5 changes: 1 addition & 4 deletions instruments/generic_scpi/scpi_multimeter.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ class SCPIMultimeter(SCPIInstrument, Multimeter):
>>> print(inst.measure(inst.Mode.resistance))
"""

def __init__(self, filelike):
super(SCPIMultimeter, self).__init__(filelike)

# ENUMS ##

class Mode(Enum):
Expand Down Expand Up @@ -142,7 +139,7 @@ class SampleSource(Enum):

# PROPERTIES ##

# pylint: disable=unnecessary-lambda
# pylint: disable=unnecessary-lambda,undefined-variable
mode = enum_property(
name="CONF",
enum=Mode,
Expand Down
3 changes: 0 additions & 3 deletions instruments/hp/hp6632b.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,6 @@ class HP6632b(SCPIInstrument, HP6652a):
array(10.0) * V
"""

def __init__(self, filelike):
super(HP6632b, self).__init__(filelike)

# ENUMS ##

class ALCBandwidth(IntEnum):
Expand Down
3 changes: 0 additions & 3 deletions instruments/hp/hp6652a.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ class HP6652a(PowerSupply, PowerSupplyChannel):
>>> psu.display_textmode=False
"""

def __init__(self, filelike):
super(HP6652a, self).__init__(filelike)

# ENUMS ##

# I don't know of any possible enumerations supported
Expand Down
10 changes: 5 additions & 5 deletions instruments/keithley/keithley195.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,11 @@ def input_range(self):
index = self.parse_status_word(self.get_status_word())['range']
if index == 0:
return 'auto'
else:
mode = self.mode
value = Keithley195.ValidRange[mode.name].value[index - 1]
units = UNITS2[mode]
return value * units

mode = self.mode
value = Keithley195.ValidRange[mode.name].value[index - 1]
units = UNITS2[mode]
return value * units

@input_range.setter
def input_range(self, newval):
Expand Down
3 changes: 0 additions & 3 deletions instruments/keithley/keithley2182.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ class Keithley2182(SCPIMultimeter):
"""

def __init__(self, filelike):
super(Keithley2182, self).__init__(filelike)

# INNER CLASSES #

class Channel(Multimeter):
Expand Down
8 changes: 4 additions & 4 deletions instruments/keithley/keithley580.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,8 +463,8 @@ def parse_measurement(measurement):

# COMMUNICATOR METHODS #

def sendcmd(self, msg):
super(Keithley580, self).sendcmd(msg + ':')
def sendcmd(self, cmd):
super(Keithley580, self).sendcmd(cmd + ':')

def query(self, msg, size=-1):
return super(Keithley580, self).query(msg + ':', size)[:-1]
def query(self, cmd, size=-1):
return super(Keithley580, self).query(cmd + ':', size)[:-1]
4 changes: 2 additions & 2 deletions instruments/ondax/lm.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,8 @@ def enabled(self, newval):
def _ack_expected(self, msg=""):
if msg.find("?") > 0:
return None
else:
return "OK"

return "OK"

@property
def firmware(self):
Expand Down
4 changes: 2 additions & 2 deletions instruments/qubitekk/cc1.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ def dwell_time(self):
dwell_time = pq.Quantity(*split_unit_str(self.query("DWEL?"), "s"))
if self.firmware[0] <= 2 and self.firmware[1] <= 1:
return dwell_time/1000.0
else:
return dwell_time

return dwell_time

@dwell_time.setter
def dwell_time(self, new_val):
Expand Down
3 changes: 0 additions & 3 deletions instruments/rigol/rigolds1000.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ class DataSource(OscilloscopeDataSource):
is designed to be initialized by the `RigolDS1000Series` class.
"""

def __init__(self, parent, name):
super(RigolDS1000Series.DataSource, self).__init__(parent, name)

@property
def name(self):
return self._name
Expand Down
4 changes: 2 additions & 2 deletions instruments/srs/srs830.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ def __init__(self, filelike, outx_mode=None): # pragma: no cover
will be sent depending on what type of communicator self._file is.
"""
super(SRS830, self).__init__(filelike)
if outx_mode is 1:
if outx_mode == 1:
self.sendcmd("OUTX 1")
elif outx_mode is 2:
elif outx_mode == 2:
self.sendcmd("OUTX 2")
else:
if isinstance(self._file, GPIBCommunicator):
Expand Down
2 changes: 1 addition & 1 deletion instruments/srs/srsctc100.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def stats_enabled(self):
:type: `bool`
"""
return True if self._get('stats') is 'On' else False
return True if self._get('stats') == 'On' else False

@stats_enabled.setter
def stats_enabled(self, newval):
Expand Down
10 changes: 6 additions & 4 deletions instruments/tektronix/tekdpo4104.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,10 @@ def __exit__(self, type, value, traceback):
def __eq__(self, other):
if not isinstance(other, type(self)):
return NotImplemented
else:
return other.name == self.name

return other.name == self.name

__hash__ = None

def read_waveform(self, bin_format=True):
"""
Expand Down Expand Up @@ -259,8 +261,8 @@ def data_source(self):
name = self.query("DAT:SOU?")
if name.startswith("CH"):
return _TekDPO4104Channel(self, int(name[2:]) - 1)
else:
return _TekDPO4104DataSource(self, name)

return _TekDPO4104DataSource(self, name)

@data_source.setter
def data_source(self, newval):
Expand Down
3 changes: 0 additions & 3 deletions instruments/tektronix/tekdpo70000.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,6 @@ class DataSource(OscilloscopeDataSource):
is designed to be initialized by the `TekDPO70000` class.
"""

def __init__(self, parent, name):
super(TekDPO70000.DataSource, self).__init__(parent, name)

@property
def name(self):
return self._name
Expand Down
4 changes: 2 additions & 2 deletions instruments/tektronix/tektds224.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ def data_source(self):
name = self.query("DAT:SOU?")
if name.startswith("CH"):
return _TekTDS224Channel(self, int(name[2:]) - 1)
else:
return _TekTDS224DataSource(self, name)

return _TekTDS224DataSource(self, name)

@data_source.setter
def data_source(self, newval):
Expand Down
11 changes: 4 additions & 7 deletions instruments/tektronix/tektds5xx.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ def read(self):
resp = self._tek.query('MEASU:MEAS{}:VAL?'.format(self._id))
self._data['value'] = float(resp)
return self._data
else:
return self._data

return self._data


class _TekTDS5xxDataSource(OscilloscopeDataSource):
Expand All @@ -97,9 +97,6 @@ class _TekTDS5xxDataSource(OscilloscopeDataSource):
designed to be initialized by the `TekTDS5xx` class.
"""

def __init__(self, parent, name):
super(_TekTDS5xxDataSource, self).__init__(parent, name)

@property
def name(self):
"""
Expand Down Expand Up @@ -434,8 +431,8 @@ def data_source(self):
name = self.query("DAT:SOU?")
if name.startswith("CH"):
return _TekTDS5xxChannel(self, int(name[2:]) - 1)
else:
return _TekTDS5xxDataSource(self, name)

return _TekTDS5xxDataSource(self, name)

@data_source.setter
def data_source(self, newval):
Expand Down
2 changes: 1 addition & 1 deletion instruments/tests/test_comm/test_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def test_filecomm_terminator():
comm.terminator = "*"
eq_(comm._terminator, "*")

comm.terminator = b"*" # pylint: disable=redefined-variable-type
comm.terminator = b"*"
eq_(comm._terminator, "*")


Expand Down
2 changes: 1 addition & 1 deletion instruments/tests/test_comm/test_gi_gpibusb.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def test_gpibusbcomm_address():
eq_(comm._gpib_address, 5)

# Able to set address with a list
comm.address = [6, "/dev/foobar"] # pylint: disable=redefined-variable-type
comm.address = [6, "/dev/foobar"]
eq_(comm._gpib_address, 6)
port_name.assert_called_with("/dev/foobar")

Expand Down
2 changes: 1 addition & 1 deletion instruments/tests/test_comm/test_loopback.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def test_loopbackcomm_terminator():
eq_(comm.terminator, "*")
eq_(comm._terminator, "*")

comm.terminator = u"\r" # pylint: disable=redefined-variable-type
comm.terminator = u"\r"
eq_(comm.terminator, u"\r")
eq_(comm._terminator, u"\r")

Expand Down
2 changes: 1 addition & 1 deletion instruments/tests/test_comm/test_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def test_socketcomm_terminator():
eq_(comm.terminator, "*")
eq_(comm._terminator, "*")

comm.terminator = u"\r" # pylint: disable=redefined-variable-type
comm.terminator = u"\r"
eq_(comm.terminator, u"\r")
eq_(comm._terminator, u"\r")

Expand Down
2 changes: 1 addition & 1 deletion instruments/tests/test_comm/test_usbtmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def test_usbtmccomm_terminator_setter(mock_usbtmc):
eq_(comm._terminator, "*")
term_char.assert_called_with(42)

comm.terminator = b"*" # pylint: disable=redefined-variable-type
comm.terminator = b"*"
eq_(comm._terminator, "*")
term_char.assert_called_with(42)

Expand Down
Loading

0 comments on commit 6c6dbb4

Please sign in to comment.