feat(version-scanner): implement targeted namespaced ignore pragmas - #17540
Merged
Merged
Conversation
…g under _safe_read_file
…nd hybrid packages
Contributor
There was a problem hiding this comment.
Code Review
This pull request adds support for targeted rule ignoring in the version scanner using the version-scanner: ignore-rule=<rule_name>:<version> pragma, along with corresponding unit tests. Feedback was provided to convert the version value to a string before calling re.escape to avoid potential runtime TypeError exceptions if a non-string version (such as a float or integer) is specified in the rule configuration.
chalmerlowe
marked this pull request as ready for review
June 23, 2026 15:07
chalmerlowe
force-pushed
the
feat/version-scanner-pr2
branch
from
June 23, 2026 15:21
04f3d2d to
69e81ab
Compare
chalmerlowe
force-pushed
the
feat/version-scanner-pr3
branch
from
June 23, 2026 15:21
64367eb to
23b8ef3
Compare
…on-generated-packages
chalmerlowe
force-pushed
the
feat/version-scanner-pr2
branch
from
June 23, 2026 15:31
69e81ab to
111c152
Compare
chalmerlowe
force-pushed
the
feat/version-scanner-pr3
branch
from
June 23, 2026 15:31
23b8ef3 to
031be67
Compare
…loat versions, and argument validation
chalmerlowe
force-pushed
the
feat/version-scanner-pr2
branch
from
June 23, 2026 15:57
111c152 to
055975c
Compare
chalmerlowe
force-pushed
the
feat/version-scanner-pr3
branch
from
June 23, 2026 15:58
031be67 to
8abd504
Compare
chalmerlowe
marked this pull request as draft
June 23, 2026 16:39
chalmerlowe
marked this pull request as ready for review
June 24, 2026 16:33
chalmerlowe
marked this pull request as draft
June 24, 2026 16:34
chalmerlowe
marked this pull request as ready for review
June 24, 2026 16:34
Contributor
Author
|
This is marked "DO NOT MERGE" simply because it is blocked by a precursor PR. It is fine to review this PR and approve, but it should not be merged until that other PR is merged. |
hebaalazzeh
approved these changes
Jun 25, 2026
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.
This PR implements ignore pragmas to allow granular and self-expiring ignores to help fend off false positives in places where we need to leave references to specific strings:
# version-scanner: ignore-rule=rule_name:versionExample:
Imagine searching for "Python 3.7". We have a variety of rules to cover multiple circumstances. One rule matches solely on the version number (e.g. "3.7" in case the reference is an edge case not covered by other more specific and complicated rules).
Thus if we find "3.7" in a situation unrelated to Python, we will have a false positive such as this:
matplotlib==3.7.2We can flag a line like this to be ignored under one of the numerous rules we have for categorizing matches (e.g
explicit_version_string,dependency_requirement,combined_version_string, etc.) so that it does not trigger a false positive in the future. In this case we detected it under theexplicit_version_stringpattern so we flag it to be ignored under that rule, if the search is for 3.7.matplotlib==3.7.2 # version-scanner: ignore-rule=explicit_version_string:3.7You might ask: but what about when we need to find versions of matplotlib so we can update references to them?
If instead of Python, we were to search for "matplotlib 3.7.2" we would get a match. As a non-Python match, it would be caught under the
dependency_requirementrule instead of theexplicit_*rule.