mirror of
https://github.com/home-assistant/core.git
synced 2025-06-25 01:21:51 +02:00
Enable strict typing for minecraft_server (#107262)
This commit is contained in:
@ -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.*
|
||||
|
@ -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:
|
||||
|
@ -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 = {}
|
||||
|
@ -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:
|
||||
|
10
mypy.ini
10
mypy.ini
@ -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
|
||||
|
Reference in New Issue
Block a user