Skip to content

Commit

Permalink
string -> re
Browse files Browse the repository at this point in the history
  • Loading branch information
ewdurbin committed Sep 4, 2024
1 parent c1530bd commit 2e7cfb8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/packaging/licenses/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@
#######################################################################################
from __future__ import annotations

import string
import re
from typing import cast

from packaging.licenses.spdx import EXCEPTIONS, LICENSES

license_ref_allowed = string.ascii_letters + string.digits + "." + "-"
license_ref_allowed = re.compile("^[A-Za-z0-9.-]*$")


def normalize_license_expression(raw_license_expression: str) -> str | None:
Expand Down Expand Up @@ -107,7 +107,7 @@ def normalize_license_expression(raw_license_expression: str) -> str | None:
suffix = ""

if final_token.startswith("licenseref-"):
if not all(c in license_ref_allowed for c in final_token):
if not license_ref_allowed.match(final_token):
message = f"invalid licenseref: {final_token}"
raise ValueError(message)
normalized_tokens.append(license_refs[final_token] + suffix)
Expand Down

0 comments on commit 2e7cfb8

Please sign in to comment.