File tree Expand file tree Collapse file tree 6 files changed +87
-0
lines changed Expand file tree Collapse file tree 6 files changed +87
-0
lines changed Original file line number Diff line number Diff line change
1
+ FROM python:alpine3.20
2
+
3
+ # Install pylint
4
+ RUN pip install pylint
5
+
6
+ # Install bash and jq
7
+ RUN apk add --no-cache bash jq
8
+
9
+ # Copy the lint script
10
+ COPY lint.sh /lint.sh
11
+ RUN chmod +x /lint.sh
12
+
13
+ COPY output_format.sh /output_format.sh
14
+ RUN chmod +x /output_format.sh
15
+
16
+ ENTRYPOINT [ "/lint.sh" ]
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ JSON_ARGS=$1
4
+
5
+ args=$( echo $JSON_ARGS | jq -r ' .args' )
6
+ output_format=$( echo $JSON_ARGS | jq -r ' .output_format' )
7
+
8
+ # If no args or args is "null"
9
+ if [ -z " $args " ] || [ " $args " == " null" ]; then
10
+ args=" ."
11
+ fi
12
+
13
+ # If no output_format or output_format is "null"
14
+ if [ -z " $output_format " ] || [ " $output_format " == " null" ]; then
15
+ output_format=" summary"
16
+ fi
17
+
18
+ pylint --recursive=y --output-format=json $args | /output_format.sh " $output_format "
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ INPUT=$( cat)
4
+ FORMAT=$1
5
+
6
+ if [ " $FORMAT " == " json" ]; then
7
+ echo " $INPUT "
8
+ exit 0
9
+ fi
10
+
11
+ MESSAGES=$( echo " $INPUT " | jq -r -c ' .[]' )
12
+
13
+ if [ " $FORMAT " == " summary" ]; then
14
+
15
+ TOTAL_MESSAGES=$( echo " $MESSAGES " | wc -l)
16
+
17
+ TOTAL_AFFECTED_FILES=$( echo $INPUT | jq -r ' .[].path' | sort | uniq | wc -l)
18
+ echo " Ran pylint and found $TOTAL_MESSAGES messages across $TOTAL_AFFECTED_FILES files."
19
+ exit
20
+ fi
21
+
22
+ for MESSAGE in $MESSAGES ; do
23
+ MESSAGE_TYPE=$( echo " $MESSAGE " | jq -r ' .type' )
24
+ MESSAGE_LINE=$( echo " $MESSAGE " | jq -r ' .line' )
25
+ MESSAGE_COLUMN=$( echo " $MESSAGE " | jq -r ' .column' )
26
+ MESSAGE_PATH=$( echo " $MESSAGE " | jq -r ' .path' )
27
+ MESSAGE_FILE=$( echo " $MESSAGE " | jq -r ' .file' )
28
+ MESSAGE_SYMBOL=$( echo " $MESSAGE " | jq -r ' .symbol' )
29
+ MESSAGE_MESSAGE=$( echo " $MESSAGE " | jq -r ' .message' )
30
+ # If condensed
31
+ if [ " $FORMAT " == " condensed" ]; then
32
+ echo " $MESSAGE_TYPE : $MESSAGE_CODE "
33
+ continue
34
+ fi
35
+ done
Original file line number Diff line number Diff line change
1
+ You are an assistant who specializes in running pylint.
Original file line number Diff line number Diff line change
1
+
2
+ Lint python files in my project using 'condensed' .
3
+
4
+ Report the response.
Original file line number Diff line number Diff line change
1
+ ---
2
+ functions :
3
+ - name : pylint
4
+ description : Runs pylint against current project
5
+ parameters :
6
+ type : object
7
+ properties :
8
+ output_format :
9
+ type : string
10
+ description : The output level to use. `summary` | `json` | `condensed` | `complaints`
11
+ container :
12
+ image : vonwig/pylint:latest
13
+ ---
You can’t perform that action at this time.
0 commit comments