summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngelos Evripiotis <jevripiotis@bloomberg.net>2019-06-11 15:45:58 +0100
committerbst-marge-bot <marge-bot@buildstream.build>2019-06-18 09:45:00 +0000
commit013d88c94f023cfa1e28872489808a80a435fd7d (patch)
treef2c6f91281f92762cf307d9c98eba0c6ae1bc816
parent5ae6ee9534e9f301b9db1b256883bb14b63efb73 (diff)
downloadbuildstream-013d88c94f023cfa1e28872489808a80a435fd7d.tar.gz
_options: match methods to base class
Update OptionEnum and OptionFlags to match the Option base-class. Introduce 'load_special' to allow explicit usage of extended functionality, which wouldn't necessarily be supported by different subclasses. By making the signatures of overridden methods deliberately match, we can use PyLint to ensure the signatures don't accidentally differ. Also replace `super(cls, self)` with the equivalent and less error-prone `super()`, wherever we've touched it. In separate work we may want to replace this across the project. We must introduce __init__() functions for OptionEnum and OptionFlags to get a clean pass from PyLint. It seems that it's unable to see that load_special() is also transitively called from __init__().
-rw-r--r--src/buildstream/_options/optionarch.py2
-rw-r--r--src/buildstream/_options/optioneltmask.py2
-rw-r--r--src/buildstream/_options/optionenum.py9
-rw-r--r--src/buildstream/_options/optionflags.py9
-rw-r--r--src/buildstream/_options/optionos.py2
5 files changed, 19 insertions, 5 deletions
diff --git a/src/buildstream/_options/optionarch.py b/src/buildstream/_options/optionarch.py
index 3117b8273..e7735eaa2 100644
--- a/src/buildstream/_options/optionarch.py
+++ b/src/buildstream/_options/optionarch.py
@@ -40,7 +40,7 @@ class OptionArch(OptionEnum):
OPTION_TYPE = 'arch'
def load(self, node):
- super().load(node, allow_default_definition=False)
+ super().load_special(node, allow_default_definition=False)
def load_default_value(self, node):
arch = Platform.get_host_arch()
diff --git a/src/buildstream/_options/optioneltmask.py b/src/buildstream/_options/optioneltmask.py
index 507dc7070..178999fa1 100644
--- a/src/buildstream/_options/optioneltmask.py
+++ b/src/buildstream/_options/optioneltmask.py
@@ -33,7 +33,7 @@ class OptionEltMask(OptionFlags):
def load(self, node):
# Ask the parent constructor to disallow value definitions,
# we define those automatically only.
- super().load(node, allow_value_definitions=False)
+ super().load_special(node, allow_value_definitions=False)
# Here we want all valid elements as possible values,
# but we'll settle for just the relative filenames
diff --git a/src/buildstream/_options/optionenum.py b/src/buildstream/_options/optionenum.py
index f214d779d..889db965c 100644
--- a/src/buildstream/_options/optionenum.py
+++ b/src/buildstream/_options/optionenum.py
@@ -30,7 +30,14 @@ class OptionEnum(Option):
OPTION_TYPE = 'enum'
- def load(self, node, allow_default_definition=True):
+ def __init__(self, name, definition, pool):
+ self.values = None
+ super().__init__(name, definition, pool)
+
+ def load(self, node):
+ self.load_special(node)
+
+ def load_special(self, node, allow_default_definition=True):
super().load(node)
valid_symbols = OPTION_SYMBOLS + ['values']
diff --git a/src/buildstream/_options/optionflags.py b/src/buildstream/_options/optionflags.py
index ba16244ba..eba3a8dd5 100644
--- a/src/buildstream/_options/optionflags.py
+++ b/src/buildstream/_options/optionflags.py
@@ -30,7 +30,14 @@ class OptionFlags(Option):
OPTION_TYPE = 'flags'
- def load(self, node, allow_value_definitions=True):
+ def __init__(self, name, definition, pool):
+ self.values = None
+ super().__init__(name, definition, pool)
+
+ def load(self, node):
+ self.load_special(node)
+
+ def load_special(self, node, allow_value_definitions=True):
super().load(node)
valid_symbols = OPTION_SYMBOLS + ['default']
diff --git a/src/buildstream/_options/optionos.py b/src/buildstream/_options/optionos.py
index 6263a05a2..fcf4552f5 100644
--- a/src/buildstream/_options/optionos.py
+++ b/src/buildstream/_options/optionos.py
@@ -29,7 +29,7 @@ class OptionOS(OptionEnum):
OPTION_TYPE = 'os'
def load(self, node):
- super().load(node, allow_default_definition=False)
+ super().load_special(node, allow_default_definition=False)
def load_default_value(self, node):
return platform.uname().system