Skip to content

Commit

Permalink
allow all requirements specs
Browse files Browse the repository at this point in the history
  • Loading branch information
mpw96 committed Aug 30, 2024
1 parent c47b37a commit d15cd27
Showing 1 changed file with 1 addition and 26 deletions.
27 changes: 1 addition & 26 deletions script/hassfest/requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import sys
from typing import Any

from awesomeversion import AwesomeVersion, AwesomeVersionStrategy
from tqdm import tqdm

import homeassistant.util.package as pkg_util
Expand All @@ -26,7 +25,6 @@
r"^(?:--.+\s)?([-_,\.\w\d\[\]]+)(==|>=|<=|~=|!=|<|>|===)*(.*)$"
)
PIP_REGEX = re.compile(r"^(--.+\s)?([-_\.\w\d]+.*(?:==|>=|<=|~=|!=|<|>|===)?.*$)")
PIP_VERSION_RANGE_SEPARATOR = re.compile(r"^(==|>=|<=|~=|!=|<|>|===)?(.*)$")

IGNORE_STANDARD_LIBRARY_VIOLATIONS = {
# Integrations which have standard library requirements.
Expand Down Expand Up @@ -59,20 +57,13 @@ def validate_requirements_format(integration: Integration) -> bool:
start_errors = len(integration.errors)

for req in integration.requirements:
if " " in req:
integration.add_error(
"requirements",
f'Requirement "{req}" contains a space',
)
continue

if not (match := PACKAGE_REGEX.match(req)):
integration.add_error(
"requirements",
f'Requirement "{req}" does not match package regex pattern',
)
continue
pkg, sep, version = match.groups()
_, sep, _ = match.groups()

if integration.core and sep != "==":
integration.add_error(
Expand All @@ -81,22 +72,6 @@ def validate_requirements_format(integration: Integration) -> bool:
)
continue

if not version:
continue

for part in version.split(";", 1)[0].split(","):
version_part = PIP_VERSION_RANGE_SEPARATOR.match(part)
if (
version_part
and AwesomeVersion(version_part.group(2)).strategy
== AwesomeVersionStrategy.UNKNOWN
):
integration.add_error(
"requirements",
f"Unable to parse package version ({version}) for {pkg}.",
)
continue

return len(integration.errors) == start_errors


Expand Down

0 comments on commit d15cd27

Please sign in to comment.