Rename cv.no_yaml_config_schema to cv.config_entry_only_config_schema (#93908)

* Rename cv.no_yaml_config_schema to cv.config_entry_only_config_schema

* ✏️
This commit is contained in:
Erik Montnemery 2023-06-01 13:15:48 +02:00 committed by GitHub
parent e05c04fadb
commit c1c319d4d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 33 additions and 27 deletions

View File

@ -12,7 +12,7 @@ from .const import DOMAIN
from .device import BroadlinkDevice
from .heartbeat import BroadlinkHeartbeat
CONFIG_SCHEMA = cv.no_yaml_config_schema(DOMAIN)
CONFIG_SCHEMA = cv.config_entry_only_config_schema(DOMAIN)
@dataclass

View File

@ -13,7 +13,7 @@ from .const import DATA_HASS_CONFIG, DOMAIN
PLATFORMS = [Platform.NOTIFY]
CONFIG_SCHEMA = cv.no_yaml_config_schema(DOMAIN)
CONFIG_SCHEMA = cv.config_entry_only_config_schema(DOMAIN)
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:

View File

@ -75,7 +75,7 @@ NAME_TO_WHITE_CHANNEL_TYPE: Final = {
option.name.lower(): option for option in WhiteChannelType
}
CONFIG_SCHEMA = cv.no_yaml_config_schema(DOMAIN)
CONFIG_SCHEMA = cv.config_entry_only_config_schema(DOMAIN)
@callback

View File

@ -44,7 +44,7 @@ SERVICE_SEND_TEXT_COMMAND_SCHEMA = vol.All(
},
)
CONFIG_SCHEMA = cv.no_yaml_config_schema(DOMAIN)
CONFIG_SCHEMA = cv.config_entry_only_config_schema(DOMAIN)
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:

View File

@ -21,7 +21,7 @@ from .services import async_setup_services
PLATFORMS = [Platform.NOTIFY, Platform.SENSOR]
CONFIG_SCHEMA = cv.no_yaml_config_schema(DOMAIN)
CONFIG_SCHEMA = cv.config_entry_only_config_schema(DOMAIN)
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:

View File

@ -12,7 +12,7 @@
"title": "Support for Python {current_python_version} is being removed",
"description": "Support for running Home Assistant in the current used Python version {current_python_version} is deprecated and will be removed in Home Assistant {breaks_in_ha_version}. Please upgrade Python to {required_python_version} to prevent your Home Assistant instance from breaking."
},
"integration_key_no_support": {
"config_entry_only": {
"title": "The {domain} integration does not support YAML configuration",
"description": "The {domain} integration does not support configuration via YAML file. You may not notice any obvious issues with the integration, but any configuration settings defined in YAML are not actually applied.\n\nTo resolve this:\n\n1. If you've not already done so, [set up the integration]({add_integration}).\n\n2. Remove `{domain}:` from your YAML configuration file.\n\n3. Restart Home Assistant."
}

View File

@ -26,7 +26,7 @@ from .utils import async_get_controller
_LOGGER = logging.getLogger(__name__)
CONFIG_SCHEMA = cv.no_yaml_config_schema(DOMAIN)
CONFIG_SCHEMA = cv.config_entry_only_config_schema(DOMAIN)
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:

View File

@ -16,7 +16,7 @@ __all__ = [
"filter_urllib3_logging",
]
CONFIG_SCHEMA = cv.no_yaml_config_schema(DOMAIN)
CONFIG_SCHEMA = cv.config_entry_only_config_schema(DOMAIN)
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:

View File

@ -58,7 +58,7 @@ from .view import PlexImageView
_LOGGER = logging.getLogger(__package__)
CONFIG_SCHEMA = cv.no_yaml_config_schema(DOMAIN)
CONFIG_SCHEMA = cv.config_entry_only_config_schema(DOMAIN)
def is_plex_media_id(media_content_id):

View File

@ -53,7 +53,7 @@ PS4_COMMAND_SCHEMA = vol.Schema(
PLATFORMS = [Platform.MEDIA_PLAYER]
CONFIG_SCHEMA = cv.no_yaml_config_schema(DOMAIN)
CONFIG_SCHEMA = cv.config_entry_only_config_schema(DOMAIN)
class PS4Data:

View File

@ -24,7 +24,7 @@ PLATFORMS = [Platform.SENSOR]
_LOGGER = logging.getLogger(__name__)
CONFIG_SCHEMA = cv.no_yaml_config_schema(DOMAIN)
CONFIG_SCHEMA = cv.config_entry_only_config_schema(DOMAIN)
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:

View File

@ -14,7 +14,7 @@ from .const import CONF_USER_KEY, DATA_HASS_CONFIG, DOMAIN
PLATFORMS = [Platform.NOTIFY]
CONFIG_SCHEMA = cv.no_yaml_config_schema(DOMAIN)
CONFIG_SCHEMA = cv.config_entry_only_config_schema(DOMAIN)
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:

View File

@ -1075,7 +1075,7 @@ def empty_config_schema(domain: str) -> Callable[[dict], dict]:
return validator
def no_yaml_config_schema(domain: str) -> Callable[[dict], dict]:
def config_entry_only_config_schema(domain: str) -> Callable[[dict], dict]:
"""Return a config schema which logs if attempted to setup from YAML."""
module = inspect.getmodule(inspect.stack(context=0)[2].frame)
@ -1098,11 +1098,11 @@ def no_yaml_config_schema(domain: str) -> Callable[[dict], dict]:
async_create_issue(
hass,
HOMEASSISTANT_DOMAIN,
f"integration_key_no_support_{domain}",
f"config_entry_only_{domain}",
is_fixable=False,
issue_domain=domain,
severity=IssueSeverity.ERROR,
translation_key="integration_key_no_support",
translation_key="config_entry_only",
translation_placeholders={
"domain": domain,
"add_integration": add_integration,

View File

@ -240,11 +240,11 @@ async def _async_setup_component(
async_create_issue(
hass,
HOMEASSISTANT_DOMAIN,
f"integration_key_no_support_{domain}",
f"config_entry_only{domain}",
is_fixable=False,
severity=IssueSeverity.ERROR,
issue_domain=domain,
translation_key="integration_key_no_support",
translation_key="config_entry_only",
translation_placeholders={"domain": domain},
)

View File

@ -1501,36 +1501,40 @@ def test_empty_schema_cant_find_module() -> None:
cv.empty_config_schema("test_domain")({"test_domain": {"foo": "bar"}})
def test_no_yaml_schema(hass: HomeAssistant, caplog: pytest.LogCaptureFixture) -> None:
"""Test no_yaml_config_schema."""
expected_issue = "integration_key_no_support_test_domain"
def test_config_entry_only_schema(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
) -> None:
"""Test config_entry_only_config_schema."""
expected_issue = "config_entry_only_test_domain"
expected_message = (
"The test_domain integration does not support YAML setup, please remove "
"it from your configuration"
)
issue_registry = ir.async_get(hass)
cv.no_yaml_config_schema("test_domain")({})
cv.config_entry_only_config_schema("test_domain")({})
assert expected_message not in caplog.text
assert not issue_registry.async_get_issue(HOMEASSISTANT_DOMAIN, expected_issue)
cv.no_yaml_config_schema("test_domain")({"test_domain": {}})
cv.config_entry_only_config_schema("test_domain")({"test_domain": {}})
assert expected_message in caplog.text
assert issue_registry.async_get_issue(HOMEASSISTANT_DOMAIN, expected_issue)
issue_registry.async_delete(HOMEASSISTANT_DOMAIN, expected_issue)
cv.no_yaml_config_schema("test_domain")({"test_domain": {"foo": "bar"}})
cv.config_entry_only_config_schema("test_domain")({"test_domain": {"foo": "bar"}})
assert expected_message in caplog.text
assert issue_registry.async_get_issue(HOMEASSISTANT_DOMAIN, expected_issue)
def test_no_yaml_schema_cant_find_module() -> None:
def test_config_entry_only_schema_cant_find_module() -> None:
"""Test if the current module cannot be inspected."""
with patch("inspect.getmodule", return_value=None):
cv.no_yaml_config_schema("test_domain")({"test_domain": {"foo": "bar"}})
cv.config_entry_only_config_schema("test_domain")(
{"test_domain": {"foo": "bar"}}
)
def test_no_yaml_schema_no_hass(
def test_config_entry_only_schema_no_hass(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
) -> None:
"""Test if the the hass context var is not set in our context."""
@ -1538,7 +1542,9 @@ def test_no_yaml_schema_no_hass(
"homeassistant.helpers.config_validation.async_get_hass",
side_effect=LookupError,
):
cv.no_yaml_config_schema("test_domain")({"test_domain": {"foo": "bar"}})
cv.config_entry_only_config_schema("test_domain")(
{"test_domain": {"foo": "bar"}}
)
expected_message = (
"The test_domain integration does not support YAML setup, please remove "
"it from your configuration"