Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitec79bd8

Browse files
committed
Remove global state of bpython.importcompletion
Repls now have a ModuleGartherer instance that performs the job.
1 parent400d7e2 commitec79bd8

File tree

9 files changed

+225
-225
lines changed

9 files changed

+225
-225
lines changed

‎bpython/autocomplete.py‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# The MIT License
22
#
33
# Copyright (c) 2009-2015 the bpython authors.
4+
# Copyright (c) 2015-2020 Sebastian Ramacher
45
#
56
# Permission is hereby granted, free of charge, to any person obtaining a copy
67
# of this software and associated documentation files (the "Software"), to deal
@@ -34,7 +35,6 @@
3435

3536
fromenumimportEnum
3637
from .importinspection
37-
from .importimportcompletion
3838
from .importlineaslineparts
3939
from .lineimportLinePart
4040
from .lazyreimportLazyReCompile
@@ -285,8 +285,12 @@ def matches(self, cursor_offset, line, **kwargs):
285285

286286

287287
classImportCompletion(BaseCompletionType):
288+
def__init__(self,module_gatherer,mode=AutocompleteModes.SIMPLE):
289+
super().__init__(False,mode)
290+
self.module_gatherer=module_gatherer
291+
288292
defmatches(self,cursor_offset,line,**kwargs):
289-
returnimportcompletion.complete(cursor_offset,line)
293+
returnself.module_gatherer.complete(cursor_offset,line)
290294

291295
deflocate(self,current_offset,line):
292296
returnlineparts.current_word(current_offset,line)
@@ -656,10 +660,10 @@ def get_completer(completers, cursor_offset, line, **kwargs):
656660
return [],None
657661

658662

659-
defget_default_completer(mode=AutocompleteModes.SIMPLE):
663+
defget_default_completer(mode=AutocompleteModes.SIMPLE,module_gatherer=None):
660664
return (
661665
DictKeyCompletion(mode=mode),
662-
ImportCompletion(mode=mode),
666+
ImportCompletion(module_gatherer,mode=mode),
663667
FilenameCompletion(mode=mode),
664668
MagicMethodCompletion(mode=mode),
665669
MultilineJediCompletion(mode=mode),

‎bpython/cli.py‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,6 @@
6666
frompygments.tokenimportToken
6767
from .formatterimportBPythonFormatter
6868

69-
# This for completion
70-
from .importimportcompletion
71-
7269
# This for config
7370
from .configimportStruct,getpreferredencoding
7471

@@ -1784,7 +1781,7 @@ def idle(caller):
17841781
sure it happens conveniently."""
17851782
globalDO_RESIZE
17861783

1787-
ifimportcompletion.find_coroutine()orcaller.paste_mode:
1784+
ifcaller.module_gatherer.find_coroutine()orcaller.paste_mode:
17881785
caller.scr.nodelay(True)
17891786
key=caller.scr.getch()
17901787
caller.scr.nodelay(False)

‎bpython/curtsies.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from .importargsasbpargs
1414
from .importtranslations
1515
from .translationsimport_
16-
from .importcompletionimportfind_coroutine
1716
from .curtsiesfrontendimporteventsasbpythonevents
1817
from .importinspection
1918
from .replimportextract_exit_value
@@ -113,7 +112,7 @@ def mainloop(self, interactive=True, paste=None):
113112
# do a display before waiting for first event
114113
self.process_event_and_paint(None)
115114
inputs=combined_events(self.input_generator)
116-
whilefind_coroutine():
115+
whileself.module_gatherer.find_coroutine():
117116
e=inputs.send(0)
118117
ifeisnotNone:
119118
self.process_event_and_paint(e)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2026 Movatter.jp