mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Enable strict typing for minecraft_server (#107262)
This commit is contained in:
parent
3a94dd6578
commit
de72bbfaad
@ -263,6 +263,7 @@ homeassistant.components.media_source.*
|
|||||||
homeassistant.components.metoffice.*
|
homeassistant.components.metoffice.*
|
||||||
homeassistant.components.mikrotik.*
|
homeassistant.components.mikrotik.*
|
||||||
homeassistant.components.min_max.*
|
homeassistant.components.min_max.*
|
||||||
|
homeassistant.components.minecraft_server.*
|
||||||
homeassistant.components.mjpeg.*
|
homeassistant.components.mjpeg.*
|
||||||
homeassistant.components.modbus.*
|
homeassistant.components.modbus.*
|
||||||
homeassistant.components.modem_callerid.*
|
homeassistant.components.modem_callerid.*
|
||||||
|
@ -128,7 +128,7 @@ class MinecraftServer:
|
|||||||
self, status_response: JavaStatusResponse
|
self, status_response: JavaStatusResponse
|
||||||
) -> MinecraftServerData:
|
) -> MinecraftServerData:
|
||||||
"""Extract Java Edition server data out of status response."""
|
"""Extract Java Edition server data out of status response."""
|
||||||
players_list = []
|
players_list: list[str] = []
|
||||||
|
|
||||||
if players := status_response.players.sample:
|
if players := status_response.players.sample:
|
||||||
for player in players:
|
for player in players:
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
"""Config flow for Minecraft Server integration."""
|
"""Config flow for Minecraft Server integration."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
@ -20,9 +23,11 @@ class MinecraftServerConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
|
|
||||||
VERSION = 3
|
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."""
|
"""Handle the initial step."""
|
||||||
errors = {}
|
errors: dict[str, str] = {}
|
||||||
|
|
||||||
if user_input:
|
if user_input:
|
||||||
address = user_input[CONF_ADDRESS]
|
address = user_input[CONF_ADDRESS]
|
||||||
@ -57,7 +62,11 @@ class MinecraftServerConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
# form filled with user_input and eventually with errors otherwise).
|
# form filled with user_input and eventually with errors otherwise).
|
||||||
return self._show_config_form(user_input, errors)
|
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."""
|
"""Show the setup form to the user."""
|
||||||
if user_input is None:
|
if user_input is None:
|
||||||
user_input = {}
|
user_input = {}
|
||||||
|
@ -61,7 +61,7 @@ def get_extra_state_attributes_players_list(
|
|||||||
data: MinecraftServerData,
|
data: MinecraftServerData,
|
||||||
) -> dict[str, list[str]]:
|
) -> dict[str, list[str]]:
|
||||||
"""Return players list as extra state attributes, if available."""
|
"""Return players list as extra state attributes, if available."""
|
||||||
extra_state_attributes = {}
|
extra_state_attributes: dict[str, Any] = {}
|
||||||
players_list = data.players_list
|
players_list = data.players_list
|
||||||
|
|
||||||
if players_list is not None and len(players_list) != 0:
|
if players_list is not None and len(players_list) != 0:
|
||||||
|
10
mypy.ini
10
mypy.ini
@ -2391,6 +2391,16 @@ disallow_untyped_defs = true
|
|||||||
warn_return_any = true
|
warn_return_any = true
|
||||||
warn_unreachable = 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.*]
|
[mypy-homeassistant.components.mjpeg.*]
|
||||||
check_untyped_defs = true
|
check_untyped_defs = true
|
||||||
disallow_incomplete_defs = true
|
disallow_incomplete_defs = true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user