-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from docker/cm/pylint
Pylint
- Loading branch information
Showing
6 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
FROM python:alpine3.20 | ||
|
||
# Install pylint | ||
RUN pip install pylint | ||
|
||
# Install bash and jq | ||
RUN apk add --no-cache bash jq | ||
|
||
# Copy the lint script | ||
COPY lint.sh /lint.sh | ||
RUN chmod +x /lint.sh | ||
|
||
COPY output_format.sh /output_format.sh | ||
RUN chmod +x /output_format.sh | ||
|
||
ENTRYPOINT [ "/lint.sh" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
|
||
JSON_ARGS=$1 | ||
|
||
args=$(echo $JSON_ARGS | jq -r '.args') | ||
output_format=$(echo $JSON_ARGS | jq -r '.output_format') | ||
|
||
# If no args or args is "null" | ||
if [ -z "$args" ] || [ "$args" == "null" ]; then | ||
args="." | ||
fi | ||
|
||
# If no output_format or output_format is "null" | ||
if [ -z "$output_format" ] || [ "$output_format" == "null" ]; then | ||
output_format="summary" | ||
fi | ||
|
||
pylint --recursive=y --output-format=json $args | /output_format.sh "$output_format" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/bash | ||
|
||
INPUT=$(cat) | ||
FORMAT=$1 | ||
|
||
if [ "$FORMAT" == "json" ]; then | ||
echo "$INPUT" | ||
exit 0 | ||
fi | ||
|
||
MESSAGES=$(echo "$INPUT" | jq -r -c '.[]') | ||
|
||
if [ "$FORMAT" == "summary" ]; then | ||
|
||
TOTAL_MESSAGES=$(echo "$MESSAGES" | wc -l) | ||
|
||
TOTAL_AFFECTED_FILES=$(echo $INPUT | jq -r '.[].path' | sort | uniq | wc -l) | ||
echo "Ran pylint and found $TOTAL_MESSAGES messages across $TOTAL_AFFECTED_FILES files." | ||
exit | ||
fi | ||
|
||
for MESSAGE in $MESSAGES; do | ||
MESSAGE_TYPE=$(echo "$MESSAGE" | jq -r '.type') | ||
MESSAGE_LINE=$(echo "$MESSAGE" | jq -r '.line') | ||
MESSAGE_COLUMN=$(echo "$MESSAGE" | jq -r '.column') | ||
MESSAGE_PATH=$(echo "$MESSAGE" | jq -r '.path') | ||
MESSAGE_FILE=$(echo "$MESSAGE" | jq -r '.file') | ||
MESSAGE_SYMBOL=$(echo "$MESSAGE" | jq -r '.symbol') | ||
MESSAGE_MESSAGE=$(echo "$MESSAGE" | jq -r '.message') | ||
# If condensed | ||
if [ "$FORMAT" == "condensed" ]; then | ||
echo "$MESSAGE_TYPE: $MESSAGE_CODE" | ||
continue | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
You are an assistant who specializes in running pylint. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
Lint python files in my project using 'condensed' . | ||
|
||
Report the response. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
functions: | ||
- name: pylint | ||
description: Runs pylint against current project | ||
parameters: | ||
type: object | ||
properties: | ||
output_format: | ||
type: string | ||
description: The output level to use. `summary` | `json` | `condensed` | `complaints` | ||
container: | ||
image: vonwig/pylint:latest | ||
--- |