refactor(provider): use list comprehension #19027

- list(filter(lambda x: x != "", sys.path))
+ [p for p in sys.path if p != ""]
This commit is contained in:
Zaz Brown 2022-06-20 06:17:00 -07:00 committed by GitHub
parent e3bfc1293e
commit 99ef06d846
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -203,7 +203,7 @@ function! s:version_info(python) abort
let nvim_path = s:trim(s:system([
\ a:python, '-c',
\ 'import sys; ' .
\ 'sys.path = list(filter(lambda x: x != "", sys.path)); ' .
\ 'sys.path = [p for p in sys.path if p != ""]; ' .
\ 'import neovim; print(neovim.__file__)']))
if s:shell_error || empty(nvim_path)
return [python_version, 'unable to load neovim Python module', pypi_version,

View File

@ -8,7 +8,7 @@ let s:loaded_pythonx_provider = 1
function! provider#pythonx#Require(host) abort
" Python host arguments
let prog = provider#python3#Prog()
let args = [prog, '-c', 'import sys; sys.path = list(filter(lambda x: x != "", sys.path)); import neovim; neovim.start_host()']
let args = [prog, '-c', 'import sys; sys.path = [p for p in sys.path if p != ""]; import neovim; neovim.start_host()']
" Collect registered Python plugins into args
@ -63,7 +63,7 @@ endfunction
function! s:import_module(prog, module) abort
let prog_version = system([a:prog, '-c' , printf(
\ 'import sys; ' .
\ 'sys.path = list(filter(lambda x: x != "", sys.path)); ' .
\ 'sys.path = [p for p in sys.path if p != ""]; ' .
\ 'sys.stdout.write(str(sys.version_info[0]) + "." + str(sys.version_info[1])); ' .
\ 'import pkgutil; ' .
\ 'exit(2*int(pkgutil.get_loader("%s") is None))',