Skip to content

Commit

Permalink
Deduplicate some logic
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleFromNVIDIA committed May 17, 2024
1 parent 8f72751 commit 30473d7
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions src/rapids_pre_commit_hooks/pyproject_license.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,12 @@ def find_value_location(document, key, append):
def check_pyproject_license(linter, args):
document = tomlkit.loads(linter.content)
try:
add_project_table = True
project_table = document["project"]
except tomlkit.exceptions.NonExistentKey:
loc = (len(linter.content), len(linter.content))
linter.add_warning(
loc, f'add project.license with value {{ text = "{RAPIDS_LICENSE}" }}'
).add_replacement(
loc,
"[project]\nlicense = "
f"{{ text = {tomlkit.string(RAPIDS_LICENSE).as_string()} }}\n",
)
return

try:
add_project_table = project_table.is_super_table()
license_value = project_table["license"]["text"]
except tomlkit.exceptions.NonExistentKey:
if project_table.is_super_table():
if add_project_table:
loc = (len(linter.content), len(linter.content))
linter.add_warning(
loc, f'add project.license with value {{ text = "{RAPIDS_LICENSE}" }}'
Expand Down

0 comments on commit 30473d7

Please sign in to comment.