FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Initialize attributes in base class · bpython/bpython@517ae80 · GitHub

Commit 517ae80

Browse files
committed
Initialize attributes in base class
1 parent c0a7837 commit 517ae80

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

‎bpython/curtsiesfrontend/manual_readline.py‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ class AbstractEdits:
2222
"cut_buffer": "there",
2323
}
2424

25+
def __init__(self, simple_edits=None, cut_buffer_edits=None):
26+
self.simple_edits = {} if simple_edits is None else simple_edits
27+
self.cut_buffer_edits = (
28+
{} if cut_buffer_edits is None else cut_buffer_edits
29+
)
30+
self.awaiting_config = {}
2531

2632
def add(self, key, func, overwrite=False):
2733
if key in self:
@@ -104,11 +110,6 @@ class UnconfiguredEdits(AbstractEdits):
104110
Keys can't be added twice, config attributes can't be added twice.
105111
"""
106112

107-
def __init__(self):
108-
self.simple_edits = {}
109-
self.cut_buffer_edits = {}
110-
self.awaiting_config = {}
111-
112113
def mapping_with_config(self, config, key_dispatch):
113114
"""Creates a new mapping object by applying a config object"""
114115
return ConfiguredEdits(
@@ -147,8 +148,7 @@ def __init__(
147148
config,
148149
key_dispatch,
149150
):
150-
self.simple_edits = dict(simple_edits)
151-
self.cut_buffer_edits = dict(cut_buffer_edits)
151+
super().__init__(dict(simple_edits), dict(cut_buffer_edits))
152152
for attr, func in awaiting_config.items():
153153
for key in key_dispatch[getattr(config, attr)]:
154154
super().add(key, func, overwrite=True)

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL