]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
manager: codecheck fixes
authorAleš <ales.mrazek@nic.cz>
Thu, 27 Jan 2022 11:04:15 +0000 (12:04 +0100)
committerAleš Mrázek <ales.mrazek@nic.cz>
Fri, 8 Apr 2022 14:17:53 +0000 (16:17 +0200)
manager/knot_resolver_manager/datamodel/network_schema.py
manager/knot_resolver_manager/datamodel/types.py
manager/knot_resolver_manager/server.py

index 0e12079312f8d1c08a4c76d975a003db9768f276..f6af86c1d877464e01813864abf00cc1499e262c 100644 (file)
@@ -71,7 +71,7 @@ class ListenSchema(SchemaNode):
                     raise ValueError(
                         "The '@<port>' syntax must be used either for all or none of the IP addresses in the list."
                     )
-                port_set = True if addr.port else False
+                port_set = bool(addr.port)
         elif isinstance(origin.ip_address, IPAddressOptionalPort) and origin.ip_address.port and origin.port:
             raise ValueError("The port number is defined in two places ('port' option and '@<port>' syntax).")
         return origin.ip_address
@@ -86,7 +86,7 @@ class ListenSchema(SchemaNode):
                     raise ValueError(
                         "The '@<port>' syntax must be used either for all or none of the interface in the list."
                     )
-                port_set = True if intrfc.port else False
+                port_set = bool(intrfc.port)
         elif isinstance(origin.interface, InterfaceOptionalPort) and origin.interface.port and origin.port:
             raise ValueError("The port number is defined in two places ('port' option and '@<port>' syntax).")
         return origin.interface
index a35fcc96f96e79b6b0453f9cc1f7e7f1d07173c4..99fdee4f8c46bafd2d015386a9ed21265155e1c2 100644 (file)
@@ -193,6 +193,9 @@ class _StrCustomBase(CustomValueType):
 
     _value: str
 
+    def __int__(self) -> int:
+        raise ValueError("Can't convert string to an integer.")
+
     def __str__(self) -> str:
         return self._value
 
@@ -227,6 +230,7 @@ class _IntRangeBase(_IntCustomBase):
     _max: int
 
     def __init__(self, source_value: Any, object_path: str = "/") -> None:
+        super().__init__(source_value)
         if isinstance(source_value, int):
             if not self._min <= source_value <= self._max:
                 raise SchemaException(
@@ -514,6 +518,7 @@ class IPAddressOptionalPort(_StrCustomBase):
     port: Optional[PortNumber] = None
 
     def __init__(self, source_value: Any, object_path: str = "/") -> None:
+        super().__init__(source_value)
         if isinstance(source_value, str):
             parts = source_value.split("@")
             if 0 < len(parts) < 3:
index 50eda8e9936207c06a333d865c716430dc827b08..102f4bcf6efc728726feda8308db393e038a8765 100644 (file)
@@ -227,7 +227,7 @@ class Server:
                 nsite = web.TCPSite(self.runner, str(mgn.ip_address.addr), int(mgn.ip_address.port))
                 logger.info(f"Starting API HTTP server on http://{mgn.ip_address.addr}:{mgn.ip_address.port}")
             else:
-                raise KresManagerException(f"Requested API on unsupported configuration format.")
+                raise KresManagerException("Requested API on unsupported configuration format.")
             await nsite.start()
 
             # stop the old listen