fix(griffe): replace production assert, fix dep vulns, add vuln handling docs - #395
Merged
Merged
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
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 Nonewith an explicit early-return guard when no docstring is present - Update
_collect_object_findingsdocstring to document the guard/early-return behavior
…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
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
_collect_object_findings used
assert obj.docstring is not Noneto enforcean invariant guaranteed by the caller. This violates the project rule against
assertin production code — assertions are stripped under-Oand arereserved for tests.
Additionally, the
uv-secureCI gate was failing due to two knowndependency vulnerabilities. One had a fix available (requests); the other
(Pygments) does not yet have a patch.
assertwith an early-return guard (if obj.docstring is None: return [])allow_unused_ignores = false.claude/rules/dependency-vulnerabilities.mdwith triage processTest:
uv run pytest tests/unit/checks/test_griffe_compat.py -v && uv run uv-securechore(deps): fix requests vuln, suppress unfixed Pygments GHSA, add vuln handling docs
PR Review
Checklist
uv run pytest)uv run ruff check .)uv run ty check)!in title andBREAKING CHANGE:in bodyReview Focus
allow_unused_ignores = falseensures CI fails when Pygments ships a fix and the ignore becomes staleRelated
Surfaced during party-mode codebase review.