|
12 | 12 | # Standard |
13 | 13 | import logging |
14 | 14 | import os |
| 15 | +import re |
15 | 16 | from enum import Enum, StrEnum |
16 | 17 | from pathlib import Path |
17 | 18 | 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: |
1655 | 1656 | if not pypi_package.strip(): |
1656 | 1657 | raise ValueError("PyPI package name cannot be empty or whitespace") |
1657 | 1658 |
|
1658 | | - # Check for valid characters |
1659 | | - import re |
1660 | | - |
1661 | 1659 | if not re.match(r"^[a-zA-Z0-9]([a-zA-Z0-9._-]*[a-zA-Z0-9])?$", pypi_package): |
1662 | 1660 | raise ValueError( |
1663 | 1661 | f"Invalid PyPI package name '{pypi_package}'. " |
@@ -1690,8 +1688,6 @@ def validate_git_repository(cls, git_repository: str | None) -> str | None: |
1690 | 1688 | raise ValueError("Git repository URL cannot be empty or whitespace") |
1691 | 1689 |
|
1692 | 1690 | # Support common Git URL formats: https://, git://, ssh://, git@ |
1693 | | - import re |
1694 | | - |
1695 | 1691 | git_url_pattern = re.compile( |
1696 | 1692 | r"^(https?://|git://|git@)" r"[a-zA-Z0-9._-]+" r"(/|:)" r"[a-zA-Z0-9._/-]+" r"(\.git)?$" |
1697 | 1693 | ) |
@@ -1729,8 +1725,6 @@ def validate_git_branch_tag_commit(cls, git_branch_tag_commit: str | None) -> st |
1729 | 1725 |
|
1730 | 1726 | # Git refs can contain alphanumeric characters, hyphens, underscores, slashes, and periods |
1731 | 1727 | # Commit hashes are typically 7-40 hex characters |
1732 | | - import re |
1733 | | - |
1734 | 1728 | if not re.match(r"^[a-zA-Z0-9._/-]+$", git_branch_tag_commit): |
1735 | 1729 | raise ValueError( |
1736 | 1730 | 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 |
1770 | 1764 | raise ValueError("Version constraint cannot be empty or whitespace") |
1771 | 1765 |
|
1772 | 1766 | # Validate semantic version constraint format (e.g., ">=1.0.0,<2.0.0", "~=1.2.3", "==1.0.0") |
1773 | | - import re |
1774 | | - |
1775 | 1767 | # Pattern for version specifiers: operator + optional space + version number |
1776 | 1768 | version_pattern = re.compile(r"^(==|!=|<=|>=|<|>|~=|===)\s*" r"\d+(\.\d+)*" r"([a-zA-Z0-9._-]*)?$") |
1777 | 1769 |
|
|
0 commit comments