Skip to content

chore: add lint script to match linter.yaml from CI#809

Merged
ishymko merged 2 commits into1.0-devfrom
ishymko/local-pyright
Mar 11, 2026
Merged

chore: add lint script to match linter.yaml from CI#809
ishymko merged 2 commits into1.0-devfrom
ishymko/local-pyright

Conversation

@ishymko
Copy link
Copy Markdown
Member

@ishymko ishymko commented Mar 11, 2026

  1. The script invokes Python linters from the CI, JSCPD is not invoked.
  2. GitHub action is updated to run pyright using local env to match versions and make results reproduciable.
image

1. The script invokes Python linters from the CI, JSCPD is not invoked.
2. GitHub action is updated to run pyright using local env to match versions and make results reproduciable.
@ishymko ishymko requested a review from a team as a code owner March 11, 2026 10:57
@ishymko ishymko merged commit b1339c8 into 1.0-dev Mar 11, 2026
10 checks passed
@ishymko ishymko deleted the ishymko/local-pyright branch March 11, 2026 11:18
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request aims to standardize the development workflow by introducing a local linting script that mirrors the CI's Python linting and formatting checks. By integrating pyright and automating these checks, it ensures that code quality and type consistency are maintained from the developer's machine, reducing discrepancies and improving overall code health before changes reach continuous integration.

Highlights

  • New Local Linting Script: A new shell script, scripts/lint.sh, has been introduced to provide a local replica of the CI's Python linting workflow. This script automates running Ruff (for linting and formatting), MyPy, and Pyright, ensuring local development aligns with CI checks.
  • Pyright Integration: The pyright type checker has been added as a development dependency in pyproject.toml and its corresponding entry included in uv.lock, enabling its use within the new local linting script.
  • Dependency Management Updates: The uv.lock file has been updated to reflect the new pyright dependency and includes minor reordering of optional dependencies, ensuring consistent and reproducible dependency resolution.
Changelog
  • pyproject.toml
    • Added 'pyright' to the development dependencies.
  • scripts/lint.sh
    • Added a new executable shell script to run Ruff (lint and format), MyPy, and Pyright locally.
  • uv.lock
    • Updated the lock file revision.
    • Reordered the 'db-cli' optional dependency entry.
    • Added the package definition for 'pyright' and its sub-dependencies.
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/linter.yaml
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a linting script to replicate CI checks locally and adds pyright as a development dependency. The changes are well-aligned with the goal of improving the local development workflow and ensuring code quality. I've suggested a small refactoring in the new lint.sh script to improve its maintainability by reducing code repetition. The dependency updates in pyproject.toml and uv.lock are correct.

Comment thread scripts/lint.sh
Comment on lines +1 to +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
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants