]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
manager: lint: satisfy newer pylint
authorAleš Mrázek <ales.mrazek@nic.cz>
Fri, 19 May 2023 14:12:58 +0000 (16:12 +0200)
committerAleš Mrázek <ales.mrazek@nic.cz>
Tue, 30 May 2023 13:46:47 +0000 (15:46 +0200)
16 files changed:
manager/knot_resolver_manager/__main__.py
manager/knot_resolver_manager/cli/cmd/convert.py
manager/knot_resolver_manager/cli/cmd/validate.py
manager/knot_resolver_manager/cli/command.py
manager/knot_resolver_manager/compat/asyncio.py
manager/knot_resolver_manager/datamodel/types/files.py
manager/knot_resolver_manager/datamodel/types/types.py
manager/knot_resolver_manager/kresd_controller/supervisord/__init__.py
manager/knot_resolver_manager/server.py
manager/knot_resolver_manager/statistics.py
manager/knot_resolver_manager/utils/modeling/base_schema.py
manager/knot_resolver_manager/utils/modeling/base_value_type.py
manager/knot_resolver_manager/utils/modeling/query.py
manager/knot_resolver_manager/utils/modeling/renaming.py
manager/knot_resolver_manager/utils/modeling/types.py
manager/knot_resolver_manager/utils/requests.py

index c4cc866b7f9780828eaf08bf1c52c5108dc995cf..89eabd5640b808ff1b25b5d233c2c6b685eb9785 100644 (file)
@@ -1,11 +1,13 @@
 # pylint: skip-file
 # flake8: noqa
 
+
 def run():
     # throws nice syntax error on old Python versions:
-    0_0  # Python >= 3.6 required
+    0_0  # Python >= 3.7 required
 
     from knot_resolver_manager import main
+
     main.main()
 
 
index b7908b0a72d93dac8b8cb90f05840fa9624f1b04..ac92185918bb7ed8966edd74358031ba8776c837 100644 (file)
@@ -41,7 +41,6 @@ class ConvertCommand(Command):
         return {}
 
     def run(self, args: CommandArgs) -> None:
-
         with open(self.input_file, "r") as f:
             data = f.read()
 
index f2bd4c7789f6675e5353cda108319068d2c96d08..3c2b081e9a268086c735f240664018e7644781f0 100644 (file)
@@ -34,7 +34,6 @@ class ValidateCommand(Command):
         return {}
 
     def run(self, args: CommandArgs) -> None:
-
         if self.input_file:
             with open(self.input_file, "r") as f:
                 data = f.read()
index 207f910802d440f8c9a82e5e4aecf066f46c82c4..6533de46cbd1fa88ad41e473a7b08236db5db8ad 100644 (file)
@@ -1,5 +1,5 @@
 import argparse
-from abc import ABC, abstractmethod
+from abc import ABC, abstractmethod  # pylint: disable=[no-name-in-module]
 from pathlib import Path
 from typing import Dict, List, Optional, Tuple, Type, TypeVar
 from urllib.parse import quote
@@ -53,7 +53,7 @@ class Command(ABC):
         raise NotImplementedError()
 
     @abstractmethod
-    def __init__(self, namespace: argparse.Namespace) -> None:
+    def __init__(self, namespace: argparse.Namespace) -> None:  # pylint: disable=[unused-argument]
         super().__init__()
 
     @abstractmethod
index cb1ca130bc218058e29858edb92d97f1ef9c6875..9362db3fd594ce55e167ab754f3f33a7fab17fe6 100644 (file)
@@ -47,11 +47,11 @@ def create_task(coro: Awaitable[T], name: Optional[str] = None) -> "asyncio.Task
     # version 3.8 and higher, call directly
     if sys.version_info.major >= 3 and sys.version_info.minor >= 8:
         # pylint: disable=unexpected-keyword-arg
-        return asyncio.create_task(coro, name=name)  # type: ignore[attr-defined]
+        return asyncio.create_task(coro, name=name)  # type: ignore[attr-defined,arg-type,call-arg]
 
     # version 3.7 and higher, call directly without the name argument
     if sys.version_info.major >= 3 and sys.version_info.minor >= 8:
-        return asyncio.create_task(coro)  # type: ignore[attr-defined]
+        return asyncio.create_task(coro)  # type: ignore[attr-defined,arg-type]
 
     # earlier versions, use older function
     else:
@@ -70,7 +70,7 @@ def run(coro: Awaitable[T], debug: Optional[bool] = None) -> T:
     # version 3.7 and higher, call directly
     # disabled due to incompatibilities
     if sys.version_info.major >= 3 and sys.version_info.minor >= 7:
-        return asyncio.run(coro, debug=debug)  # type: ignore[attr-defined]
+        return asyncio.run(coro, debug=debug)  # type: ignore[attr-defined,arg-type]
 
     # earlier versions, use backported version of the function
     if events._get_running_loop() is not None:  # pylint: disable=protected-access
index 5811dbcde3b7d5d064278d87402edbc69075036f..6fff73aec0555bd6fe4c6df0339bd3ccb92e2423 100644 (file)
@@ -16,13 +16,11 @@ class UncheckedPath(BaseValueType):
     def __init__(
         self, source_value: Any, parents: Tuple["UncheckedPath", ...] = tuple(), object_path: str = "/"
     ) -> None:
-
         super().__init__(source_value, object_path=object_path)
         self._object_path: str = object_path
         self._parents: Tuple[UncheckedPath, ...] = parents
 
         if isinstance(source_value, str):
-
             # we do not load global validation context if the path is absolute
             # this prevents errors when constructing defaults in the schema
             if source_value.startswith("/"):
index 02614e22644f821df458e74ef4698f4b41d7cd59..086235351d12765d48da4435be3d105231697012 100644 (file)
@@ -37,7 +37,7 @@ class PortNumber(IntRangeBase):
 
 
 class SizeUnit(UnitBase):
-    _units = {"B": 1, "K": 1024, "M": 1024 ** 2, "G": 1024 ** 3}
+    _units = {"B": 1, "K": 1024, "M": 1024**2, "G": 1024**3}
 
     def bytes(self) -> int:
         return self._value
index 7229254ed6eaecaf21cc38347ae69fc1128d0b4b..d246822da19ccacb4d256f7fbc2740ed41d959f4 100644 (file)
@@ -1,5 +1,5 @@
 import logging
-from os import kill
+from os import kill  # pylint: disable=[no-name-in-module]
 from pathlib import Path
 from typing import Any, Dict, Iterable, NoReturn, Optional, Union, cast
 from xmlrpc.client import Fault, ServerProxy
index 1999c92ddafa0623e19d43b1d53786d196c6d285..80e3b61ddfd5762ec4a619a4dba835db8e9ff15b 100644 (file)
@@ -109,7 +109,6 @@ class Server:
         return Result.ok(None)
 
     async def _reload_config(self) -> None:
-
         if self._config_path is None:
             logger.warning("The manager was started with inlined configuration - can't reload")
         else:
index d21a3915d56654cec764e71836473f7d63116456..069f4e75ffb4f1edf6bf43f0a07769052f6cc321 100644 (file)
@@ -5,13 +5,8 @@ from typing import TYPE_CHECKING, Any, Awaitable, Callable, Dict, Generator, Lis
 
 from prometheus_client import Histogram, exposition  # type: ignore
 from prometheus_client.bridge.graphite import GraphiteBridge  # type: ignore
-from prometheus_client.core import (  # type: ignore
-    REGISTRY,
-    CounterMetricFamily,
-    GaugeMetricFamily,
-    HistogramMetricFamily,
-    Metric,
-)
+from prometheus_client.core import GaugeMetricFamily  # type: ignore
+from prometheus_client.core import REGISTRY, CounterMetricFamily, HistogramMetricFamily, Metric
 
 from knot_resolver_manager import compat
 from knot_resolver_manager.config_store import ConfigStore, only_on_real_changes
index ca8d196d97d8d56e1b4ce3bb1679c17169b7bd12..31cea7cc40d08735e5f4e3a3a0b5d91e6c557b89 100644 (file)
@@ -1,6 +1,6 @@
 import enum
 import inspect
-from abc import ABC, abstractmethod
+from abc import ABC, abstractmethod  # pylint: disable=[no-name-in-module]
 from typing import Any, Callable, Dict, Generic, List, Optional, Set, Tuple, Type, TypeVar, Union, cast
 
 import yaml
@@ -83,6 +83,7 @@ class _lazy_default(Generic[T], Serializable):
     """
 
     def __init__(self, constructor: Callable[..., T], *args: Any, **kwargs: Any) -> None:
+        # pylint: disable=[super-init-not-called]
         self._func = constructor
         self._args = args
         self._kwargs = kwargs
@@ -682,7 +683,7 @@ class BaseSchema(Serializable):
     _LAYER: Optional[Type["BaseSchema"]] = None
     _MAPPER: ObjectMapper = ObjectMapper()
 
-    def __init__(self, source: TSource = None, object_path: str = ""):
+    def __init__(self, source: TSource = None, object_path: str = ""):  # pylint: disable=[super-init-not-called]
         # save source data (and drop information about nullness)
         source = source or {}
         self.__source: Union[Dict[str, Any], BaseSchema] = source
index e5da922daefee0dc7fdfab24c9a3fe6597d2afcf..1b07e3d4712f775f667c4f2e3b2dcb84517c7688 100644 (file)
@@ -1,4 +1,4 @@
-from abc import ABC, abstractmethod
+from abc import ABC, abstractmethod  # pylint: disable=[no-name-in-module]
 from typing import Any, Dict, Type
 
 
index 786cf645fafa4138a78dd7a662d6d9c853f12124..cfea82f6fbe474269f461ea41ee1ae4f36237b2d 100644 (file)
@@ -1,5 +1,5 @@
 import copy
-from abc import ABC, abstractmethod
+from abc import ABC, abstractmethod  # pylint: disable=[no-name-in-module]
 from typing import Any, List, Optional, Tuple, Union
 
 from typing_extensions import Literal
index ec992c113960ea0511569e1b47d3cd8713850488..2420ed04610b85755c5d8cd94bcbe921cbd5bc62 100644 (file)
@@ -15,7 +15,7 @@ assert isinstance(rd, Renamed) == True
 assert l = rl.original()
 """
 
-from abc import ABC, abstractmethod
+from abc import ABC, abstractmethod  # pylint: disable=[no-name-in-module]
 from typing import Any, Dict, List, TypeVar
 
 
index 5d4c48ea164a6053beb7ad5b6121b8902f436029..aaeded9e91c8c65ad3f7f2062988891ab6ba7380 100644 (file)
@@ -35,7 +35,7 @@ def is_tuple(tp: Any) -> bool:
 
 
 def is_union(tp: Any) -> bool:
-    """ Returns true even for optional types, because they are just a Union[T, NoneType] """
+    """Returns true even for optional types, because they are just a Union[T, NoneType]"""
     return getattr(tp, "__origin__", None) == Union  # type: ignore
 
 
@@ -55,7 +55,7 @@ def get_generic_type_arguments(tp: Any) -> List[Any]:
 
 
 def get_generic_type_argument(tp: Any) -> Any:
-    """ same as function get_generic_type_arguments, but expects just one type argument"""
+    """same as function get_generic_type_arguments, but expects just one type argument"""
 
     args = get_generic_type_arguments(tp)
     assert len(args) == 1
index 45d986f0197d34dcc30b715318011dadbcc91d6f..e406ab3bec6470656e7021d11606dfe54e3f5471 100644 (file)
@@ -78,7 +78,7 @@ class UnixHTTPHandler(AbstractHTTPHandler):
         super().__init__()
 
         def open_(self: UnixHTTPHandler, req: Any) -> Any:
-            return self.do_open(UnixHTTPConnection, req)
+            return self.do_open(UnixHTTPConnection, req)  # type: ignore[arg-type]
 
         setattr(UnixHTTPHandler, "http+unix_open", open_)
         setattr(UnixHTTPHandler, "http+unix_request", AbstractHTTPHandler.do_request_)