From baf1ccc91562ce345c788e61a76a6ab9d0203e4b Mon Sep 17 00:00:00 2001 From: JWinermaSplunk Date: Fri, 5 Dec 2025 14:20:05 -0800 Subject: [PATCH 1/8] initial commit --- README.md | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index dd29393e..939fb24d 100644 --- a/README.md +++ b/README.md @@ -291,7 +291,35 @@ inv.output_messages = [OutputMessage(role="assistant", parts=[Text("Hi!")], fini handler.stop_llm(inv) ``` -## 16. Validation Strategy +## 16. Resolving CI Lint Failures + +If the CI lint job fails on your PR, you can automatically fix all linting and formatting issues: + +```bash +make lint +``` + +This command will: +1. Install ruff 0.6.9 (the version used in CI) +2. Auto-fix all linting issues +3. Auto-format all code +4. Verify that all checks pass + +After running the command, commit and push the changes: + +```bash +git add . +git commit -m "fix: auto-fix linting issues" +git push +``` + +The CI lint job checks two things: +- **Linting**: `ruff check .` - checks for code quality issues +- **Formatting**: `ruff format --check .` - checks code formatting + +The `make lint` command fixes both automatically. + +## 17. Validation Strategy - Unit tests: env parsing, category overrides, evaluator grammar, sampling, content capture gating. - Future: ordering hints tests once implemented. From 4df197583d8079f9a8bcca32e0821772129b3040 Mon Sep 17 00:00:00 2001 From: JWinermaSplunk Date: Fri, 5 Dec 2025 14:24:39 -0800 Subject: [PATCH 2/8] add lint failure --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 939fb24d..5f845c78 100644 --- a/README.md +++ b/README.md @@ -293,7 +293,7 @@ handler.stop_llm(inv) ## 16. Resolving CI Lint Failures -If the CI lint job fails on your PR, you can automatically fix all linting and formatting issues: +If the CI lint job fails on your PR, you can automatically fix all linting and formatting issues: ```bash make lint From 387d61f9fd37a9da51370ccd07b6936ed9f5fc29 Mon Sep 17 00:00:00 2001 From: JWinermaSplunk Date: Fri, 5 Dec 2025 14:27:46 -0800 Subject: [PATCH 3/8] add lint failure --- .../src/opentelemetry/util/genai/types.py | 1 + 1 file changed, 1 insertion(+) diff --git a/util/opentelemetry-util-genai/src/opentelemetry/util/genai/types.py b/util/opentelemetry-util-genai/src/opentelemetry/util/genai/types.py index 12424b71..e609ae70 100644 --- a/util/opentelemetry-util-genai/src/opentelemetry/util/genai/types.py +++ b/util/opentelemetry-util-genai/src/opentelemetry/util/genai/types.py @@ -14,6 +14,7 @@ import time +import os from contextvars import Token from dataclasses import dataclass, field from dataclasses import fields as dataclass_fields From 419fc00f8d2ec6234109c38d842f3b5f7583ebac Mon Sep 17 00:00:00 2001 From: JWinermaSplunk Date: Fri, 5 Dec 2025 14:49:50 -0800 Subject: [PATCH 4/8] check lint pass --- .../src/opentelemetry/util/genai/types.py | 1 - 1 file changed, 1 deletion(-) diff --git a/util/opentelemetry-util-genai/src/opentelemetry/util/genai/types.py b/util/opentelemetry-util-genai/src/opentelemetry/util/genai/types.py index e609ae70..12424b71 100644 --- a/util/opentelemetry-util-genai/src/opentelemetry/util/genai/types.py +++ b/util/opentelemetry-util-genai/src/opentelemetry/util/genai/types.py @@ -14,7 +14,6 @@ import time -import os from contextvars import Token from dataclasses import dataclass, field from dataclasses import fields as dataclass_fields From ff83e84efe1d31c3f53b35801fc569d422f6ae6d Mon Sep 17 00:00:00 2001 From: JWinermaSplunk Date: Fri, 5 Dec 2025 14:52:00 -0800 Subject: [PATCH 5/8] add Makefile --- Makefile | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..6f480036 --- /dev/null +++ b/Makefile @@ -0,0 +1,22 @@ +.PHONY: lint + +# Fix all linting and formatting issues from CI +lint: + @echo "Installing ruff..." + @python -m pip install --upgrade pip > /dev/null 2>&1 + @pip install ruff==0.6.9 > /dev/null 2>&1 + @echo "✓ Ruff installed" + @echo "" + @echo "Fixing linting issues..." + @ruff check --fix . + @echo "" + @echo "Fixing formatting..." + @ruff format . + @echo "" + @echo "✓ All linting and formatting issues fixed!" + @echo "" + @echo "Verifying fixes..." + @ruff check . + @ruff format --check . + @echo "" + @echo "✓ All CI lint checks will pass!" From 0690f64af00cb80b22b3ff7c8a86e55becae5958 Mon Sep 17 00:00:00 2001 From: JWinermaSplunk Date: Fri, 5 Dec 2025 14:58:51 -0800 Subject: [PATCH 6/8] update README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 5f845c78..a3d53056 100644 --- a/README.md +++ b/README.md @@ -299,6 +299,8 @@ If the CI lint job fails on your PR, you can automatically fix all linting and f make lint ``` +**Note:** It's recommended to run this from within a Python virtual environment to avoid installing ruff globally. + This command will: 1. Install ruff 0.6.9 (the version used in CI) 2. Auto-fix all linting issues From ba420e953ccba9d7e0d3bce0e7facea9f6db0709 Mon Sep 17 00:00:00 2001 From: JWinermaSplunk Date: Mon, 8 Dec 2025 10:04:59 -0800 Subject: [PATCH 7/8] remove Makefile and update README for pre-commit-config --- .pre-commit-config.yaml | 2 +- Makefile | 22 --------------- README.md | 62 ++++++++++++++++++++++++++++++----------- 3 files changed, 46 insertions(+), 40 deletions(-) delete mode 100644 Makefile diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5b9bf997..01486fbd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.6.9 + rev: v0.14.1 hooks: # Run the linter. - id: ruff diff --git a/Makefile b/Makefile deleted file mode 100644 index 6f480036..00000000 --- a/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -.PHONY: lint - -# Fix all linting and formatting issues from CI -lint: - @echo "Installing ruff..." - @python -m pip install --upgrade pip > /dev/null 2>&1 - @pip install ruff==0.6.9 > /dev/null 2>&1 - @echo "✓ Ruff installed" - @echo "" - @echo "Fixing linting issues..." - @ruff check --fix . - @echo "" - @echo "Fixing formatting..." - @ruff format . - @echo "" - @echo "✓ All linting and formatting issues fixed!" - @echo "" - @echo "Verifying fixes..." - @ruff check . - @ruff format --check . - @echo "" - @echo "✓ All CI lint checks will pass!" diff --git a/README.md b/README.md index a3d53056..d1602f45 100644 --- a/README.md +++ b/README.md @@ -291,35 +291,63 @@ inv.output_messages = [OutputMessage(role="assistant", parts=[Text("Hi!")], fini handler.stop_llm(inv) ``` -## 16. Resolving CI Lint Failures +## 16. Linting and Formatting -If the CI lint job fails on your PR, you can automatically fix all linting and formatting issues: +This project uses [pre-commit](https://pre-commit.com/) hooks to automatically check and fix linting and formatting issues before committing. + +### Setting Up Pre-Commit Hooks + +Install and configure pre-commit hooks (recommended to run in a virtual environment): ```bash -make lint +pip install pre-commit +pre-commit install ``` -**Note:** It's recommended to run this from within a Python virtual environment to avoid installing ruff globally. +Once installed, the hooks will automatically run on every `git commit` and will: +- Fix linting issues with ruff +- Format code with ruff +- Check RST documentation files +- Update dependency locks -This command will: -1. Install ruff 0.6.9 (the version used in CI) -2. Auto-fix all linting issues -3. Auto-format all code -4. Verify that all checks pass +### Running Pre-Commit Manually -After running the command, commit and push the changes: +To run pre-commit checks on all files (not just staged files): ```bash -git add . -git commit -m "fix: auto-fix linting issues" -git push +pre-commit run --all-files ``` -The CI lint job checks two things: -- **Linting**: `ruff check .` - checks for code quality issues -- **Formatting**: `ruff format --check .` - checks code formatting +This is useful for: +- Fixing existing lint failures in CI +- Checking the entire codebase before pushing +- Running checks without committing + +### Resolving CI Lint Failures + +If the CI lint job fails on your PR: + +1. **Run pre-commit on all files:** + ```bash + pre-commit run --all-files + ``` + +2. **Review and stage the fixes:** + ```bash + git add . + ``` + +3. **Commit and push:** + ```bash + git commit -m "fix: auto-fix linting issues" + git push + ``` + +The CI lint job checks: +- **Linting**: `ruff check .` - code quality issues (unused imports, undefined names, etc.) +- **Formatting**: `ruff format --check .` - code formatting consistency -The `make lint` command fixes both automatically. +Pre-commit hooks use the same ruff version and configuration as CI, ensuring local checks match CI requirements. ## 17. Validation Strategy From 05c0aff916219f2a3919388006d604db74b8243e Mon Sep 17 00:00:00 2001 From: JWinermaSplunk Date: Wed, 17 Dec 2025 12:10:16 -0800 Subject: [PATCH 8/8] add back Makefile and update README --- Makefile | 22 ++++++++++++++++++++++ README.md | 26 ++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..6f480036 --- /dev/null +++ b/Makefile @@ -0,0 +1,22 @@ +.PHONY: lint + +# Fix all linting and formatting issues from CI +lint: + @echo "Installing ruff..." + @python -m pip install --upgrade pip > /dev/null 2>&1 + @pip install ruff==0.6.9 > /dev/null 2>&1 + @echo "✓ Ruff installed" + @echo "" + @echo "Fixing linting issues..." + @ruff check --fix . + @echo "" + @echo "Fixing formatting..." + @ruff format . + @echo "" + @echo "✓ All linting and formatting issues fixed!" + @echo "" + @echo "Verifying fixes..." + @ruff check . + @ruff format --check . + @echo "" + @echo "✓ All CI lint checks will pass!" diff --git a/README.md b/README.md index d1602f45..e19c3954 100644 --- a/README.md +++ b/README.md @@ -327,6 +327,32 @@ This is useful for: If the CI lint job fails on your PR: +#### Option 1: Using Make (Recommended for instrumentation packages) + +Some instrumentation packages include a Makefile with a lint recipe that automatically fixes all linting and formatting issues. + +**Note:** It's recommended to run this in a virtual environment to avoid conflicts with system packages. + +```bash +cd instrumentation-genai/opentelemetry-instrumentation-weaviate +make lint +``` + +This will: +- Install the correct version of ruff +- Fix all linting issues with `ruff check --fix` +- Format all code with `ruff format` +- Verify that all fixes pass CI checks + +Then commit and push the changes: +```bash +git add . +git commit -m "fix: auto-fix linting issues" +git push +``` + +#### Option 2: Using Pre-Commit + 1. **Run pre-commit on all files:** ```bash pre-commit run --all-files