Skip to content

Add ruff/mypy linting and pre-commit, plus code formatting and minor typing fixes - #34

Open
canstralian wants to merge 1 commit into
mainfrom
codex/consolidate-linting-tools-to-ruff-zw51u5
Open

canstralian wants to merge 1 commit into
mainfrom
codex/consolidate-linting-tools-to-ruff-zw51u5

Conversation

@canstralian

Copy link
Copy Markdown
Owner

Motivation

  • Integrate consistent linting, formatting and type checking into CI and local workflows to improve code quality and avoid regressions.
  • Add editor/commit hooks so contributors automatically apply ruff fixes and run mypy checks before committing.
  • Normalize formatting and small typing annotations across modules to satisfy the new linters without changing behavior.

Description

  • CI and linting: updated .github/workflows/ci.yml and .github/workflows/lint.yml to install and run lint checks; pinned ruff==0.15.1 and mypy==1.18.2 and added ruff format --check . and mypy --explicit-package-bases . steps.
  • Pre-commit and config: added .pre-commit-config.yaml with ruff and mypy hooks and created pyproject.toml containing ruff and mypy configuration.
  • Code cleanups: formatting/whitespace fixes, minor typing improvements (e.g. list_vectors() -> list[str]), added TODOs and clarified docstrings in adapters/mcp/server.py and adapters/airtable/scope_mapper.py, and minor functional-preserving refactors in guardrails and validator modules to conform to linters.
  • Tests updated: adjusted test string literals, formatting and parametrization in tests/* to match style and normalization changes.

Testing

  • Ran the test suite with pytest -q in CI and the test run completed successfully.
  • Lint checks ruff check ., ruff format --check . and mypy --explicit-package-bases . were added to the lint job and passed in CI.
  • Pre-commit hooks were added to the repository so local commits will run ruff and mypy checks automatically (no failures reported in CI run).

Codex Task

@coderabbitai

coderabbitai Bot commented Jun 5, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

@canstralian, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 55 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 66184f19-4565-4ed2-bbd7-a93dc19c0e84

📥 Commits

Reviewing files that changed from the base of the PR and between 3ecfc97 and 0dc6e12.

📒 Files selected for processing (17)
  • .github/workflows/ci.yml
  • .github/workflows/lint.yml
  • .pre-commit-config.yaml
  • adapters/airtable/scope_mapper.py
  • adapters/mcp/server.py
  • pyproject.toml
  • tests/test_repo_structure.py
  • tests/test_substrate_guardrails.py
  • vectors/pipeline/app.py
  • vectors/pipeline/models.py
  • vectors/pipeline/nlp_processor.py
  • vectors/pipeline/routes.py
  • vectors/storage/app.py
  • vectors/storage/routes.py
  • vectors/substrate/guardrails/input_scanner.py
  • vectors/substrate/guardrails/output_validator.py
  • vectors/substrate/processor.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/consolidate-linting-tools-to-ruff-zw51u5

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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

Copy link
Copy Markdown

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 primarily introduces code formatting and style consistency improvements across several files, including configuring ruff and mypy in pyproject.toml and .pre-commit-config.yaml. It also adds type annotations and updates docstrings in the MCP server adapter. Feedback on the changes highlights two key issues: first, the regular expression for phone numbers in output_validator.py is overly permissive and can lead to false positives on other multi-digit numbers (like database IDs or timestamps); second, in processor.py, when block_on_pii is disabled, any detected PII might still be incorrectly listed in the validation failure reasons if another check fails.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

r"drive|dr|lane|ln|way|court|ct)\b",
re.IGNORECASE,
), "address"),
(re.compile(r"\b(?:\+?\d{1,3}[\-.\s]?)?\(?\d{3}\)?[\-.\s]?\d{3}[\-.\s]?\d{4}\b"), "phone"),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The current regular expression for phone numbers \b(?:\+?\d{1,3}[\-.\s]?)?\(?\d{3}\)?[\-.\s]?\d{3}[\-.\s]?\d{4}\b can cause significant false positives. Because the country code group is optional and doesn't require a delimiter or a + prefix, any raw 11, 12, or 13-digit number (such as database IDs, timestamps, or hash prefixes) will be incorrectly matched as a phone number and redacted. Additionally, \(?\d{3}\)? allows unbalanced parentheses (e.g., (123 or 123)).

To prevent these false positives while still matching standard phone formats, we should:

  1. Require balanced parentheses for the area code: (?:\(\d{3}\)|\d{3}).
  2. Require a delimiter after the country code if it doesn't start with +, or require a + prefix if there is no delimiter.

Here is a more robust pattern:
r"\b(?:\+\d{1,3}[\-.\s]?|\d{1,3}[\-.\s])?(?:\(\d{3}\)|\d{3})[\-.\s]?\d{3}[\-.\s]?\d{4}\b"

Suggested change
(re.compile(r"\b(?:\+?\d{1,3}[\-.\s]?)?\(?\d{3}\)?[\-.\s]?\d{3}[\-.\s]?\d{4}\b"), "phone"),
(re.compile(r"\b(?:\+\d{1,3}[\-.\s]?|\d{1,3}[\-.\s])?(?:\(\d{3}\)|\d{3})[\-.\s]?\d{3}[\-.\s]?\d{4}\b"), "phone"),

Comment on lines +213 to +215
reason="; ".join(
validation.reasons.get(k, "") for k in validation.blocking_failures
),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

When block_on_pii is False (the default), any detected PII is still marked as False in verdicts["pii"] by the OutputValidator. This causes "pii" to be included in validation.blocking_failures.

If the validation subsequently fails due to another check (like leakage), the constructed reason here will incorrectly list the PII detection as a blocking failure, even though it was not configured to block the request.

We should filter out "pii" from the blocking failures list if self.config.block_on_pii is False.

                reason="; ".join(
                    validation.reasons.get(k, "")
                    for k in validation.blocking_failures
                    if k != "pii" or self.config.block_on_pii
                ),

@canstralian
canstralian marked this pull request as ready for review July 8, 2026 01:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant