Skip to content

Commit 3896f4f

Browse files
committed
fix(pylint): make message id completion work with < 2.4.0
`--list-msgs-enabled` was introduced in 2.4.0. Fall back to `--list-msgs` if it fails, no matter if enabled or disabled message ids were requested.
1 parent e25da7e commit 3896f4f

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

completions/pylint

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,18 @@ _comp_cmd_pylint_message_ids()
55
local filter=p
66
[[ ${2-} ]] && filter="/^$2 messages/,/^$/p"
77
# 6: arbitrary, assumed no ids shorter than that
8-
_comp_delimited , -W "$(
8+
# TODO(scop): The fallback here is slow, maybe memoize whether
9+
# --list-msgs-enabled worked (>= 2.4.0) and avoid unnecessary tries
10+
# again later?
11+
local msgs="$(
12+
set -o pipefail
913
${1:-pylint} --list-msgs-enabled 2>/dev/null |
1014
command sed -ne "$filter" |
11-
command sed -ne 's/^[[:space:]]\{1,\}\([a-z-]\{6,\}\).*/\1/p'
15+
command sed -ne 's/^[[:space:]]\{1,\}\([a-z-]\{6,\}\).*/\1/p' ||
16+
${1:-pylint} --list-msgs 2>/dev/null |
17+
command sed -ne 's/^:\([a-z-]\{6,\}\).*/\1/p'
1218
)"
19+
_comp_delimited , -W "$msgs"
1320
}
1421

1522
_pylint()

0 commit comments

Comments
 (0)