Replace for/if/append pattern with list comprehension in autocompletion.py

This commit is contained in:
Jon Dufresne 2021-02-20 07:20:08 -08:00
parent 8a949a1c52
commit bfc4e9c331
2 changed files with 5 additions and 4 deletions

View File

@ -47,11 +47,12 @@ def autocomplete():
not current.startswith('-')
)
if should_list_installed:
installed = []
lc = current.lower()
for dist in get_installed_distributions(local_only=True):
if dist.key.startswith(lc) and dist.key not in cwords[1:]:
installed.append(dist.key)
installed = [
dist.key
for dist in get_installed_distributions(local_only=True)
if dist.key.startswith(lc) and dist.key not in cwords[1:]
]
# if there are no dists installed, fall back to option completion
if installed:
for dist in installed: