-
Notifications
You must be signed in to change notification settings - Fork 7
Exclude dependencies in pyproject.toml from verify-hardcoded-version
#98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
KyleFromNVIDIA
merged 7 commits into
rapidsai:main
from
KyleFromNVIDIA:verify-hardcoded-version-exclude-pyproject-dependencies
Jan 23, 2026
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b8114e7
Exclude auto-generated dependencies in `pyproject.toml` from verify-h…
KyleFromNVIDIA c866274
More thorough test
KyleFromNVIDIA b31576d
Oops
KyleFromNVIDIA 7bd183a
s/=/-/
KyleFromNVIDIA fd58291
More testing
KyleFromNVIDIA ea70b01
Rename and move test_toml_utils.py
KyleFromNVIDIA 2bd7b48
Exclude build-system.requires
KyleFromNVIDIA File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import copy | ||
| import uuid | ||
|
|
||
| import tomlkit | ||
|
|
||
|
|
||
| _LocType = tuple[int, int] | ||
|
|
||
|
|
||
| def find_value_location( | ||
| document: "tomlkit.TOMLDocument", | ||
| key: tuple[str, ...], | ||
| *, | ||
| append: bool, | ||
| ) -> _LocType: | ||
| """ | ||
| Find the exact location of a key in a stringified TOML document. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| document : tomlkit.TOMLDocument | ||
| TOML content | ||
| key : tuple[str, ...] | ||
| Tuple of strings, of any length. | ||
| Items are evaluated in order as keys to subset into ``document``. | ||
| For example, to reference the 'license' value in the [project] table | ||
| in a pyproject.toml, ``key = ("project", "license",)``. | ||
| append : bool | ||
| If ``True``, returns the location where new text will be added. | ||
| If ``False``, returns the range of characters to be replaced. | ||
|
|
||
| Returns | ||
| ------- | ||
| loc : tuple[int, int] | ||
| Location of the key and its value in the document. | ||
| e.g., ``(20, 35)`` = "the 20th-35th characters, including newlines" | ||
| * element 0: number of characters from beginning of the document to | ||
| beginning of the section indicated by ``key`` | ||
| * element 1: final character to replace | ||
| """ | ||
| copied_document = copy.deepcopy(document) | ||
| placeholder = uuid.uuid4() | ||
| placeholder_toml = tomlkit.string(str(placeholder)) | ||
| placeholder_repr = placeholder_toml.as_string() | ||
|
|
||
| # tomlkit does not provide "mark" information to determine where exactly in | ||
| # the document a value is located, so instead we replace it with a | ||
| # placeholder and look for that in the new document. | ||
| node = copied_document | ||
| while len(key) > (0 if append else 1): | ||
| node = node[key[0]] # type: ignore[assignment] | ||
| key = key[1:] | ||
|
|
||
| if append: | ||
| node.add(str(placeholder), placeholder_toml) | ||
| value_to_find = f"{placeholder} = {placeholder_repr}" | ||
| begin_loc = copied_document.as_string().find(value_to_find) | ||
| return begin_loc, begin_loc | ||
|
|
||
| # otherwise, if replacing without appending | ||
| old_value = node[key[0]] | ||
| placeholder_value, value_to_find = ( | ||
| ( | ||
| {str(placeholder): placeholder_toml}, | ||
| f"{placeholder} = {placeholder_repr}", | ||
| ) | ||
| if isinstance(old_value, tomlkit.items.Table) | ||
| else (str(placeholder), placeholder_repr) | ||
| ) | ||
| node[key[0]] = placeholder_value | ||
| begin_loc = copied_document.as_string().find(value_to_find) | ||
| end_loc = begin_loc + len(old_value.as_string()) | ||
| return begin_loc, end_loc |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.