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

Commitf2744fc

Browse files
Yield from import module discovery
Avoid interruptions by yielding more frequently.This prevent unresponsiveness while working throughportions of directory trees without any Python modules.
1 parenta9db837 commitf2744fc

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

‎bpython/importcompletion.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,9 @@ def complete(self, cursor_offset: int, line: str) -> Optional[Set[str]]:
155155
else:
156156
returnNone
157157

158-
deffind_modules(self,path:Path)->Generator[str,None,None]:
158+
deffind_modules(
159+
self,path:Path
160+
)->Generator[Union[str,None],None,None]:
159161
"""Find all modules (and packages) for a given directory."""
160162
ifnotpath.is_dir():
161163
# Perhaps a zip file
@@ -219,9 +221,12 @@ def find_modules(self, path: Path) -> Generator[str, None, None]:
219221
if (stat.st_dev,stat.st_ino)notinself.paths:
220222
self.paths.add((stat.st_dev,stat.st_ino))
221223
forsubnameinself.find_modules(path_real):
222-
ifsubname!="__init__":
224+
ifsubnameisNone:
225+
yieldNone# take a break to avoid unresponsiveness
226+
elifsubname!="__init__":
223227
yieldf"{name}.{subname}"
224228
yieldname
229+
yieldNone# take a break to avoid unresponsiveness
225230

226231
deffind_all_modules(
227232
self,paths:Iterable[Path]
@@ -231,7 +236,8 @@ def find_all_modules(
231236

232237
forpinpaths:
233238
formoduleinself.find_modules(p):
234-
self.modules.add(module)
239+
ifmoduleisnotNone:
240+
self.modules.add(module)
235241
yield
236242

237243
deffind_coroutine(self)->Optional[bool]:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp