Skip to content

Commit

Permalink
Merge pull request #10 from clebergnu/python_tools_use_module_entrypoint
Browse files Browse the repository at this point in the history
Tool name and command standardization
  • Loading branch information
richtja authored Sep 11, 2024
2 parents ddbac9c + e245ca8 commit 2f53ec2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 39 deletions.
9 changes: 4 additions & 5 deletions check-import-order
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/bin/sh -e

TOOL_CMD=isort
PATH=$(basename $0)/utils:$PATH
TOOL_PATH=$(which $TOOL_CMD)
TOOL_NAME=isort
TOOL_CMD="python3 -m $TOOL_NAME"

echo "** Running $TOOL_CMD ($TOOL_PATH)..."
$TOOL_PATH --check-only --profile black .
echo "** Running $TOOL_NAME..."
$TOOL_CMD --check-only --profile black .
15 changes: 8 additions & 7 deletions check-lint
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/sh -e

TOOL_CMD=pylint
TOOL_NAME=pylint
TOOL_CMD="python3 -m $TOOL_NAME"
BASE_DIR=$(dirname "$0")
CONFIG_FILE="$BASE_DIR/../avocado-static-checks.conf"

Expand Down Expand Up @@ -70,8 +71,8 @@ if [ -f "$CONFIG_FILE" ]; then
FILES=$(git ls-files "$DIRECTORY_PATH/" | grep -e '.py$')

if [ -n "$FILES" ]; then
echo "** Running $TOOL_CMD on directory '$DIRECTORY_PATH' with config from '$CONFIG_PATH'..."
python3 -m pylint --rcfile="$BASE_DIR/../$CONFIG_PATH" $FILES
echo "** Running $TOOL_NAME on directory '$DIRECTORY_PATH' with config from '$CONFIG_PATH'..."
$TOOL_CMD --rcfile="$BASE_DIR/../$CONFIG_PATH" $FILES

# Add the files to the custom config list
for file in $FILES; do
Expand All @@ -82,8 +83,8 @@ if [ -f "$CONFIG_FILE" ]; then
done < "$CONFIG_FILE"
else
# If the configuration file does not exist, print a message and use default config for all files
echo "Configuration file '$CONFIG_FILE' not found. Running $TOOL_CMD with default config on all files..."
python3 -m pylint --rcfile="$DEFAULT_CONFIG_PATH" $ALL_FILES
echo "Configuration file '$CONFIG_FILE' not found. Running $TOOL_NAME with default config on all files..."
$TOOL_CMD --rcfile="$DEFAULT_CONFIG_PATH" $ALL_FILES
exit 0
fi

Expand All @@ -97,6 +98,6 @@ for file in $ALL_FILES; do
done

if [ ${#remaining_files[@]} -gt 0 ]; then
echo "** Running $TOOL_CMD with default config on remaining files..."
python3 -m pylint --rcfile="$DEFAULT_CONFIG_PATH" "${remaining_files[@]}"
echo "** Running $TOOL_NAME with default config on remaining files..."
$TOOL_CMD --rcfile="$DEFAULT_CONFIG_PATH" "${remaining_files[@]}"
fi
9 changes: 4 additions & 5 deletions check-style
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/bin/sh -e

TOOL_CMD=black
PATH=$(basename $0)/utils:$PATH
TOOL_PATH=$(which $TOOL_CMD)
TOOL_NAME=black
TOOL_CMD="python3 -m black"

echo "** Running $TOOL_CMD ($TOOL_PATH)..."
$TOOL_PATH --check --diff --color .
echo "** Running $TOOL_NAME..."
$TOOL_CMD --check --diff --color .
22 changes: 0 additions & 22 deletions utils/which

This file was deleted.

0 comments on commit 2f53ec2

Please sign in to comment.