X Tutup
Skip to content

Commit 39e75dc

Browse files
committed
Make config non-optional
1 parent 163b64f commit 39e75dc

File tree

4 files changed

+14
-20
lines changed

4 files changed

+14
-20
lines changed

bpython/curtsies.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ def __init__(self, config, locals_, banner, interp=None):
5353
pass # temp hack to get .original_stty
5454

5555
super().__init__(
56+
config,
5657
locals_=locals_,
57-
config=config,
5858
banner=banner,
5959
interp=interp,
6060
orig_tcattrs=self.input_generator.original_stty,

bpython/curtsiesfrontend/repl.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,7 @@
2727
import bpython
2828
from bpython.repl import Repl as BpythonRepl, SourceNotFound
2929
from bpython.repl import LineTypeTranslator as LineType
30-
from bpython.config import (
31-
Struct,
32-
loadini,
33-
default_config_path,
34-
getpreferredencoding,
35-
)
30+
from bpython.config import getpreferredencoding, default_config_path
3631
from bpython.formatter import BPythonFormatter
3732
from bpython import autocomplete
3833
from bpython.translations import _
@@ -310,8 +305,8 @@ class BaseRepl(BpythonRepl):
310305

311306
def __init__(
312307
self,
308+
config,
313309
locals_=None,
314-
config=None,
315310
banner=None,
316311
interp=None,
317312
orig_tcattrs=None,
@@ -326,10 +321,6 @@ def __init__(
326321

327322
logger.debug("starting init")
328323

329-
if config is None:
330-
config = Struct()
331-
loadini(config, default_config_path())
332-
333324
# If creating a new interpreter on undo would be unsafe because initial
334325
# state was passed in
335326
self.weak_rewind = bool(locals_ or interp)

bpython/test/test_curtsies_repl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ def captured_output():
233233

234234
def create_repl(**kwargs):
235235
config = setup_config({"editor": "true"})
236-
repl = curtsiesrepl.BaseRepl(config=config, **kwargs)
236+
repl = curtsiesrepl.BaseRepl(config, **kwargs)
237237
os.environ["PAGER"] = "true"
238238
os.environ.pop("PYTHONSTARTUP", None)
239239
repl.width = 50

doc/sphinx/source/simplerepl.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@
2727
import time
2828
import logging
2929

30-
from . import translations
31-
from .curtsiesfrontend import events as bpythonevents
32-
from .curtsiesfrontend.repl import BaseRepl
33-
from .importcompletion import ModuleGatherer
30+
from bpython import translations
31+
from bpython.config import Struct, loadini, default_config_path
32+
from bpython.curtsiesfrontend import events as bpythonevents
33+
from bpython.curtsiesfrontend.repl import BaseRepl
34+
from bpython.importcompletion import ModuleGatherer
3435

3536
from curtsies.configfile_keynames import keymap as key_dispatch
3637

@@ -39,9 +40,9 @@
3940

4041

4142
class SimpleRepl(BaseRepl):
42-
def __init__(self):
43+
def __init__(self, config):
4344
self.requested_events = []
44-
BaseRepl.__init__(self)
45+
BaseRepl.__init__(self, config)
4546

4647
def _request_refresh(self):
4748
self.requested_events.append(bpythonevents.RefreshRequestEvent())
@@ -116,10 +117,12 @@ def get_input(self):
116117

117118
def main(args=None, locals_=None, banner=None):
118119
translations.init()
120+
config = Struct()
121+
loadini(config, default_config_path())
119122
module_gatherer = ModuleGatherer()
120123
while module_gatherer.find_coroutine():
121124
pass
122-
with SimpleRepl() as r:
125+
with SimpleRepl(config) as r:
123126
r.width = 50
124127
r.height = 10
125128
while True:

0 commit comments

Comments
 (0)
X Tutup