Skip to content

Commit 4925b31

Browse files
committed
chore: move import of re to top-level import
Signed-off-by: habeck <habeck@us.ibm.com>
1 parent f8aabf7 commit 4925b31

1 file changed

Lines changed: 1 addition & 9 deletions

File tree

cpex/framework/models.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# Standard
1313
import logging
1414
import os
15+
import re
1516
from enum import Enum, StrEnum
1617
from pathlib import Path
1718
from typing import Any, Generic, List, Optional, Self, TypeVar, Union
@@ -1655,9 +1656,6 @@ def validate_pypi_package(cls, pypi_package: str | None) -> str | None:
16551656
if not pypi_package.strip():
16561657
raise ValueError("PyPI package name cannot be empty or whitespace")
16571658

1658-
# Check for valid characters
1659-
import re
1660-
16611659
if not re.match(r"^[a-zA-Z0-9]([a-zA-Z0-9._-]*[a-zA-Z0-9])?$", pypi_package):
16621660
raise ValueError(
16631661
f"Invalid PyPI package name '{pypi_package}'. "
@@ -1690,8 +1688,6 @@ def validate_git_repository(cls, git_repository: str | None) -> str | None:
16901688
raise ValueError("Git repository URL cannot be empty or whitespace")
16911689

16921690
# Support common Git URL formats: https://, git://, ssh://, git@
1693-
import re
1694-
16951691
git_url_pattern = re.compile(
16961692
r"^(https?://|git://|git@)" r"[a-zA-Z0-9._-]+" r"(/|:)" r"[a-zA-Z0-9._/-]+" r"(\.git)?$"
16971693
)
@@ -1729,8 +1725,6 @@ def validate_git_branch_tag_commit(cls, git_branch_tag_commit: str | None) -> st
17291725

17301726
# Git refs can contain alphanumeric characters, hyphens, underscores, slashes, and periods
17311727
# Commit hashes are typically 7-40 hex characters
1732-
import re
1733-
17341728
if not re.match(r"^[a-zA-Z0-9._/-]+$", git_branch_tag_commit):
17351729
raise ValueError(
17361730
f"Invalid Git branch/tag/commit '{git_branch_tag_commit}'. "
@@ -1770,8 +1764,6 @@ def validate_version_constraint(cls, version_constraint: str | None) -> str | No
17701764
raise ValueError("Version constraint cannot be empty or whitespace")
17711765

17721766
# Validate semantic version constraint format (e.g., ">=1.0.0,<2.0.0", "~=1.2.3", "==1.0.0")
1773-
import re
1774-
17751767
# Pattern for version specifiers: operator + optional space + version number
17761768
version_pattern = re.compile(r"^(==|!=|<=|>=|<|>|~=|===)\s*" r"\d+(\.\d+)*" r"([a-zA-Z0-9._-]*)?$")
17771769

0 commit comments

Comments
 (0)