mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
configpanel: quick fix option typing
This commit is contained in:
parent
2f4c88ec55
commit
6953a8bf15
1 changed files with 10 additions and 3 deletions
|
@ -21,7 +21,7 @@ import os
|
||||||
import re
|
import re
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from logging import getLogger
|
from logging import getLogger
|
||||||
from typing import TYPE_CHECKING, Any, Iterator, Literal, Sequence, Type, Union
|
from typing import TYPE_CHECKING, Any, Iterator, Literal, Sequence, Type, Union, cast
|
||||||
|
|
||||||
from pydantic import BaseModel, Extra, validator
|
from pydantic import BaseModel, Extra, validator
|
||||||
|
|
||||||
|
@ -100,7 +100,9 @@ class SectionModel(ContainerModel, OptionsModel):
|
||||||
**kwargs,
|
**kwargs,
|
||||||
) -> None:
|
) -> None:
|
||||||
options = self.options_dict_to_list(kwargs, optional=optional)
|
options = self.options_dict_to_list(kwargs, optional=optional)
|
||||||
is_action_section = any([option["type"] == OptionType.button for option in options])
|
is_action_section = any(
|
||||||
|
[option["type"] == OptionType.button for option in options]
|
||||||
|
)
|
||||||
ContainerModel.__init__(
|
ContainerModel.__init__(
|
||||||
self,
|
self,
|
||||||
id=id,
|
id=id,
|
||||||
|
@ -370,7 +372,9 @@ class ConfigPanel:
|
||||||
for opt in section["options"]:
|
for opt in section["options"]:
|
||||||
instance = self.config.get_option(opt["id"])
|
instance = self.config.get_option(opt["id"])
|
||||||
if isinstance(instance, BaseInputOption):
|
if isinstance(instance, BaseInputOption):
|
||||||
opt["value"] = instance.normalize(self.form[opt["id"]], instance)
|
opt["value"] = instance.normalize(
|
||||||
|
self.form[opt["id"]], instance
|
||||||
|
)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
result = OrderedDict()
|
result = OrderedDict()
|
||||||
|
@ -381,6 +385,9 @@ class ConfigPanel:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for option in section.options:
|
for option in section.options:
|
||||||
|
# FIXME not sure why option resolves as possibly `None`
|
||||||
|
option = cast(AnyOption, option)
|
||||||
|
|
||||||
if mode == "export":
|
if mode == "export":
|
||||||
if isinstance(option, BaseInputOption):
|
if isinstance(option, BaseInputOption):
|
||||||
result[option.id] = self.form[option.id]
|
result[option.id] = self.form[option.id]
|
||||||
|
|
Loading…
Add table
Reference in a new issue