manifestv2: attempt to fix mypy errors é_è

This commit is contained in:
Alexandre Aubin 2022-09-02 00:20:44 +02:00
parent e9190a6bd6
commit 0610a1808b
2 changed files with 15 additions and 4 deletions

View file

@ -22,7 +22,8 @@ import os
import copy
import shutil
import random
from typing import Dict, Any
from typing import Optional, Dict, List, Union, Any, Mapping, Callable, no_type_check
from moulinette.utils.process import check_output
from moulinette.utils.log import getActionLogger
@ -123,6 +124,8 @@ class AppResourceManager:
class AppResource:
default_properties: Dict[str, Any] = None
def __init__(self, properties: Dict[str, Any], app: str, manager=None):
self.app = app
@ -199,7 +202,7 @@ class PermissionsResource(AppResource):
default_properties = {
}
default_perm_properties = {
default_perm_properties: Dict[str, Any] = {
"url": None,
"additional_urls": [],
"auth_header": True,
@ -208,6 +211,8 @@ class PermissionsResource(AppResource):
"protected": False,
}
permissions: Dict[str, Dict[str, Any]] = {}
def __init__(self, properties: Dict[str, Any], *args, **kwargs):
# FIXME : if url != None, we should check that there's indeed a domain/path defined ? ie that app is a webapp
@ -362,6 +367,7 @@ class SystemuserAppResource(AppResource):
# fi
#
@no_type_check
class InstalldirAppResource(AppResource):
"""
is_provisioned -> setting install_dir exists + /dir/ exists
@ -427,6 +433,7 @@ class InstalldirAppResource(AppResource):
# FIXME : in fact we should delete settings to be consistent
@no_type_check
class DatadirAppResource(AppResource):
"""
is_provisioned -> setting data_dir exists + /dir/ exists
@ -510,6 +517,7 @@ class DatadirAppResource(AppResource):
# return
#
@no_type_check
class AptDependenciesAppResource(AppResource):
"""
is_provisioned -> package __APP__-ynh-deps exists (ideally should check the Depends: but hmgn)
@ -583,6 +591,8 @@ class PortsResource(AppResource):
"fixed": False, # FIXME: implement logic. Corresponding to wether or not the port is "fixed" or any random port is ok
}
ports: Dict[str, Dict[str, Any]]
def __init__(self, properties: Dict[str, Any], *args, **kwargs):
if "main" not in properties:

View file

@ -21,6 +21,7 @@
import re
import os
import logging
from typing import Union
from moulinette.utils.process import check_output
from yunohost.utils.error import YunohostError
@ -74,11 +75,11 @@ def human_to_binary(size: str) -> int:
raise YunohostError(f"Invalid size suffix '{suffix}', expected one of {symbols}")
try:
size = float(size)
size_ = float(size)
except Exception:
raise YunohostError(f"Failed to convert size {size} to float")
return size * factor[suffix]
return int(size_ * factor[suffix])
def binary_to_human(n: int) -> str: