fixes to config types, remove unneeded derived __init__ and call base __init__
This commit is contained in:
parent
2a705e2eb6
commit
6431542eba
@ -123,9 +123,8 @@ class BaseType:
|
||||
|
||||
special = False
|
||||
|
||||
def __init__(self, none_ok=False, valid_values=None):
|
||||
def __init__(self, none_ok=False):
|
||||
self.none_ok = none_ok
|
||||
self.valid_values = valid_values
|
||||
|
||||
def _basic_validation(self, value):
|
||||
"""Do some basic validation for the value (empty, non-printable chars).
|
||||
@ -244,7 +243,8 @@ class String(BaseType):
|
||||
|
||||
def __init__(self, minlen=None, maxlen=None, forbidden=None,
|
||||
none_ok=False, completions=None, valid_values=None):
|
||||
super().__init__(none_ok, valid_values)
|
||||
super().__init__(none_ok)
|
||||
self.valid_values = valid_values
|
||||
if minlen is not None and minlen < 1:
|
||||
raise ValueError("minlen ({}) needs to be >= 1!".format(minlen))
|
||||
elif maxlen is not None and maxlen < 1:
|
||||
@ -651,8 +651,7 @@ class ColorSystem(MappingType):
|
||||
|
||||
special = True
|
||||
|
||||
def __init__(self):
|
||||
self.valid_values = ValidValues(
|
||||
valid_values = ValidValues(
|
||||
('rgb', "Interpolate in the RGB color system."),
|
||||
('hsv', "Interpolate in the HSV color system."),
|
||||
('hsl', "Interpolate in the HSL color system."),
|
||||
@ -1095,9 +1094,7 @@ class Proxy(BaseType):
|
||||
"""A proxy URL or special value."""
|
||||
|
||||
special = True
|
||||
|
||||
def __init__(self):
|
||||
self.valid_values = ValidValues(
|
||||
valid_values = ValidValues(
|
||||
('system', "Use the system wide proxy."),
|
||||
('none', "Don't use any proxy"))
|
||||
|
||||
@ -1209,8 +1206,6 @@ class FuzzyUrl(BaseType):
|
||||
|
||||
PaddingValues = collections.namedtuple('PaddingValues', ['top', 'bottom',
|
||||
'left', 'right'])
|
||||
|
||||
|
||||
class Padding(IntList):
|
||||
|
||||
"""Setting for paddings around elements."""
|
||||
@ -1326,8 +1321,7 @@ class Position(MappingType):
|
||||
|
||||
"""The position of the tab bar."""
|
||||
|
||||
def __init__(self):
|
||||
self.valid_values = ValidValues('top', 'bottom', 'left', 'right')
|
||||
valid_values = ValidValues('top', 'bottom', 'left', 'right')
|
||||
|
||||
MAPPING = {
|
||||
'top': QTabWidget.North,
|
||||
@ -1341,8 +1335,7 @@ class VerticalPosition(BaseType):
|
||||
|
||||
"""The position of the download bar."""
|
||||
|
||||
def __init__(self):
|
||||
self.valid_values = ValidValues('top', 'bottom')
|
||||
valid_values = ValidValues('top', 'bottom')
|
||||
|
||||
|
||||
class UrlList(List):
|
||||
@ -1387,8 +1380,8 @@ class SelectOnRemove(MappingType):
|
||||
"""Which tab to select when the focused tab is removed."""
|
||||
|
||||
special = True
|
||||
def __init__(self):
|
||||
self.valid_values = ValidValues(
|
||||
|
||||
valid_values = ValidValues(
|
||||
('left', "Select the tab on the left."),
|
||||
('right', "Select the tab on the right."),
|
||||
('previous', "Select the previously selected tab."))
|
||||
@ -1406,8 +1399,7 @@ class ConfirmQuit(FlagList):
|
||||
|
||||
special = True
|
||||
|
||||
def __init__(self):
|
||||
self.valid_values = ValidValues(('always', "Always show a confirmation."),
|
||||
valid_values = ValidValues(('always', "Always show a confirmation."),
|
||||
('multiple-tabs', "Show a confirmation if "
|
||||
"multiple tabs are opened."),
|
||||
('downloads', "Show a confirmation if "
|
||||
@ -1438,8 +1430,7 @@ class NewTabPosition(BaseType):
|
||||
|
||||
special = True
|
||||
|
||||
def __init__(self):
|
||||
self.valid_values = ValidValues(
|
||||
valid_values = ValidValues(
|
||||
('left', "On the left of the current tab."),
|
||||
('right', "On the right of the current tab."),
|
||||
('first', "At the left end."),
|
||||
@ -1452,8 +1443,7 @@ class IgnoreCase(Bool):
|
||||
|
||||
special = True
|
||||
|
||||
def __init__(self):
|
||||
self.valid_values = ValidValues(
|
||||
valid_values = ValidValues(
|
||||
('true', "Search case-insensitively"),
|
||||
('false', "Search case-sensitively"),
|
||||
('smart', "Search case-sensitively if there "
|
||||
@ -1481,9 +1471,6 @@ class UserAgent(BaseType):
|
||||
|
||||
special = True
|
||||
|
||||
def __init__(self, none_ok=False):
|
||||
super().__init__(none_ok)
|
||||
|
||||
def validate(self, value):
|
||||
self._basic_validation(value)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user