Improve standard library violation check in hassfest (#115752)
* Improve standard library violation check in hassfest * Improve prints * Improve error messagepull/115124/head^2
parent
cb16465539
commit
5c018f6ffc
|
@ -28,16 +28,9 @@ PACKAGE_REGEX = re.compile(
|
||||||
PIP_REGEX = re.compile(r"^(--.+\s)?([-_\.\w\d]+.*(?:==|>=|<=|~=|!=|<|>|===)?.*$)")
|
PIP_REGEX = re.compile(r"^(--.+\s)?([-_\.\w\d]+.*(?:==|>=|<=|~=|!=|<|>|===)?.*$)")
|
||||||
PIP_VERSION_RANGE_SEPARATOR = re.compile(r"^(==|>=|<=|~=|!=|<|>|===)?(.*)$")
|
PIP_VERSION_RANGE_SEPARATOR = re.compile(r"^(==|>=|<=|~=|!=|<|>|===)?(.*)$")
|
||||||
|
|
||||||
IGNORE_VIOLATIONS = {
|
IGNORE_STANDARD_LIBRARY_VIOLATIONS = {
|
||||||
# Still has standard library requirements.
|
# Integrations which have standard library requirements.
|
||||||
"acmeda",
|
|
||||||
"blink",
|
|
||||||
"electrasmart",
|
"electrasmart",
|
||||||
"ezviz",
|
|
||||||
"hdmi_cec",
|
|
||||||
"juicenet",
|
|
||||||
"lupusec",
|
|
||||||
"rainbird",
|
|
||||||
"slide",
|
"slide",
|
||||||
"suez_water",
|
"suez_water",
|
||||||
}
|
}
|
||||||
|
@ -113,10 +106,6 @@ def validate_requirements(integration: Integration) -> None:
|
||||||
if not validate_requirements_format(integration):
|
if not validate_requirements_format(integration):
|
||||||
return
|
return
|
||||||
|
|
||||||
# Some integrations have not been fixed yet so are allowed to have violations.
|
|
||||||
if integration.domain in IGNORE_VIOLATIONS:
|
|
||||||
return
|
|
||||||
|
|
||||||
integration_requirements = set()
|
integration_requirements = set()
|
||||||
integration_packages = set()
|
integration_packages = set()
|
||||||
for req in integration.requirements:
|
for req in integration.requirements:
|
||||||
|
@ -150,12 +139,34 @@ def validate_requirements(integration: Integration) -> None:
|
||||||
return
|
return
|
||||||
|
|
||||||
# Check for requirements incompatible with standard library.
|
# Check for requirements incompatible with standard library.
|
||||||
|
standard_library_violations = set()
|
||||||
for req in all_integration_requirements:
|
for req in all_integration_requirements:
|
||||||
if req in sys.stdlib_module_names:
|
if req in sys.stdlib_module_names:
|
||||||
integration.add_error(
|
standard_library_violations.add(req)
|
||||||
"requirements",
|
|
||||||
f"Package {req} is not compatible with the Python standard library",
|
if (
|
||||||
)
|
standard_library_violations
|
||||||
|
and integration.domain not in IGNORE_STANDARD_LIBRARY_VIOLATIONS
|
||||||
|
):
|
||||||
|
integration.add_error(
|
||||||
|
"requirements",
|
||||||
|
(
|
||||||
|
f"Package {req} has dependencies {standard_library_violations} which "
|
||||||
|
"are not compatible with the Python standard library"
|
||||||
|
),
|
||||||
|
)
|
||||||
|
elif (
|
||||||
|
not standard_library_violations
|
||||||
|
and integration.domain in IGNORE_STANDARD_LIBRARY_VIOLATIONS
|
||||||
|
):
|
||||||
|
integration.add_error(
|
||||||
|
"requirements",
|
||||||
|
(
|
||||||
|
f"Integration {integration.domain} no longer has requirements which are"
|
||||||
|
" incompatible with the Python standard library, remove it from "
|
||||||
|
"IGNORE_STANDARD_LIBRARY_VIOLATIONS"
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@cache
|
@cache
|
||||||
|
|
Loading…
Reference in New Issue