Enable strict typing for minecraft_server (#107262)

This commit is contained in:
Marc Mueller
2024-01-05 18:38:31 +01:00
committed by GitHub
parent 3a94dd6578
commit de72bbfaad
5 changed files with 25 additions and 5 deletions

View File

@ -263,6 +263,7 @@ homeassistant.components.media_source.*
homeassistant.components.metoffice.*
homeassistant.components.mikrotik.*
homeassistant.components.min_max.*
homeassistant.components.minecraft_server.*
homeassistant.components.mjpeg.*
homeassistant.components.modbus.*
homeassistant.components.modem_callerid.*

View File

@ -128,7 +128,7 @@ class MinecraftServer:
self, status_response: JavaStatusResponse
) -> MinecraftServerData:
"""Extract Java Edition server data out of status response."""
players_list = []
players_list: list[str] = []
if players := status_response.players.sample:
for player in players:

View File

@ -1,5 +1,8 @@
"""Config flow for Minecraft Server integration."""
from __future__ import annotations
import logging
from typing import Any
import voluptuous as vol
@ -20,9 +23,11 @@ class MinecraftServerConfigFlow(ConfigFlow, domain=DOMAIN):
VERSION = 3
async def async_step_user(self, user_input=None) -> FlowResult:
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
"""Handle the initial step."""
errors = {}
errors: dict[str, str] = {}
if user_input:
address = user_input[CONF_ADDRESS]
@ -57,7 +62,11 @@ class MinecraftServerConfigFlow(ConfigFlow, domain=DOMAIN):
# form filled with user_input and eventually with errors otherwise).
return self._show_config_form(user_input, errors)
def _show_config_form(self, user_input=None, errors=None) -> FlowResult:
def _show_config_form(
self,
user_input: dict[str, Any] | None = None,
errors: dict[str, str] | None = None,
) -> FlowResult:
"""Show the setup form to the user."""
if user_input is None:
user_input = {}

View File

@ -61,7 +61,7 @@ def get_extra_state_attributes_players_list(
data: MinecraftServerData,
) -> dict[str, list[str]]:
"""Return players list as extra state attributes, if available."""
extra_state_attributes = {}
extra_state_attributes: dict[str, Any] = {}
players_list = data.players_list
if players_list is not None and len(players_list) != 0:

View File

@ -2391,6 +2391,16 @@ disallow_untyped_defs = true
warn_return_any = true
warn_unreachable = true
[mypy-homeassistant.components.minecraft_server.*]
check_untyped_defs = true
disallow_incomplete_defs = true
disallow_subclassing_any = true
disallow_untyped_calls = true
disallow_untyped_decorators = true
disallow_untyped_defs = true
warn_return_any = true
warn_unreachable = true
[mypy-homeassistant.components.mjpeg.*]
check_untyped_defs = true
disallow_incomplete_defs = true