Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Add call to super().__init__() where appropriate #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mbanszex
Copy link
Member

@mbanszex mbanszex commented Feb 9, 2017

Uppon receiving review comments about missing call to super init() I scanned the taf for W0231 warning (super-init-not-called). Pylint has showed this warning at 12 places and I tried to fixed that where I thought it was appropriate.
Have a look if it is worth fixing it.
It is not tested, though.


This change is Reviewable

@@ -44,7 +44,7 @@ def __init__(self, config, opts, env):
@type env: Environment
"""
self.class_logger.debug("Create AFS object.")
self.opts = opts
super().__init__(config, opts)

# Correcting AFS port map
if "mapcorrector" in config:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this:

map_corrector = config.get('mapcorrector', {})
for dev_id, device in mapcorrector.items():
  dev_id_int = int(dev_id)
  valid_dev_set = {int(key) for key in device}
  # remove unnecessary items
  portmap = config['portmap']
  for items in portmap[:]:
    if items[0] == dev_id_int and items[1] not in valid_dev_set:
      portmap.remove(items)
  # correct port IDs
  for items in portmap:
    if items[0] == dev_id_int:
      items[1] = int(device[str(items[1])]

And I think we can drop lines 68 and 69.

Is there significance to the filtering of config? If yes, then perhaps the GenericEntry should allow descendants to give a set of keys that will be used to filter the config:

class GenericEntry(...):
  CONFIG_KEYS_ALLOWED = set()
  ...
  def __init__(...):
    ...
   if self.CONFIG_KEYS_ALLOWED:
      self.config = {key: config[key] for key in self.CONFIG_KEYS_ALLOWED}
   else:
      self.config = config
...
class AFS(...):
  CONFIG_KEYS_ALLOWED = {'id', 'instance_type', 'ip_host', 'user', 'password', 'portmap'}
...

self.class_logger.info("Init ONS Switch Cross object.")
self.id = config['id']
self.type = config['instance_type']
self.name = config['name'] if "name" in config else "noname"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this self.name = config.get('name', 'noname')?

@esmacgil
Copy link

Review status: 0 of 7 files reviewed at latest revision, 15 unresolved discussions, some commit checks failed.


taf/testlib/dev_onsswcross.py, line 57 at r1 (raw file):

        self.connections = []
        # Do xconnect on create?
        self.autoconnect = config['autoconnect'] if "autoconnect" in config else True

Please change this, and related_conf below, to use config.get instead of the conditional operator.


taf/testlib/dev_ovscontroller.py, line 69 at r1 (raw file):

        self.port = config['json_ipport']
        self.cport = config['ip_port']
        self.id = config['id']

Duplicate of assignment in GenericEntry, please remove.


taf/testlib/dev_ovscontroller.py, line 70 at r1 (raw file):

        self.cport = config['ip_port']
        self.id = config['id']
        self.type = config['instance_type']

Duplicate of assignment in GenericEntry, please remove.


taf/testlib/dev_ovscontroller.py, line 606 at r1 (raw file):

        self.popen = None
        self.pid = None
        self.opts = opts

Do we need this? It looks like it was removed in other classes that inherit from OvsControllerGeneralMixin.


taf/testlib/dev_ovscontroller.py, line 750 at r1 (raw file):

        self.popen = None
        self.pid = None
        self.opts = opts

Do we need this? It looks like it was removed in other classes that inherit from OvsControllerGeneralMixin.


taf/testlib/dev_ovscontroller.py, line 880 at r1 (raw file):

        self.popen = None
        self.pid = None
        self.opts = opts

Do we need this? It looks like it was removed in other classes that inherit from OvsControllerGeneralMixin.


taf/testlib/dev_staticcross_ons.py, line 43 at r1 (raw file):

        """
        super().__init__(config, opts)
        self.autoconnect = config['autoconnect'] if "autoconnect" in config else True

Please make this self.autoconnect = config.get('autoconnect', True)


taf/testlib/dev_staticcross_ons.py, line 48 at r1 (raw file):

        self.related_conf = {}
        if "related_conf" in list(config.keys()):
            self.related_conf = config['related_conf']

Can we make this self.related_conf = config.get('related_conf', {})


taf/testlib/dev_vethcross.py, line 52 at r1 (raw file):

        self.connections = []
        # Do xconnect on create?
        self.autoconnect = config['autoconnect'] if "autoconnect" in config else True

Please make this self.autoconnect = config.get('autoconnect', True)


taf/testlib/dev_vethcross.py, line 56 at r1 (raw file):

        self.related_conf = {}
        if "related_conf" in list(config.keys()):
            self.related_conf = config['related_conf']

Can we make this self.related_conf = config.get('related_conf', {})


taf/testlib/dev_vlabcross.py, line 55 at r1 (raw file):

        super().__init__(config, opts)
        self.ipaddr = config['ip_host']
        self.port = config['ip_port'] if "ip_port" in config else "8050"

Please make this `self.port = config.get('ip_port', '8050')


taf/testlib/dev_vlabcross.py, line 58 at r1 (raw file):

        self.ifaces = config['ports']
        # Do xconnect on create?
        self.autoconnect = config['autoconnect'] if "autoconnect" in config else True

Please make this self.autoconnect = config.get('autoconnect', True)


taf/testlib/dev_vlabcross.py, line 62 at r1 (raw file):

        self.related_conf = {}
        if "related_conf" in list(config.keys()):
            self.related_conf = config['related_conf']

Can we make this self.related_conf = config.get('related_conf', {})

And similar for the others?


Comments from Reviewable

@esmacgil
Copy link

Reviewed 6 of 7 files at r1.
Review status: 6 of 7 files reviewed at latest revision, 15 unresolved discussions, some commit checks failed.


Comments from Reviewable

@esmacgil
Copy link

Reviewed 1 of 7 files at r1.
Review status: all files reviewed at latest revision, 15 unresolved discussions, some commit checks failed.


Comments from Reviewable

@rbbratta
Copy link
Member

Review scrub: please address comments

1 similar comment
@rbbratta
Copy link
Member

rbbratta commented Apr 6, 2017

Review scrub: please address comments

@NazarTkachuk
Copy link

TAF doctring style is changed.
Detailed information you can find by link
http://taf-docs.readthedocs.io/en/latest/development_guide.html#docstring

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants