From d040710d75082ee353187bd9987f017cd93c16bf Mon Sep 17 00:00:00 2001 From: Jennifer Davis Date: Tue, 2 Jun 2026 22:08:09 -0700 Subject: [PATCH 01/19] feat: create a lint action --- .github/workflows/lint.yml | 42 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000000..8a9ca77de55 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,42 @@ +name: Lint + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +permissions: + contents: read + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 + with: + fetch-depth: 0 + + - name: Setup Python + uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 + with: + python-version: '3.10' + + - name: Install nox + run: | + python -m pip install --upgrade pip + python -m pip install nox + + - name: Prepare noxfile + run: cp noxfile-template.py noxfile.py + + - name: Make script executable + run: chmod +x .github/scripts/lint-changed.sh + + - name: Run lint script for changed files + run: | + .github/scripts/lint-changed.sh \ + "${{ github.event_name }}" \ + "${{ github.base_ref || github.ref_name }}" \ + "${{ github.event.before }}" From e0ba63095b53df5bc9a5b8907eadff3f0790cab2 Mon Sep 17 00:00:00 2001 From: Jennifer Davis Date: Tue, 2 Jun 2026 22:09:47 -0700 Subject: [PATCH 02/19] feat: add lint-changed.sh shell script --- .github/scripts/lint-changed.sh | 47 +++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/scripts/lint-changed.sh diff --git a/.github/scripts/lint-changed.sh b/.github/scripts/lint-changed.sh new file mode 100644 index 00000000000..1b0a6bcec8a --- /dev/null +++ b/.github/scripts/lint-changed.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash + +# Exit immediately if a command fails, or if an unset variable is used +set -euo pipefail + +EVENT_NAME="${1:-local}" +BASE_REF="${2:-main}" +BEFORE_SHA="${3:-}" + +echo "Configuring target diff for event: $EVENT_NAME" + +# Determine the base branch/commit to diff against +if [ "$EVENT_NAME" = "pull_request" ]; then + # Ensure we have the target branch metadata fetched. + # Note: If this fails due to shallow clone issues, the script will exit safely via set -e + git fetch origin "$BASE_REF" --depth=1 --quiet + BASE_SHA="origin/$BASE_REF" +else + BASE_SHA="$BEFORE_SHA" + # Fallback if it's a direct push without a prior SHA, or a local run + if [ "$BASE_SHA" = "0000000000000000000000000000000000000000" ] || [ -z "$BASE_SHA" ]; then + BASE_SHA="HEAD~1" + fi +fi + +# Extract changed Python files into a Bash array +mapfile -t CHANGED_FILES < <(git diff --name-only --diff-filter=d "$BASE_SHA" -- '*.py' 2>/dev/null || true) + +# Execute linters if files exist +if [ ${#CHANGED_FILES[@]} -gt 0 ]; then + echo "Files to lint:" + printf ' - %s\n' "${CHANGED_FILES[@]}" + + # Track execution success manually so both tools get a chance to run + BLACK_EXIT=0 + LINT_EXIT=0 + + # Pass the array safely using "${CHANGED_FILES[@]}" + nox -s blacken -- "${CHANGED_FILES[@]}" || BLACK_EXIT=$? + nox -s lint -- "${CHANGED_FILES[@]}" || LINT_EXIT=$? + + if [ $BLACK_EXIT -ne 0 ] || [ $LINT_EXIT -ne 0 ]; then + echo "❌ One or more linting checks failed." + exit 1 + fi +else + echo "✅ No Python files changed in this scope. Skipping checks." From 8e9cfbef846486426aa9e90af44d4278af7fddad Mon Sep 17 00:00:00 2001 From: Jennifer Davis Date: Tue, 2 Jun 2026 22:11:56 -0700 Subject: [PATCH 03/19] fix: Update lint-changed.sh --- .github/scripts/lint-changed.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/scripts/lint-changed.sh b/.github/scripts/lint-changed.sh index 1b0a6bcec8a..698ef423f35 100644 --- a/.github/scripts/lint-changed.sh +++ b/.github/scripts/lint-changed.sh @@ -12,7 +12,6 @@ echo "Configuring target diff for event: $EVENT_NAME" # Determine the base branch/commit to diff against if [ "$EVENT_NAME" = "pull_request" ]; then # Ensure we have the target branch metadata fetched. - # Note: If this fails due to shallow clone issues, the script will exit safely via set -e git fetch origin "$BASE_REF" --depth=1 --quiet BASE_SHA="origin/$BASE_REF" else @@ -23,8 +22,13 @@ else fi fi -# Extract changed Python files into a Bash array -mapfile -t CHANGED_FILES < <(git diff --name-only --diff-filter=d "$BASE_SHA" -- '*.py' 2>/dev/null || true) +DIFF_OUTPUT=$(git diff --name-only --diff-filter=d "$BASE_SHA" -- '*.py' 2>/dev/null || true) + +if [ -n "$DIFF_OUTPUT" ]; then + mapfile -t CHANGED_FILES <<< "$DIFF_OUTPUT" +else + CHANGED_FILES=() +fi # Execute linters if files exist if [ ${#CHANGED_FILES[@]} -gt 0 ]; then @@ -45,3 +49,4 @@ if [ ${#CHANGED_FILES[@]} -gt 0 ]; then fi else echo "✅ No Python files changed in this scope. Skipping checks." +fi From c8dd4894e712e9594e768a5522bcfbd40e168722 Mon Sep 17 00:00:00 2001 From: Jennifer Davis Date: Tue, 2 Jun 2026 22:16:46 -0700 Subject: [PATCH 04/19] fix: add license header to lint-changed.sh --- .github/scripts/lint-changed.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/scripts/lint-changed.sh b/.github/scripts/lint-changed.sh index 698ef423f35..ecfee5cfba1 100644 --- a/.github/scripts/lint-changed.sh +++ b/.github/scripts/lint-changed.sh @@ -1,6 +1,18 @@ #!/usr/bin/env bash +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. -# Exit immediately if a command fails, or if an unset variable is used set -euo pipefail EVENT_NAME="${1:-local}" From 9f457eab4a9c8df3517eddb855020fd432e41a02 Mon Sep 17 00:00:00 2001 From: Jennifer Davis Date: Wed, 3 Jun 2026 09:18:25 -0700 Subject: [PATCH 05/19] fix: minor update to GitHub action --- .github/workflows/lint.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 8a9ca77de55..507663bbf40 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -35,8 +35,13 @@ jobs: run: chmod +x .github/scripts/lint-changed.sh - name: Run lint script for changed files + env: + EVENT_NAME: ${{ github.event_name }} + BASE_REF: ${{ github.base_ref }} + BEFORE_SHA: ${{ github.event.before }} run: | + # Use default string values if the GitHub Context variables are null/empty .github/scripts/lint-changed.sh \ - "${{ github.event_name }}" \ - "${{ github.base_ref || github.ref_name }}" \ - "${{ github.event.before }}" + "${EVENT_NAME:-local}" \ + "${BASE_REF:-main}" \ + "${BEFORE_SHA:-}" From 786cf9771ccd9b2c24cef1404a4d8d28c1f511b7 Mon Sep 17 00:00:00 2001 From: Jennifer Davis Date: Wed, 3 Jun 2026 09:22:21 -0700 Subject: [PATCH 06/19] fix: remove checking for pushes against main. we never push to main. --- .github/scripts/lint-changed.sh | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/.github/scripts/lint-changed.sh b/.github/scripts/lint-changed.sh index ecfee5cfba1..e2bb2650006 100644 --- a/.github/scripts/lint-changed.sh +++ b/.github/scripts/lint-changed.sh @@ -17,24 +17,26 @@ set -euo pipefail EVENT_NAME="${1:-local}" BASE_REF="${2:-main}" -BEFORE_SHA="${3:-}" echo "Configuring target diff for event: $EVENT_NAME" -# Determine the base branch/commit to diff against +# Determine the target reference to diff against if [ "$EVENT_NAME" = "pull_request" ]; then + echo "Fetching origin/$BASE_REF metadata..." # Ensure we have the target branch metadata fetched. git fetch origin "$BASE_REF" --depth=1 --quiet - BASE_SHA="origin/$BASE_REF" + + # Isolate to only changes in the PR + DIFF_COMMAND="origin/$BASE_REF..." else - BASE_SHA="$BEFORE_SHA" - # Fallback if it's a direct push without a prior SHA, or a local run - if [ "$BASE_SHA" = "0000000000000000000000000000000000000000" ] || [ -z "$BASE_SHA" ]; then - BASE_SHA="HEAD~1" - fi + # Local fallback + # diff against local main branch. + echo "Running locally. Diffing against local $BASE_REF..." + DIFF_COMMAND="$BASE_REF" fi -DIFF_OUTPUT=$(git diff --name-only --diff-filter=d "$BASE_SHA" -- '*.py' 2>/dev/null || true) +# Gather modified/added Python files, explicitly ignoring deleted files via --diff-filter=d +DIFF_OUTPUT=$(git diff --name-only --diff-filter=d "$DIFF_COMMAND" -- '*.py' 2>/dev/null || true) if [ -n "$DIFF_OUTPUT" ]; then mapfile -t CHANGED_FILES <<< "$DIFF_OUTPUT" @@ -42,17 +44,20 @@ else CHANGED_FILES=() fi -# Execute linters if files exist +# Execute linters if changed Python files exist if [ ${#CHANGED_FILES[@]} -gt 0 ]; then echo "Files to lint:" printf ' - %s\n' "${CHANGED_FILES[@]}" - # Track execution success manually so both tools get a chance to run + # Track execution success manually so both tools get a chance to run. + # This prevents the workflow from dying on Black without showing Flake8 errors. BLACK_EXIT=0 LINT_EXIT=0 - # Pass the array safely using "${CHANGED_FILES[@]}" + echo "Running blacken..." nox -s blacken -- "${CHANGED_FILES[@]}" || BLACK_EXIT=$? + + echo "Running flake8 lint..." nox -s lint -- "${CHANGED_FILES[@]}" || LINT_EXIT=$? if [ $BLACK_EXIT -ne 0 ] || [ $LINT_EXIT -ne 0 ]; then From d8ed76f3cdc2a58d1bdf45eb3bd7768c55eb6d38 Mon Sep 17 00:00:00 2001 From: Jennifer Davis Date: Wed, 3 Jun 2026 09:23:59 -0700 Subject: [PATCH 07/19] fix: update based on never pushing to main. --- .github/workflows/lint.yml | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 507663bbf40..6e7ced6a19d 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,8 +1,6 @@ name: Lint on: - push: - branches: [ main ] pull_request: branches: [ main ] @@ -34,14 +32,6 @@ jobs: - name: Make script executable run: chmod +x .github/scripts/lint-changed.sh - - name: Run lint script for changed files - env: - EVENT_NAME: ${{ github.event_name }} - BASE_REF: ${{ github.base_ref }} - BEFORE_SHA: ${{ github.event.before }} + - name: name: Run lint script for changed files run: | - # Use default string values if the GitHub Context variables are null/empty - .github/scripts/lint-changed.sh \ - "${EVENT_NAME:-local}" \ - "${BASE_REF:-main}" \ - "${BEFORE_SHA:-}" + .github/scripts/lint-changed.sh "pull_request" "${{ github.base_ref }}" From 927be10d714de3c4364e7c9143b550000c820bd9 Mon Sep 17 00:00:00 2001 From: Jennifer Davis Date: Wed, 3 Jun 2026 09:26:33 -0700 Subject: [PATCH 08/19] fix: address action scanning issue (maybe) --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 6e7ced6a19d..8a79c193ec0 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -32,6 +32,6 @@ jobs: - name: Make script executable run: chmod +x .github/scripts/lint-changed.sh - - name: name: Run lint script for changed files + - name: Run lint script for changed files run: | .github/scripts/lint-changed.sh "pull_request" "${{ github.base_ref }}" From 223adc74495a24c9a653b89467b8e040a7f9e259 Mon Sep 17 00:00:00 2001 From: Jennifer Davis Date: Wed, 3 Jun 2026 09:31:06 -0700 Subject: [PATCH 09/19] feat: add a failing test fixture for linting --- .internal/tests/fixtures/test_fail.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .internal/tests/fixtures/test_fail.py diff --git a/.internal/tests/fixtures/test_fail.py b/.internal/tests/fixtures/test_fail.py new file mode 100644 index 00000000000..86e323e7e7e --- /dev/null +++ b/.internal/tests/fixtures/test_fail.py @@ -0,0 +1,11 @@ +# test_fail.py +import sys # Flake8 Error: 'sys' imported but unused +import os + +def calculate_square (number): # Flake8 Error: extra space before opening parenthesis + + result=number*number # Flake8 Error: missing whitespace around operator '=' + print('The result is: ' + str(result)) # Black will want to change single quotes to double quotes + return result + +# Intentional trailing whitespace on the line below to trigger Flake8 From a655b34173321141715f91fe0a90c7cba181b7b8 Mon Sep 17 00:00:00 2001 From: Jennifer Davis Date: Wed, 3 Jun 2026 09:32:07 -0700 Subject: [PATCH 10/19] feat: add a passing test python file for linting --- .internal/tests/fixtures/test_pass.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .internal/tests/fixtures/test_pass.py diff --git a/.internal/tests/fixtures/test_pass.py b/.internal/tests/fixtures/test_pass.py new file mode 100644 index 00000000000..b5bb7917815 --- /dev/null +++ b/.internal/tests/fixtures/test_pass.py @@ -0,0 +1,15 @@ +# test_pass.py +import os + + +def calculate_square(number: int) -> int: + """Calculates the square of a given integer.""" + result = number * number + print(f"The result is: {result}") + return result + + +if __name__ == "__main__": + # Ensure a basic execution works cleanly + current_directory = os.getcwd() + calculate_square(5) From 5619c8122dbe3f48a4c14f4e81f0e945862abaf1 Mon Sep 17 00:00:00 2001 From: Jennifer Davis Date: Wed, 3 Jun 2026 09:33:37 -0700 Subject: [PATCH 11/19] fix: address header issues --- .internal/tests/fixtures/test_fail.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.internal/tests/fixtures/test_fail.py b/.internal/tests/fixtures/test_fail.py index 86e323e7e7e..94c84da0902 100644 --- a/.internal/tests/fixtures/test_fail.py +++ b/.internal/tests/fixtures/test_fail.py @@ -1,3 +1,17 @@ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # test_fail.py import sys # Flake8 Error: 'sys' imported but unused import os From c562e7a38f9962e694928ab109262120b14238e5 Mon Sep 17 00:00:00 2001 From: Jennifer Davis Date: Wed, 3 Jun 2026 09:34:01 -0700 Subject: [PATCH 12/19] fix: address header issues --- .internal/tests/fixtures/test_pass.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.internal/tests/fixtures/test_pass.py b/.internal/tests/fixtures/test_pass.py index b5bb7917815..5561c878041 100644 --- a/.internal/tests/fixtures/test_pass.py +++ b/.internal/tests/fixtures/test_pass.py @@ -1,3 +1,17 @@ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # test_pass.py import os From 69fce966d0dd87da9209b86a65f230b3251b90c5 Mon Sep 17 00:00:00 2001 From: Jennifer Davis Date: Wed, 3 Jun 2026 09:41:16 -0700 Subject: [PATCH 13/19] fix: create updated noxfile template so that only targeted files are linted --- .github/scripts/noxfile-lint.py | 88 +++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 .github/scripts/noxfile-lint.py diff --git a/.github/scripts/noxfile-lint.py b/.github/scripts/noxfile-lint.py new file mode 100644 index 00000000000..d1db7b7506d --- /dev/null +++ b/.github/scripts/noxfile-lint.py @@ -0,0 +1,88 @@ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from __future__ import annotations + +import os +import sys +import nox + +# Use a stable Python version for running the style utilities +LINTING_VERSION = "3.10" + +# Error out if the runner is missing the target python interpreter +nox.options.error_on_missing_interpreters = True + + +def _determine_local_import_names(start_dir: str) -> list[str]: + """Determines local import names to assist Flake8 with import order checks.""" + try: + file_ext_pairs = [os.path.splitext(path) for path in os.listdir(start_dir)] + return [ + basename + for basename, extension in file_ext_pairs + if extension == ".py" + or (os.path.isdir(os.path.join(start_dir, basename)) and basename != "__pycache__") + ] + except Exception: + return [] + + +# Standardize style configuration parameters +FLAKE8_COMMON_ARGS = [ + "--show-source", + "--builtin=gettext", + "--max-complexity=20", + "--import-order-style=google", + "--exclude=.nox,.cache,env,lib,generated_pb2,*_pb2.py,*_pb2_grpc.py", + "--ignore=ANN101,ANN102,E121,E123,E126,E203,E226,E24,E266,E501,E704,W503,W504,I202", + "--max-line-length=88", +] + + +@nox.session(python=LINTING_VERSION) +def lint(session: nox.sessions.Session) -> None: + """Runs flake8 linting checks. Honors incremental PR file arguments.""" + session.install("flake8", "flake8-import-order") + + local_names = _determine_local_import_names(".") + args = FLAKE8_COMMON_ARGS + [ + "--application-import-names", + ",".join(local_names), + ] + + if session.posargs: + args.extend(session.posargs) + else: + args.append(".") + + session.run("flake8", *args) + + +@nox.session(python=LINTING_VERSION) +def blacken(session: nox.sessions.Session) -> None: + """Runs black code formatting checks. Honors incremental PR file arguments.""" + session.install("black") + + # If explicit target files are passed via posargs, target ONLY those files. + if session.posargs: + targets = session.posargs + else: + # Fallback to scanning immediate root Python files if run purely locally without args + targets = [path for path in os.listdir(".") if path.endswith(".py")] + + if targets: + session.run("black", *targets) + else: + session.log("No specific Python targets identified for formatting validations.") From f65fdeb991941a3f5e8062a0df30135445fb1ee9 Mon Sep 17 00:00:00 2001 From: Jennifer Davis Date: Wed, 3 Jun 2026 09:42:37 -0700 Subject: [PATCH 14/19] fix: use customized noxfile template --- .github/workflows/lint.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 8a79c193ec0..9701c2f0de8 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -27,7 +27,9 @@ jobs: python -m pip install nox - name: Prepare noxfile - run: cp noxfile-template.py noxfile.py + # copy from customized noxfile so that we don't lint everything in the repository + # we don't expect contributors to fix past lint issues + run: cp .github/scripts/noxfile-lint.py noxfile.py - name: Make script executable run: chmod +x .github/scripts/lint-changed.sh From 1070b788760ead1848a4539e1fc45beb68fab7bd Mon Sep 17 00:00:00 2001 From: Jennifer Davis Date: Wed, 3 Jun 2026 09:44:20 -0700 Subject: [PATCH 15/19] fix: address on lint passing test Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com> --- .internal/tests/fixtures/test_pass.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/.internal/tests/fixtures/test_pass.py b/.internal/tests/fixtures/test_pass.py index 5561c878041..e9cbf0f0225 100644 --- a/.internal/tests/fixtures/test_pass.py +++ b/.internal/tests/fixtures/test_pass.py @@ -13,7 +13,6 @@ # limitations under the License. # test_pass.py -import os def calculate_square(number: int) -> int: @@ -25,5 +24,4 @@ def calculate_square(number: int) -> int: if __name__ == "__main__": # Ensure a basic execution works cleanly - current_directory = os.getcwd() calculate_square(5) From 2c8609808c5b5f7c154b650d171bc6c1fd5a3a1d Mon Sep 17 00:00:00 2001 From: Jennifer Davis Date: Wed, 3 Jun 2026 09:56:53 -0700 Subject: [PATCH 16/19] fix: address some of the noisy logging in the output to the action --- .github/scripts/lint-changed.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/scripts/lint-changed.sh b/.github/scripts/lint-changed.sh index e2bb2650006..7e4ca691318 100644 --- a/.github/scripts/lint-changed.sh +++ b/.github/scripts/lint-changed.sh @@ -54,11 +54,12 @@ if [ ${#CHANGED_FILES[@]} -gt 0 ]; then BLACK_EXIT=0 LINT_EXIT=0 + # adding -q to silence some of the extraneous logging echo "Running blacken..." - nox -s blacken -- "${CHANGED_FILES[@]}" || BLACK_EXIT=$? + nox -q -s blacken -- "${CHANGED_FILES[@]}" || BLACK_EXIT=$? echo "Running flake8 lint..." - nox -s lint -- "${CHANGED_FILES[@]}" || LINT_EXIT=$? + nox -q -s lint -- "${CHANGED_FILES[@]}" || LINT_EXIT=$? if [ $BLACK_EXIT -ne 0 ] || [ $LINT_EXIT -ne 0 ]; then echo "❌ One or more linting checks failed." From 8708a795d1625fd2219da46c220aaf22faef9758 Mon Sep 17 00:00:00 2001 From: Jennifer Davis Date: Wed, 3 Jun 2026 09:59:48 -0700 Subject: [PATCH 17/19] chore: remove failing lint file for now .internal/tests/fixtures/test_fail.py --- .internal/tests/fixtures/test_fail.py | 25 ------------------------- 1 file changed, 25 deletions(-) delete mode 100644 .internal/tests/fixtures/test_fail.py diff --git a/.internal/tests/fixtures/test_fail.py b/.internal/tests/fixtures/test_fail.py deleted file mode 100644 index 94c84da0902..00000000000 --- a/.internal/tests/fixtures/test_fail.py +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright 2026 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# test_fail.py -import sys # Flake8 Error: 'sys' imported but unused -import os - -def calculate_square (number): # Flake8 Error: extra space before opening parenthesis - - result=number*number # Flake8 Error: missing whitespace around operator '=' - print('The result is: ' + str(result)) # Black will want to change single quotes to double quotes - return result - -# Intentional trailing whitespace on the line below to trigger Flake8 From 67cb2238e2ad7747d1499064d4a2d5cc3810f033 Mon Sep 17 00:00:00 2001 From: Jennifer Davis Date: Wed, 3 Jun 2026 10:02:22 -0700 Subject: [PATCH 18/19] fix: no quiet mode :( --- .github/scripts/lint-changed.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/scripts/lint-changed.sh b/.github/scripts/lint-changed.sh index 7e4ca691318..0597909b9ae 100644 --- a/.github/scripts/lint-changed.sh +++ b/.github/scripts/lint-changed.sh @@ -56,10 +56,10 @@ if [ ${#CHANGED_FILES[@]} -gt 0 ]; then # adding -q to silence some of the extraneous logging echo "Running blacken..." - nox -q -s blacken -- "${CHANGED_FILES[@]}" || BLACK_EXIT=$? + nox -s blacken -- "${CHANGED_FILES[@]}" || BLACK_EXIT=$? echo "Running flake8 lint..." - nox -q -s lint -- "${CHANGED_FILES[@]}" || LINT_EXIT=$? + nox -s lint -- "${CHANGED_FILES[@]}" || LINT_EXIT=$? if [ $BLACK_EXIT -ne 0 ] || [ $LINT_EXIT -ne 0 ]; then echo "❌ One or more linting checks failed." From 43ed342e331ab3b36a70bfc91d6fdc0d64416bcc Mon Sep 17 00:00:00 2001 From: Jennifer Davis Date: Wed, 3 Jun 2026 10:06:57 -0700 Subject: [PATCH 19/19] fix: address linting issues with lib and readd comment --- .github/scripts/noxfile-lint.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/scripts/noxfile-lint.py b/.github/scripts/noxfile-lint.py index d1db7b7506d..c1ce614150d 100644 --- a/.github/scripts/noxfile-lint.py +++ b/.github/scripts/noxfile-lint.py @@ -15,7 +15,7 @@ from __future__ import annotations import os -import sys + import nox # Use a stable Python version for running the style utilities @@ -38,6 +38,20 @@ def _determine_local_import_names(start_dir: str) -> list[str]: except Exception: return [] +# Linting with flake8. +# +# We ignore the following rules: +# ANN101: missing type annotation for `self` in method +# ANN102: missing type annotation for `cls` in method +# E203: whitespace before ‘:’ +# E266: too many leading ‘#’ for block comment +# E501: line too long +# I202: Additional newline in a section of imports +# +# We also need to specify the rules which are ignored by default: +# ['E226', 'W504', 'E126', 'E123', 'W503', 'E24', 'E704', 'E121'] +# +# For more information see: https://pypi.org/project/flake8-annotations # Standardize style configuration parameters FLAKE8_COMMON_ARGS = [