From 9ca6fcc4d5ccf40a7b2de810f7b856e971a4e965 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicki=20K=C5=99=C3=AD=C5=BEek?= Date: Mon, 14 Oct 2024 14:44:06 +0200 Subject: [PATCH] Disable too-many/too-few pylint checks Enforcing pylint standards and default for our test code seems counter-productive. Since most of the newly added code are tests or is test-related, encountering these checks rarely make us refactor the code in other ways and we just disable these checks individually. Code that is too complex or convoluted will be pointed out in reviews anyways. (cherry picked from commit 7639c58c4889003777e5da36567f84caa424f157) --- .pylintrc | 11 +++++++++++ bin/tests/system/conftest.py | 8 +++----- bin/tests/system/isctest/instance.py | 1 - bin/tests/system/isctest/query.py | 1 - bin/tests/system/isctest/rndc.py | 1 - bin/tests/system/isctest/run.py | 2 +- bin/tests/system/shutdown/tests_shutdown.py | 2 -- bin/tests/system/tsiggss/tests_isc_spnego_flaws.py | 4 ---- doc/arm/_ext/iscconf.py | 2 -- doc/arm/conf.py | 2 +- util/parse_tsan.py | 3 --- 11 files changed, 16 insertions(+), 21 deletions(-) diff --git a/.pylintrc b/.pylintrc index a75e65d8d3..3fb33f3c9c 100644 --- a/.pylintrc +++ b/.pylintrc @@ -12,6 +12,17 @@ disable= C0116, # missing-function-docstring C0209, # consider-using-f-string C0301, # line-too-long, handled better by black + C0302, # too-many-lines C0415, # import-outside-toplevel R0801, # duplicate-code + R0901, # too-many-ancestors + R0902, # too-many-instance-attributes R0903, # too-few-public-methods + R0904, # too-many-public-methods + R0911, # too-many-return-statements + R0912, # too-many-branches + R0913, # too-many-arguments + R0914, # too-many-locals + R0915, # too-many-statements + R0916, # too-many-boolean-expressions + R0917, # too-many-positional-arguments diff --git a/bin/tests/system/conftest.py b/bin/tests/system/conftest.py index 337f160f85..da3f638d6a 100644 --- a/bin/tests/system/conftest.py +++ b/bin/tests/system/conftest.py @@ -345,9 +345,7 @@ def logger(request, system_test_name): @pytest.fixture(scope="module") -def system_test_dir( - request, env, system_test_name -): # pylint: disable=too-many-statements,too-many-locals +def system_test_dir(request, env, system_test_name): """ Temporary directory for executing the test. @@ -455,7 +453,7 @@ def system_test_dir( unlink(symlink_dst) -def _run_script( # pylint: disable=too-many-arguments +def _run_script( env, system_test_dir: Path, interpreter: str, @@ -520,7 +518,7 @@ def run_tests_sh(system_test_dir, shell): @pytest.fixture(scope="module", autouse=True) -def system_test( # pylint: disable=too-many-arguments,too-many-statements +def system_test( request, env: Dict[str, str], system_test_dir, diff --git a/bin/tests/system/isctest/instance.py b/bin/tests/system/isctest/instance.py index 9db27621d6..6d7b308b1d 100644 --- a/bin/tests/system/isctest/instance.py +++ b/bin/tests/system/isctest/instance.py @@ -38,7 +38,6 @@ class NamedInstance: ``` """ - # pylint: disable=too-many-arguments def __init__( self, identifier: str, diff --git a/bin/tests/system/isctest/query.py b/bin/tests/system/isctest/query.py index 5662d1e380..4c389af2d9 100644 --- a/bin/tests/system/isctest/query.py +++ b/bin/tests/system/isctest/query.py @@ -22,7 +22,6 @@ from isctest.compat import dns_rcode QUERY_TIMEOUT = 10 -# pylint: disable=too-many-arguments def generic_query( query_func: Callable[..., Any], message: dns.message.Message, diff --git a/bin/tests/system/isctest/rndc.py b/bin/tests/system/isctest/rndc.py index 6e869ab316..d4a0a1bd77 100644 --- a/bin/tests/system/isctest/rndc.py +++ b/bin/tests/system/isctest/rndc.py @@ -14,7 +14,6 @@ import os import subprocess -# pylint: disable=too-few-public-methods class RNDCExecutor(abc.ABC): """ An interface which RNDC executors have to implement in order for the diff --git a/bin/tests/system/isctest/run.py b/bin/tests/system/isctest/run.py index e4585ecae2..09eec76127 100644 --- a/bin/tests/system/isctest/run.py +++ b/bin/tests/system/isctest/run.py @@ -20,7 +20,7 @@ from isctest.compat import dns_rcode import dns.message -def cmd( # pylint: disable=too-many-arguments +def cmd( args, cwd=None, timeout=60, diff --git a/bin/tests/system/shutdown/tests_shutdown.py b/bin/tests/system/shutdown/tests_shutdown.py index 4a447c12a0..d93d0d9b47 100755 --- a/bin/tests/system/shutdown/tests_shutdown.py +++ b/bin/tests/system/shutdown/tests_shutdown.py @@ -61,8 +61,6 @@ def do_work(named_proc, resolver_ip, instance, kill_method, n_workers, n_queries :param n_queries: Total number of queries to send :type n_queries: int """ - # pylint: disable-msg=too-many-arguments - # pylint: disable-msg=too-many-locals # helper function, 'command' is the rndc command to run def launch_rndc(command): diff --git a/bin/tests/system/tsiggss/tests_isc_spnego_flaws.py b/bin/tests/system/tsiggss/tests_isc_spnego_flaws.py index b474fc1ab8..796da8fbc9 100755 --- a/bin/tests/system/tsiggss/tests_isc_spnego_flaws.py +++ b/bin/tests/system/tsiggss/tests_isc_spnego_flaws.py @@ -35,8 +35,6 @@ import dns.rrset class CraftedTKEYQuery: - # pylint: disable=too-few-public-methods - """ A class for preparing crafted TKEY queries """ @@ -81,8 +79,6 @@ class CraftedTKEYQuery: class ASN1Encoder: - # pylint: disable=too-few-public-methods - """ A custom ASN1 encoder which allows preparing malformed GSSAPI tokens """ diff --git a/doc/arm/_ext/iscconf.py b/doc/arm/_ext/iscconf.py index 7c0a3c9511..dc440e2928 100644 --- a/doc/arm/_ext/iscconf.py +++ b/doc/arm/_ext/iscconf.py @@ -52,7 +52,6 @@ def split_csv(argument, required): return outlist -# pylint: disable=too-many-statements def domain_factory(domainname, domainlabel, todolist, grammar): """ Return parametrized Sphinx domain object. @@ -318,7 +317,6 @@ def domain_factory(domainname, domainlabel, todolist, grammar): ] ) - # pylint: disable=too-many-arguments def resolve_xref(self, env, fromdocname, builder, typ, target, node, contnode): """ Sphinx API: diff --git a/doc/arm/conf.py b/doc/arm/conf.py index 8e209bee3e..2c5a388c29 100644 --- a/doc/arm/conf.py +++ b/doc/arm/conf.py @@ -26,7 +26,7 @@ from sphinx import addnodes try: from sphinx.util.docutils import ReferenceRole except ImportError: - # pylint: disable=too-few-public-methods + class ReferenceRole(roles.GenericRole): """ The ReferenceRole class (used as a base class by GitLabRefRole diff --git a/util/parse_tsan.py b/util/parse_tsan.py index e13e8ec49e..28afc34bff 100755 --- a/util/parse_tsan.py +++ b/util/parse_tsan.py @@ -24,9 +24,6 @@ from hashlib import sha256 class State: """Class that holds state of the TSAN parser.""" - # pylint: disable=too-many-instance-attributes - # pylint: disable=too-few-public-methods - inside = False block = "" last_line = None