Skip to content

Commit 900a273

Browse files
committed
Refactor
1 parent 2868ab1 commit 900a273

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

bpython/importcompletion.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,23 +206,22 @@ def find_modules(self, path: Path) -> Generator[Optional[str], None, None]:
206206
# Workaround for issue #166
207207
continue
208208
try:
209-
is_package = False
209+
package_pathname = None
210210
with warnings.catch_warnings():
211211
warnings.simplefilter("ignore", ImportWarning)
212212
spec = finder.find_spec(name)
213213
if spec is None:
214214
continue
215215
if spec.submodule_search_locations is not None:
216-
pathname = spec.submodule_search_locations[0]
217-
is_package = True
216+
package_pathname = spec.submodule_search_locations[0]
218217
except (ImportError, OSError, SyntaxError):
219218
continue
220219
except UnicodeEncodeError:
221220
# Happens with Python 3 when there is a filename in some invalid encoding
222221
continue
223222
else:
224-
if is_package:
225-
path_real = Path(pathname).resolve()
223+
if package_pathname is not None:
224+
path_real = Path(package_pathname).resolve()
226225
try:
227226
stat = path_real.stat()
228227
except OSError:

0 commit comments

Comments
 (0)