Add ruff/mypy linting and pre-commit, plus code formatting and minor typing fixes - #34
canstralian wants to merge 1 commit into
Conversation
|
Warning Review limit reached
Next review available in: 55 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (17)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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"), |
There was a problem hiding this comment.
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:
- Require balanced parentheses for the area code:
(?:\(\d{3}\)|\d{3}). - 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"
| (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"), |
| reason="; ".join( | ||
| validation.reasons.get(k, "") for k in validation.blocking_failures | ||
| ), |
There was a problem hiding this comment.
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
),
Motivation
rufffixes and runmypychecks before committing.Description
.github/workflows/ci.ymland.github/workflows/lint.ymlto install and run lint checks; pinnedruff==0.15.1andmypy==1.18.2and addedruff format --check .andmypy --explicit-package-bases .steps..pre-commit-config.yamlwithruffandmypyhooks and createdpyproject.tomlcontainingruffandmypyconfiguration.list_vectors() -> list[str]), added TODOs and clarified docstrings inadapters/mcp/server.pyandadapters/airtable/scope_mapper.py, and minor functional-preserving refactors in guardrails and validator modules to conform to linters.tests/*to match style and normalization changes.Testing
pytest -qin CI and the test run completed successfully.ruff check .,ruff format --check .andmypy --explicit-package-bases .were added to the lint job and passed in CI.ruffandmypychecks automatically (no failures reported in CI run).Codex Task