python 3.10 type definitions 50/11950/1
authorMartin Skorupski <martin.skorupski@highstreet-technologies.com>
Sun, 22 Oct 2023 09:56:08 +0000 (11:56 +0200)
committerMartin Skorupski <martin.skorupski@highstreet-technologies.com>
Sun, 22 Oct 2023 09:56:20 +0000 (11:56 +0200)
- deprecated typings
- formatting
- spelling

Issue-ID: OAM-370
Change-Id: I844de77809f9b471aa7b80b54ca28786fac281c1
Signed-off-by: Martin Skorupski <martin.skorupski@highstreet-technologies.com>
code/network-generator/controller/parameter_validator.py

index 0375498..365a5f8 100644 (file)
@@ -19,7 +19,6 @@ Module containing a class for parameter validation
 import os
 import os.path
 import json
 import os
 import os.path
 import json
-from typing import Dict, Union
 import jsonschema
 
 
 import jsonschema
 
 
@@ -30,10 +29,12 @@ class ParameterValidator:
 
     __config_file: str = "config.json"
     __configuration: dict = {}
 
     __config_file: str = "config.json"
     __configuration: dict = {}
-    __configuration_schema_file: str = os.path.dirname(os.path.realpath(
-        __file__)) + "/../model/jsonSchema/configuration.schema.json"
+    __configuration_schema_file: str = (
+        os.path.dirname(os.path.realpath(__file__))
+        + "/../model/jsonSchema/configuration.schema.json"
+    )
     __config_schema: dict = {}
     __config_schema: dict = {}
-    __error_messsage: str = ""
+    __error_message: str = ""
     __is_valid: bool = False
 
     # constructor
     __is_valid: bool = False
 
     # constructor
@@ -55,7 +56,8 @@ class ParameterValidator:
             with open(self.__configuration_schema_file) as content:
                 self.__config_schema = json.load(content)
         self.__is_valid = self.__is_json_valid(
             with open(self.__configuration_schema_file) as content:
                 self.__config_schema = json.load(content)
         self.__is_valid = self.__is_json_valid(
-            self.__configuration, self.__config_schema)
+            self.__configuration, self.__config_schema
+        )
 
     def configuration_file(self) -> str:
         """
 
     def configuration_file(self) -> str:
         """
@@ -64,17 +66,17 @@ class ParameterValidator:
         """
         return self.__config_file
 
         """
         return self.__config_file
 
-    def configuration(self) -> Dict[str, Union[str, Dict[str, int]]]:
+    def configuration(self) -> dict[str, str | dict[str, int]]:
         """
         Getter for the configuration as input parameter.
         """
         Getter for the configuration as input parameter.
-        :return Init configuration as Dict.
+        :return Init configuration as dict.
         """
         return self.__configuration
 
     def is_valid(self) -> bool:
         """
         Getter for the validation result.
         """
         return self.__configuration
 
     def is_valid(self) -> bool:
         """
         Getter for the validation result.
-        :return Init configuration as Dict.
+        :return Init configuration as dict.
         """
         return self.__is_valid
 
         """
         return self.__is_valid
 
@@ -82,9 +84,9 @@ class ParameterValidator:
         """
         Getter for the error message after validation process or an empty sting,
         when configuration is valid.
         """
         Getter for the error message after validation process or an empty sting,
         when configuration is valid.
-        :return Errormessage as string.
+        :return Error message as string.
         """
         """
-        return self.__error_messsage
+        return self.__error_message
 
     # private
 
 
     # private
 
@@ -94,8 +96,8 @@ class ParameterValidator:
         """
         try:
             jsonschema.validate(instance=json_data, schema=json_schema)
         """
         try:
             jsonschema.validate(instance=json_data, schema=json_schema)
-            self.__error_messsage = ""
+            self.__error_message = ""
         except jsonschema.exceptions.ValidationError as err:
         except jsonschema.exceptions.ValidationError as err:
-            self.__error_messsage = err
+            self.__error_message = err
             return False
         return True
             return False
         return True