The way _Component uses kwargs is handy to save a few characters, but it
doesn't play well with static analysis. When editing gdbarch.py, my
editor (which uses pylance under the hood) knows nothing about the
properties of components. So it's full of squiggly lines, and typing
analysis (which I find really helpful) doesn't work. I therefore think
it would be better to spell out the parameters.
Change-Id: Iaf561beb0d0fbe170ce1c79252a291e0945e1830
Reviewed-By: Tom Tromey <tom@tromey.com>
Reviewed-By: Andrew Burgess <aburgess@redhat.com>
class _Component:
"Base class for all components."
- def __init__(self, **kwargs):
- for key in kwargs:
- setattr(self, key, kwargs[key])
+ def __init__(
+ self,
+ name,
+ type,
+ printer,
+ comment=None,
+ predicate=False,
+ predefault=None,
+ postdefault=None,
+ invalid=None,
+ params=None,
+ param_checks=None,
+ result_checks=None,
+ implement=True,
+ ):
+ self.name = name
+ self.type = type
+ self.printer = printer
+ self.comment = comment
+ self.predicate = predicate
+ self.predefault = predefault
+ self.postdefault = postdefault
+ self.invalid = invalid
+ self.params = params
+ self.param_checks = param_checks
+ self.result_checks = result_checks
+ self.implement = implement
+
components.append(self)
# It doesn't make sense to have a check of the result value
name,
type,
comment=None,
- predicate=None,
+ predicate=False,
predefault=None,
postdefault=None,
invalid=None,
type,
params,
comment=None,
- predicate=None,
+ predicate=False,
predefault=None,
postdefault=None,
invalid=None,