From c1164568ae6310cdb673a9fb292725d936feeff5 Mon Sep 17 00:00:00 2001 From: Markus Zolliker Date: Thu, 26 Sep 2019 13:17:49 +0200 Subject: [PATCH] further fixes of py3 issues complaints by pylint are mainly related to - remove object from base list in class definitions - unnecessary else/elif after return/raise Change-Id: I13d15449149cc8bba0562338d0c9c42e97163bdf Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/21325 Tested-by: JenkinsCodeReview Reviewed-by: Markus Zolliker --- bin/cfg-editor | 1 + bin/secop-console | 2 +- bin/secop-server | 2 +- secop/client/__init__.py | 6 +++--- secop/client/baseclient.py | 8 ++++---- secop/datatypes.py | 16 ++++++++-------- secop/features.py | 3 +-- secop/gui/cfg_editor/mainwindow.py | 4 ++-- secop/gui/cfg_editor/node_display.py | 2 +- secop/gui/cfg_editor/widgets.py | 5 ++--- secop/gui/miniplot.py | 2 +- secop/gui/nodectrl.py | 2 +- secop/lib/__init__.py | 4 ++-- secop/lib/enum.py | 8 ++++---- secop/lib/parsing.py | 10 ++++------ secop/lib/sequence.py | 10 +++++----- secop/metaclass.py | 4 ++-- secop/modules.py | 1 + secop/params.py | 14 ++++++-------- secop/parse.py | 6 +++--- secop/poller.py | 4 ++-- secop/properties.py | 12 ++++++------ secop/protocol/dispatcher.py | 7 +++---- secop/server.py | 2 +- secop/simulation.py | 2 +- secop/version.py | 9 ++++----- secop_demo/modules.py | 6 +++--- secop_ess/epics.py | 4 ++-- secop_mlz/amagnet.py | 2 +- test/conftest.py | 2 +- test/test_basic_validators.py | 2 +- test/test_client_baseclient.py | 2 +- test/test_poller.py | 8 ++++---- 33 files changed, 83 insertions(+), 89 deletions(-) diff --git a/bin/cfg-editor b/bin/cfg-editor index 388b868..9e4fdd4 100755 --- a/bin/cfg-editor +++ b/bin/cfg-editor @@ -1,4 +1,5 @@ #!/usr/bin/env python +# pylint: disable=invalid-name # -*- coding: utf-8 -*- # ***************************************************************************** # diff --git a/bin/secop-console b/bin/secop-console index 1acf828..babb778 100755 --- a/bin/secop-console +++ b/bin/secop-console @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# pylint: disable=invalid-name # -*- coding: utf-8 -*- # ***************************************************************************** # @@ -21,7 +22,6 @@ # # ***************************************************************************** -import os import sys import argparse from os import path diff --git a/bin/secop-server b/bin/secop-server index acbffc4..008f442 100755 --- a/bin/secop-server +++ b/bin/secop-server @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# pylint: disable=invalid-name # -*- coding: utf-8 -*- # ***************************************************************************** # @@ -22,7 +23,6 @@ # # ***************************************************************************** -import os import sys import argparse from os import path diff --git a/secop/client/__init__.py b/secop/client/__init__.py index 69bcd82..801cc09 100644 --- a/secop/client/__init__.py +++ b/secop/client/__init__.py @@ -74,7 +74,7 @@ def getClientOpts(cfgfile): return dict(item for item in parser.items('client')) -class ClientConsole(object): +class ClientConsole: def __init__(self, cfgname, basepath): self.namespace = NameSpace() @@ -99,7 +99,7 @@ class ClientConsole(object): help(arg) -class TCPConnection(object): +class TCPConnection: def __init__(self, connect, port, **kwds): self.log = mlzlog.log.getChild('connection', False) @@ -173,7 +173,7 @@ class TCPConnection(object): self.callbacks.discard(callback) -class Client(object): +class Client: def __init__(self, opts): self.log = mlzlog.log.getChild('client', True) diff --git a/secop/client/baseclient.py b/secop/client/baseclient.py index 87d4d0d..989819e 100644 --- a/secop/client/baseclient.py +++ b/secop/client/baseclient.py @@ -44,7 +44,7 @@ from secop.protocol.messages import BUFFERREQUEST, COMMANDREQUEST, \ READREQUEST, REQUEST2REPLY, WRITEREPLY, WRITEREQUEST -class TCPConnection(object): +class TCPConnection: # disguise a TCP connection as serial one def __init__(self, host, port): @@ -136,7 +136,7 @@ class TCPConnection(object): self.writeline(line) -class Value(object): +class Value: t = None # pylint: disable = C0103 u = None e = None @@ -165,7 +165,7 @@ class Value(object): return self.fmtstr % self.value -class Client(object): +class Client: secop_id = 'unknown' describing_data = {} stopflag = False @@ -175,7 +175,7 @@ class Client(object): if 'testing' not in opts: self.log = mlzlog.log.getChild('client', True) else: - class logStub(object): + class logStub: def info(self, *args): pass diff --git a/secop/datatypes.py b/secop/datatypes.py index b986132..8f2c64d 100644 --- a/secop/datatypes.py +++ b/secop/datatypes.py @@ -48,7 +48,7 @@ DEFAULT_MAX_INT = 16777216 Parser = Parser() # base class for all DataTypes -class DataType(object): +class DataType: IS_COMMAND = False unit = '' fmtstr = '%r' @@ -353,7 +353,7 @@ class EnumType(DataType): class BLOBType(DataType): - minbytes = None + minbytes = 0 maxbytes = None def __init__(self, minbytes=0, maxbytes=None): @@ -366,7 +366,7 @@ class BLOBType(DataType): self.maxbytes = int(maxbytes) if self.minbytes < 0: raise BadValueError('sizes must be bigger than or equal to 0!') - elif self.minbytes > self.maxbytes: + if self.minbytes > self.maxbytes: raise BadValueError('maxbytes must be bigger than or equal to minbytes!') self.default = b'\0' * self.minbytes @@ -418,7 +418,7 @@ class StringType(DataType): self.set_prop('isUTF8', isUTF8, False, bool) if self.minchars < 0: raise BadValueError('sizes must be bigger than or equal to 0!') - elif self.minchars > self.maxchars: + if self.minchars > self.maxchars: raise BadValueError('maxchars must be bigger than or equal to minchars!') self.default = ' ' * self.minchars @@ -504,7 +504,7 @@ class BoolType(DataType): def export_value(self, value): """returns a python object fit for serialisation""" - return True if self(value) else False + return bool(self(value)) def import_value(self, value): """returns a python object from serialisation""" @@ -544,9 +544,9 @@ class ArrayOf(DataType): self.maxlen = int(maxlen) if self.minlen < 0: raise BadValueError('sizes must be > 0') - elif self.maxlen < 1: + if self.maxlen < 1: raise BadValueError('Maximum size must be >= 1!') - elif self.minlen > self.maxlen: + if self.minlen > self.maxlen: raise BadValueError('maxlen must be bigger than or equal to minlen!') self.default = [members.default] * self.minlen @@ -890,7 +890,7 @@ DATATYPES = dict( blob =lambda maxbytes, minbytes=0: BLOBType(minbytes=minbytes, maxbytes=maxbytes), string =lambda minchars=0, maxchars=None: StringType(minchars=minchars, maxchars=maxchars), array =lambda maxlen, members, minlen=0: ArrayOf(get_datatype(members), minlen=minlen, maxlen=maxlen), - tuple =lambda members: TupleOf(*map(get_datatype, members)), + tuple =lambda members: TupleOf(*tuple(map(get_datatype, members))), enum =lambda members: EnumType('', members=members), struct =lambda members, optional=None: StructOf(optional, **dict((n, get_datatype(t)) for n, t in list(members.items()))), diff --git a/secop/features.py b/secop/features.py index f9b4e51..8eb9d11 100644 --- a/secop/features.py +++ b/secop/features.py @@ -28,9 +28,8 @@ from secop.metaclass import ModuleMeta from secop.modules import Command, Parameter -class Feature(object, metaclass=ModuleMeta): +class Feature(metaclass=ModuleMeta): """all things belonging to a small, predefined functionality influencing the working of a module""" - pass class HAS_PID(Feature): diff --git a/secop/gui/cfg_editor/mainwindow.py b/secop/gui/cfg_editor/mainwindow.py index 68f12bf..66284b6 100644 --- a/secop/gui/cfg_editor/mainwindow.py +++ b/secop/gui/cfg_editor/mainwindow.py @@ -136,7 +136,7 @@ class MainWindow(QMainWindow): reply = self.show_save_message(self.tabWidget.tabText(index)) if reply == QMessageBox.Cancel: return - elif reply == QMessageBox.Save: + if reply == QMessageBox.Save: self.save_tab(index) self.tabWidget.removeTab(index) @@ -158,7 +158,7 @@ class MainWindow(QMainWindow): if reply == QMessageBox.Cancel: event.ignore() return - elif reply == QMessageBox.Save: + if reply == QMessageBox.Save: for i in range(0, self.tabWidget.count()): self.save_tab(i) event.accept() diff --git a/secop/gui/cfg_editor/node_display.py b/secop/gui/cfg_editor/node_display.py index 3f701eb..4b80833 100644 --- a/secop/gui/cfg_editor/node_display.py +++ b/secop/gui/cfg_editor/node_display.py @@ -28,7 +28,7 @@ class NodeDisplay(QWidget): def __init__(self, file_path=None, parent=None): QWidget.__init__(self, parent) loadUi(self, 'node_display.ui') - self.saved = True if file_path else False + self.saved = bool(file_path) self.created = self.tree_widget.set_file(file_path) self.tree_widget.save_status_changed.connect(self.change_save_status) self.tree_widget.currentItemChanged.connect(self.set_scroll_area) diff --git a/secop/gui/cfg_editor/widgets.py b/secop/gui/cfg_editor/widgets.py index ac562f8..46c325c 100644 --- a/secop/gui/cfg_editor/widgets.py +++ b/secop/gui/cfg_editor/widgets.py @@ -104,8 +104,7 @@ class TreeWidget(QTreeWidget): self.set_tree(read_config(self.file_path)) self.emit_save_status_changed(True) return True - else: - self.file_path = None + self.file_path = None return self.new_tree() def new_tree(self): @@ -391,7 +390,7 @@ class AddDialog(QDialog): if self.exec_() == QDialog.Accepted: if self.kind in [NODE, MODULE, INTERFACE]: return [self.name.text(), self.get_value()] - elif self.kind in [PARAMETER, PROPERTY, COMMENT]: + if self.kind in [PARAMETER, PROPERTY, COMMENT]: return [self.get_value()] return None diff --git a/secop/gui/miniplot.py b/secop/gui/miniplot.py index 998e677..0e43318 100644 --- a/secop/gui/miniplot.py +++ b/secop/gui/miniplot.py @@ -44,7 +44,7 @@ _orange = QBrush(QColor('#ffa500')) my_uipath = path.dirname(__file__) -class MiniPlotCurve(object): +class MiniPlotCurve: # placeholder for data linecolor = _black linewidth = 0 # set to 0 to disable lines diff --git a/secop/gui/nodectrl.py b/secop/gui/nodectrl.py index fa847d6..535e557 100644 --- a/secop/gui/nodectrl.py +++ b/secop/gui/nodectrl.py @@ -25,6 +25,7 @@ import json import pprint from time import sleep +import mlzlog from secop.datatypes import EnumType, StringType from secop.errors import SECoPError @@ -222,7 +223,6 @@ class ReadableWidget(QWidget): try: # if queried, we get the qualifiers as well, but don't want them # here - import mlzlog mlzlog.getLogger('cached values').warn( 'no cached value for %s:%s' % (self._module, pname)) val = self._node.getParameter(self._module, pname)[0] diff --git a/secop/lib/__init__.py b/secop/lib/__init__.py index f424756..240c78c 100644 --- a/secop/lib/__init__.py +++ b/secop/lib/__init__.py @@ -32,6 +32,7 @@ import subprocess import sys import threading import traceback +import importlib from os import path repodir = path.abspath(path.join(path.dirname(__file__), '..', '..')) @@ -51,7 +52,7 @@ CONFIG = { unset_value = object() -class lazy_property(object): +class lazy_property: """A property that calculates its value only once.""" def __init__(self, func): @@ -89,7 +90,6 @@ def clamp(_min, value, _max): def get_class(spec): """loads a class given by string in dotted notaion (as python would do)""" modname, classname = spec.rsplit('.', 1) - import importlib if modname.startswith('secop'): module = importlib.import_module(modname) else: diff --git a/secop/lib/enum.py b/secop/lib/enum.py index f459584..3bc7d45 100755 --- a/secop/lib/enum.py +++ b/secop/lib/enum.py @@ -26,7 +26,7 @@ __ALL__ = ['Enum'] -class EnumMember(object): +class EnumMember: """represents one member of an Enum has an int-type value and attributes 'name' and 'value' @@ -53,7 +53,7 @@ class EnumMember(object): return -1 # XXX:! if self.value < other: return -1 - elif self.value > other: + if self.value > other: return 1 return 0 @@ -262,7 +262,7 @@ class Enum(dict): elif isinstance(parent, dict): for k, v in parent.items(): add(self, k, v) - elif parent != None: + elif parent is not None: raise TypeError('parent (if given) MUST be a dict or an Enum!') for k, v in kwds.items(): add(self, k, v) @@ -286,7 +286,7 @@ class Enum(dict): raise TypeError('Enum %r can not be changed!' % self.name) def __repr__(self): - return '' % (self.name, len(self)/2) + return '' % (self.name, len(self)//2) def __call__(self, key): return self[key] diff --git a/secop/lib/parsing.py b/secop/lib/parsing.py index c085f06..8cda36a 100644 --- a/secop/lib/parsing.py +++ b/secop/lib/parsing.py @@ -149,7 +149,7 @@ def format_args(args): return repr(args) # for floats/ints/... -class ArgsParser(object): +class ArgsParser: """returns a pythonic object from the input expression grammar: @@ -164,10 +164,8 @@ class ArgsParser(object): name = [A-Za-z_] [A-Za-z0-9_]* """ - DIGITS_CHARS = [c for c in '0123456789'] - NAME_CHARS = [ - c for c in '_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' - ] + DIGITS_CHARS = '0123456789' + NAME_CHARS = '_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' NAME_CHARS2 = NAME_CHARS + DIGITS_CHARS def __init__(self, string=''): @@ -276,7 +274,7 @@ class ArgsParser(object): def parse_record(self): """record_expr = '(' (name '=' expr ',')* ')' """ - if self.get != '(': + if self.get() != '(': return None self.skip() res = {} diff --git a/secop/lib/sequence.py b/secop/lib/sequence.py index b17a58e..0ea5426 100644 --- a/secop/lib/sequence.py +++ b/secop/lib/sequence.py @@ -30,11 +30,11 @@ from secop.errors import IsBusyError from secop.lib import mkthread -class Namespace(object): +class Namespace: pass -class Step(object): +class Step: def __init__(self, desc, waittime, func, *args, **kwds): self.desc = desc @@ -44,7 +44,7 @@ class Step(object): self.kwds = kwds -class SequencerMixin(object): +class SequencerMixin: """Mixin for worker classes that need to execute a sequence of actions, including waits, that exceeds the usual Tango timeout (about 3 seconds) and should be executed asynchronously. @@ -129,11 +129,11 @@ class SequencerMixin(object): def read_status(self): if self.seq_is_alive(): return self.Status.BUSY, 'moving: ' + self._seq_phase - elif self._seq_error: + if self._seq_error: if self._seq_fault_on_error: return self.Status.ERROR, self._seq_error return self.Status.WARN, self._seq_error - elif self._seq_stopped: + if self._seq_stopped: if self._seq_fault_on_stop: return self.Status.ERROR, self._seq_stopped return self.Status.WARN, self._seq_stopped diff --git a/secop/metaclass.py b/secop/metaclass.py index dee49c8..7303fb0 100644 --- a/secop/metaclass.py +++ b/secop/metaclass.py @@ -45,12 +45,12 @@ class ModuleMeta(PropertyMeta): and wraps read_*/write_* methods (so the dispatcher will get notfied of changed values) """ - def __new__(mcs, name, bases, attrs): + def __new__(cls, name, bases, attrs): commands = attrs.pop('commands', {}) parameters = attrs.pop('parameters', {}) overrides = attrs.pop('overrides', {}) - newtype = type.__new__(mcs, name, bases, attrs) + newtype = type.__new__(cls, name, bases, attrs) if '__constructed__' in attrs: return newtype diff --git a/secop/modules.py b/secop/modules.py index 265631e..c123904 100644 --- a/secop/modules.py +++ b/secop/modules.py @@ -324,6 +324,7 @@ class Readable(Module): rfunc() # pylint: disable = not-callable except Exception: # really all! pass + return False class Writable(Readable): diff --git a/secop/params.py b/secop/params.py index d0d3ae1..4f0e0a5 100644 --- a/secop/params.py +++ b/secop/params.py @@ -30,7 +30,7 @@ from secop.errors import ProgrammingError from secop.properties import HasProperties, Property -class CountedObj(object): +class CountedObj: ctr = [0] def __init__(self): cl = self.__class__.ctr @@ -163,7 +163,7 @@ class Parameter(Accessible): del _set_unit_ -class UnusedClass(object): +class UnusedClass: # do not derive anything from this! pass @@ -186,7 +186,7 @@ class Parameters(OrderedDict): return super(Parameters, self).__getitem__(self.exported.get(item, item)) -class ParamValue(object): +class ParamValue: __slots__ = ['value', 'timestamp'] def __init__(self, value, timestamp=0): self.value = value @@ -195,7 +195,6 @@ class ParamValue(object): class Commands(Parameters): """class storage for Commands""" - pass class Override(CountedObj): @@ -232,10 +231,9 @@ class Override(CountedObj): #props['ctr'] = self.ctr return type(obj)(ctr=self.ctr, **props) return type(obj)(**props) - else: - raise ProgrammingError( - u"Overrides can only be applied to Accessibles, %r is none!" % - obj) + raise ProgrammingError( + u"Overrides can only be applied to Accessibles, %r is none!" % + obj) class Command(Accessible): diff --git a/secop/parse.py b/secop/parse.py index 374a483..ad3ad97 100644 --- a/secop/parse.py +++ b/secop/parse.py @@ -40,7 +40,7 @@ further convertions are done by the validator of the datatype.... from collections import OrderedDict -class Parser(object): +class Parser: # all parsing methods return (parsed value, remaining string) # or (None, remaining_text) if parsing error @@ -153,9 +153,9 @@ class Parser(object): return None, orgtext if text[0] in '+-.0123456789': return self.parse_number(orgtext) - elif text[0] == '{': + if text[0] == '{': return self.parse_dict(orgtext) - elif text[0] in '([<': + if text[0] in '([<': return self.parse_tuple(orgtext) return self.parse_string(orgtext) diff --git a/secop/poller.py b/secop/poller.py index 5c2bfa6..7372423 100644 --- a/secop/poller.py +++ b/secop/poller.py @@ -45,7 +45,7 @@ SLOW = 2 REGULAR = 3 DYNAMIC = 4 -class PollerBase(object): +class PollerBase: startup_timeout = 30 # default timeout for startup name = 'unknown' # to be overridden in implementors __init__ method @@ -149,7 +149,7 @@ class Poller(PollerBase): raise ProgrammingError("module %s must have a pollinterval" % module.name) if polltype == AUTO: # covers also pobj.poll == True - if pname == 'value' or pname == 'status': + if pname in ('value', 'status'): polltype = DYNAMIC elif pobj.readonly: polltype = REGULAR diff --git a/secop/properties.py b/secop/properties.py index 0ad8bd2..90e3f33 100644 --- a/secop/properties.py +++ b/secop/properties.py @@ -29,7 +29,7 @@ from secop.errors import ProgrammingError, ConfigError # storage for 'properties of a property' -class Property(object): +class Property: '''base class holding info about a property properties are only sent to the ECS if export is True, or an extname is set @@ -82,18 +82,18 @@ class PropertyMeta(type): joining the class's properties with those of base classes. """ - def __new__(mcs, name, bases, attrs): - newtype = type.__new__(mcs, name, bases, attrs) + def __new__(cls, name, bases, attrs): + newtype = type.__new__(cls, name, bases, attrs) if '__constructed__' in attrs: return newtype - newtype = mcs.__join_properties__(newtype, name, bases, attrs) + newtype = cls.__join_properties__(newtype, name, bases, attrs) attrs['__constructed__'] = True return newtype @classmethod - def __join_properties__(mcs, newtype, name, bases, attrs): + def __join_properties__(cls, newtype, name, bases, attrs): # merge properties from all sub-classes properties = Properties() for base in reversed(bases): @@ -114,7 +114,7 @@ class PropertyMeta(type): return newtype -class HasProperties(object, metaclass=PropertyMeta): +class HasProperties(metaclass=PropertyMeta): properties = {} def __init__(self, supercall_init=True): diff --git a/secop/protocol/dispatcher.py b/secop/protocol/dispatcher.py index 9654e64..e7ccfaf 100644 --- a/secop/protocol/dispatcher.py +++ b/secop/protocol/dispatcher.py @@ -50,7 +50,7 @@ from secop.protocol.messages import COMMANDREPLY, DESCRIPTIONREPLY, \ HEARTBEATREPLY, IDENTREPLY, IDENTREQUEST, READREPLY, WRITEREPLY -class Dispatcher(object): +class Dispatcher: def __init__(self, name, logger, options, srv): # to avoid errors, we want to eat all options here @@ -145,7 +145,7 @@ class Dispatcher(object): def get_module(self, modulename): if modulename in self._modules: return self._modules[modulename] - elif modulename in list(self._modules.values()): + if modulename in list(self._modules.values()): return modulename raise NoSuchModuleError('Module does not exist on this SEC-Node!') @@ -296,8 +296,7 @@ class Dispatcher(object): if handler: return handler(conn, specifier, data) - else: - raise InternalError('unhandled message!') + raise InternalError('unhandled message!') # now the (defined) handlers for the different requests def handle_help(self, conn, specifier, data): diff --git a/secop/server.py b/secop/server.py index 7c5c3f4..09ac38a 100644 --- a/secop/server.py +++ b/secop/server.py @@ -40,7 +40,7 @@ except ImportError: import daemon.pidfile as pidlockfile -class Server(object): +class Server: # list allowed section prefixes # if mapped dict does not exist -> section need a 'class' option # otherwise a 'type' option is evaluatet and the class from the mapping dict used diff --git a/secop/simulation.py b/secop/simulation.py index 8e4653a..8a7d66c 100644 --- a/secop/simulation.py +++ b/secop/simulation.py @@ -30,7 +30,7 @@ from secop.lib import mkthread from secop.modules import Drivable, Module, Parameter, Readable, Writable -class SimBase(object): +class SimBase: def __init__(self, cfgdict): # spice up parameters if requested by extra property # hint: us a comma-separated list if mor than one extra_param diff --git a/secop/version.py b/secop/version.py index 670337c..3a43f9b 100644 --- a/secop/version.py +++ b/secop/version.py @@ -68,12 +68,11 @@ def get_version(abbrev=4): if git_version != release_version: write_release_version(git_version) return git_version - elif release_version: + if release_version: return release_version - else: - raise ValueError('Cannot find a version number - make sure that ' - 'git is installed or a RELEASE-VERSION file is ' - 'present!') + raise ValueError('Cannot find a version number - make sure that ' + 'git is installed or a RELEASE-VERSION file is ' + 'present!') if __name__ == "__main__": diff --git a/secop_demo/modules.py b/secop_demo/modules.py index f16a854..895c3d3 100644 --- a/secop_demo/modules.py +++ b/secop_demo/modules.py @@ -155,11 +155,11 @@ class MagneticField(Drivable): if self._state == self._state.enum.idle: return (PERSIST, 'at field') if self.value else \ (self.Status.IDLE, 'zero field') - elif self._state == self._state.enum.switch_on: + if self._state == self._state.enum.switch_on: return (self.Status.PREPARE, self._state.name) - elif self._state == self._state.enum.switch_off: + if self._state == self._state.enum.switch_off: return (self.Status.FINISH, self._state.name) - elif self._state == self._state.enum.ramp: + if self._state == self._state.enum.ramp: return (self.Status.RAMPING, self._state.name) return (self.Status.ERROR, self._state.name) diff --git a/secop_ess/epics.py b/secop_ess/epics.py index 4d762f5..c536f0a 100644 --- a/secop_ess/epics.py +++ b/secop_ess/epics.py @@ -27,7 +27,7 @@ from secop.modules import Drivable, Parameter, Readable try: from pvaccess import Channel # import EPIVSv4 functionallity, PV access except ImportError: - class Channel(object): + class Channel: def __init__(self, pv_name): self.pv_name = pv_name @@ -48,7 +48,7 @@ except ImportError: try: from epics import PV except ImportError: - class PV(object): + class PV: def __init__(self, pv_name): self.pv_name = pv_name diff --git a/secop_mlz/amagnet.py b/secop_mlz/amagnet.py index 5ebfc7e..b21550f 100644 --- a/secop_mlz/amagnet.py +++ b/secop_mlz/amagnet.py @@ -116,7 +116,7 @@ class GarfieldMagnet(SequencerMixin, Drivable): if field == tryfield: self.log.debug('current for %g T is %g A', field, trycurr) return trycurr # Gotcha! - elif field > tryfield: + if field > tryfield: # retry upper interval mincurr = trycurr minfield = tryfield diff --git a/test/conftest.py b/test/conftest.py index 244a171..6289b9b 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -6,7 +6,7 @@ import pytest @pytest.fixture(scope="module") def constants(): # setup - class Constants(object): + class Constants: ONE = 1 TWO = 2 c = Constants() diff --git a/test/test_basic_validators.py b/test/test_basic_validators.py index dfdfaba..e730bf4 100644 --- a/test/test_basic_validators.py +++ b/test/test_basic_validators.py @@ -29,7 +29,7 @@ from secop.basic_validators import FloatProperty, PositiveFloatProperty, \ NonNegativeIntProperty, BoolProperty, StringProperty, UnitProperty, \ FmtStrProperty, OneOfProperty, NoneOr, EnumProperty, TupleProperty -class unprintable(object): +class unprintable: def __str__(self): raise NotImplementedError diff --git a/test/test_client_baseclient.py b/test/test_client_baseclient.py index fe0fa0b..040f9cf 100644 --- a/test/test_client_baseclient.py +++ b/test/test_client_baseclient.py @@ -30,7 +30,7 @@ from secop.client.baseclient import Client # define Test-only connection object -class TestConnect(object): +class TestConnect: callbacks = [] def writeline(self, line): diff --git a/test/test_poller.py b/test/test_poller.py index 1f3ba95..07b0b5f 100644 --- a/test/test_poller.py +++ b/test/test_poller.py @@ -28,7 +28,7 @@ from secop.modules import Drivable from secop.poller import Poller, REGULAR, DYNAMIC, SLOW Status = Drivable.Status -class Time(object): +class Time: STARTTIME = 1000 # artificial time zero def __init__(self): self.reset() @@ -65,7 +65,7 @@ def patch_time(monkeypatch): monkeypatch.setattr(time, 'time', artime.time) -class Event(object): +class Event: def __init__(self): self.flag = False @@ -79,7 +79,7 @@ class Event(object): return self.flag -class Parameter(object): +class Parameter: def __init__(self, name, readonly, poll, polltype, interval): self.poll = poll self.polltype = polltype # used for check only @@ -107,7 +107,7 @@ class Parameter(object): return 'Parameter(%s)' % ", ".join("%s=%r" % item for item in self.__dict__.items()) -class Module(object): +class Module: properties = {} pollerClass = Poller iodev = 'common_iodev'