Skip to content

fix(griffe): replace production assert, fix dep vulns, add vuln handling docs - #395

Merged
Alberto-Codes merged 3 commits into
mainfrom
fix/griffe-remove-production-assert
Mar 27, 2026
Merged

fix(griffe): replace production assert, fix dep vulns, add vuln handling docs#395
Alberto-Codes merged 3 commits into
mainfrom
fix/griffe-remove-production-assert

Conversation

@Alberto-Codes

@Alberto-Codes Alberto-Codes commented Mar 27, 2026

Copy link
Copy Markdown
Owner

_collect_object_findings used assert obj.docstring is not None to enforce
an invariant guaranteed by the caller. This violates the project rule against
assert in production code — assertions are stripped under -O and are
reserved for tests.

Additionally, the uv-secure CI gate was failing due to two known
dependency vulnerabilities. One had a fix available (requests); the other
(Pygments) does not yet have a patch.

  • Replace assert with an early-return guard (if obj.docstring is None: return [])
  • Update docstring to document the guard behavior
  • Add test for the None-docstring guard path
  • Upgrade requests 2.32.5 -> 2.33.0 (fixes GHSA-gc5v-m9x4-r6x2)
  • Add uv-secure config to suppress Pygments GHSA-5239-wwwm-4pmq with allow_unused_ignores = false
  • Add .claude/rules/dependency-vulnerabilities.md with triage process
  • Add "Dependency Vulnerabilities" section to CONTRIBUTING.md

Test: uv run pytest tests/unit/checks/test_griffe_compat.py -v && uv run uv-secure

chore(deps): fix requests vuln, suppress unfixed Pygments GHSA, add vuln handling docs


PR Review

Checklist

  • Self-reviewed my code
  • Tests pass (uv run pytest)
  • Lint passes (uv run ruff check .)
  • Types pass (uv run ty check)
  • Breaking changes use ! in title and BREAKING CHANGE: in body

Review Focus

  • uv-secure config in pyproject.toml: allow_unused_ignores = false ensures CI fails when Pygments ships a fix and the ignore becomes stale
  • New rule file establishes the triage process for future vulns

Related

Surfaced during party-mode codebase review.

The assert in _collect_object_findings violated the project rule
against assert in production code. Replaced with an early return
guard that handles the same invariant safely.
@codecov

codecov Bot commented Mar 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@Alberto-Codes
Alberto-Codes marked this pull request as ready for review March 27, 2026 00:12
Copilot AI review requested due to automatic review settings March 27, 2026 00:12

Copilot AI 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.

Pull request overview

Updates griffe_compat’s internal finding collection helper to avoid relying on production assert for a runtime invariant, making behavior safe under python -O.

Changes:

  • Replace assert obj.docstring is not None with an explicit early-return guard when no docstring is present
  • Update _collect_object_findings docstring to document the guard/early-return behavior

Comment thread src/docvet/checks/griffe_compat.py Outdated
…uln handling docs

Upgrade requests 2.32.5 -> 2.33.0 to resolve GHSA-gc5v-m9x4-r6x2.
Add uv-secure ignore for Pygments GHSA-5239-wwwm-4pmq (no fix available)
with allow_unused_ignores=false so CI fails when the ignore goes stale.
Add dependency vulnerability handling rule and CONTRIBUTING.md section.
Add test for _collect_object_findings None-docstring guard.
@Alberto-Codes Alberto-Codes changed the title fix(griffe): replace production assert with explicit guard fix(griffe): replace production assert, fix dep vulns, add vuln handling docs Mar 27, 2026
@Alberto-Codes
Alberto-Codes merged commit 7273e56 into main Mar 27, 2026
12 checks passed
@Alberto-Codes
Alberto-Codes deleted the fix/griffe-remove-production-assert branch March 27, 2026 00:53
Alberto-Codes added a commit that referenced this pull request Mar 27, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.15.0](v1.14.1...v1.15.0)
(2026-03-27)


### Features

* **cli:** add docvet fix subcommand with dry-run and discovery
([#386](#386))
([7f76477](7f76477))
* **cli:** add inline suppression comments for findings
([#393](#393))
([14ba0b7](14ba0b7))
* **enrichment:** add scaffold category, scaffolding engine, and
scaffold-incomplete rule
([#385](#385))
([782cd27](782cd27))
* **enrichment:** add scaffold-incomplete enrichment rule
([782cd27](782cd27))


### Bug Fixes

* **cli:** address code review findings for fix subcommand
([7f76477](7f76477))
* **cli:** prevent uppercase rule IDs from degrading to blanket
([14ba0b7](14ba0b7))
* **config:** address PR
[#379](#379) review
feedback ([#380](#380))
([134e428](134e428))
* **enrichment:** handle docstring-only stubs, multi-statement stubs,
and deprecated abstract decorators
([#391](#391))
([bc2445d](bc2445d)),
closes [#387](#387)
[#388](#388)
[#389](#389)
* **griffe:** replace production assert, fix dep vulns, add vuln
handling docs
([#395](#395))
([7273e56](7273e56))
* **test:** move _active_style reset to shared conftest fixture
([#363](#363))
([b8b6586](b8b6586))


### Documentation

* **cli:** add missing subcommands to quick references
([#397](#397))
([d92af72](d92af72)),
closes [#396](#396)
* **enrichment:** add scaffold-incomplete rule page and config docs
([782cd27](782cd27))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
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