Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/linter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ jobs:
- name: Run Pyright (Pylance equivalent)
id: pyright
continue-on-error: true
uses: jakebailey/pyright-action@v2
with:
pylance-version: latest-release
run: uv run pyright src

- name: Run JSCPD for copy-paste detection
id: jscpd
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ dev = [
"trio",
"uvicorn>=0.35.0",
"pytest-timeout>=2.4.0",
"pyright",
"a2a-sdk[all]",
]

Expand Down
60 changes: 60 additions & 0 deletions scripts/lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash
# Local replica of .github/workflows/linter.yaml (excluding jscpd copy-paste check)

# ANSI color codes for premium output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
BOLD='\033[1m'
NC='\033[0m' # No Color

FAILED=0

echo -e "${BLUE}${BOLD}=== A2A Python Fixed-and-Lint Suite ===${NC}"
echo -e "Fixing formatting and linting issues, then verifying types...\n"

# 1. Ruff Linter (with fix)
echo -e "${YELLOW}${BOLD}--- [1/4] Running Ruff Linter (fix) ---${NC}"
if uv run ruff check --fix; then
echo -e "${GREEN}✓ Ruff Linter passed (and fixed what it could)${NC}"
else
echo -e "${RED}✗ Ruff Linter failed${NC}"
FAILED=1
fi

# 2. Ruff Formatter
echo -e "\n${YELLOW}${BOLD}--- [2/4] Running Ruff Formatter (apply) ---${NC}"
if uv run ruff format; then
echo -e "${GREEN}✓ Ruff Formatter applied${NC}"
else
echo -e "${RED}✗ Ruff Formatter failed${NC}"
FAILED=1
fi

# 3. MyPy Type Checker
echo -e "\n${YELLOW}${BOLD}--- [3/4] Running MyPy Type Checker ---${NC}"
if uv run mypy src; then
echo -e "${GREEN}✓ MyPy passed${NC}"
else
echo -e "${RED}✗ MyPy failed${NC}"
FAILED=1
fi

# 4. Pyright Type Checker
echo -e "\n${YELLOW}${BOLD}--- [4/4] Running Pyright ---${NC}"
if uv run pyright; then
echo -e "${GREEN}✓ Pyright passed${NC}"
else
echo -e "${RED}✗ Pyright failed${NC}"
FAILED=1
fi

echo -e "\n${BLUE}${BOLD}=========================================${NC}"
if [ $FAILED -eq 0 ]; then
echo -e "${GREEN}${BOLD}SUCCESS: All linting and formatting tasks complete!${NC}"
exit 0
else
echo -e "${RED}${BOLD}FAILURE: One or more steps failed.${NC}"
exit 1
fi
Comment on lines +1 to +60
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

low

This script is well-structured and achieves its goal. To improve maintainability and reduce code duplication, you could refactor the repeated logic for running each check into a helper function. This would make it easier to add or modify checks in the future.

#!/bin/bash
# Local replica of .github/workflows/linter.yaml (excluding jscpd copy-paste check)

# ANSI color codes for premium output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
BOLD='\033[1m'
NC='\033[0m' # No Color

FAILED=0
STEP=1
TOTAL_STEPS=4

# Helper function to run a check and report its status.
# Usage: run_check "Description" "Success Message" "Failure Message" command_to_run...
run_check() {
    local description="$1"
    local success_msg="$2"
    local failure_msg="$3"
    shift 3

    # Add a newline before each step except the first one.
    if [ "$STEP" -gt 1 ]; then
        echo
    fi

    echo -e "${YELLOW}${BOLD}--- [${STEP}/${TOTAL_STEPS}] $description ---${NC}"
    if "$@"; then
        echo -e "${GREEN}$success_msg${NC}"
    else
        echo -e "${RED}$failure_msg${NC}"
        FAILED=1
    fi
    ((STEP++))
}

echo -e "${BLUE}${BOLD}=== A2A Python Fixed-and-Lint Suite ===${NC}"
echo -e "Fixing formatting and linting issues, then verifying types...\n"

run_check "Running Ruff Linter (fix)" "Ruff Linter passed (and fixed what it could)" "Ruff Linter failed" uv run ruff check --fix
run_check "Running Ruff Formatter (apply)" "Ruff Formatter applied" "Ruff Formatter failed" uv run ruff format
run_check "Running MyPy Type Checker" "MyPy passed" "MyPy failed" uv run mypy src
run_check "Running Pyright" "Pyright passed" "Pyright failed" uv run pyright

echo -e "\n${BLUE}${BOLD}=========================================${NC}"
if [ $FAILED -eq 0 ]; then
    echo -e "${GREEN}${BOLD}SUCCESS: All linting and formatting tasks complete!${NC}"
    exit 0
else
    echo -e "${RED}${BOLD}FAILURE: One or more steps failed.${NC}"
    exit 1
fi

27 changes: 21 additions & 6 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading