From b58ec49da983bcd25473ef6ae246eaadf32cd174 Mon Sep 17 00:00:00 2001 From: Stanislav Levin Date: Thu, 24 Feb 2022 16:40:09 +0300 Subject: [PATCH] pylint: Skip false-positive invalid-sequence-index Pylint doesn't handle flow control and thus, doesn't understand that a key of type `str` is not reachable at this point: > ipalib/base.py:472: [E1126(invalid-sequence-index), NameSpace.__getitem__] Sequence index is not an int, slice, or instance with __index__) Note: I faced this error on Python3.9 and didn't see it using Python3.10. Fixes: https://pagure.io/freeipa/issue/9117 Signed-off-by: Stanislav Levin Reviewed-By: Rob Crittenden --- ipalib/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ipalib/base.py b/ipalib/base.py index 2970bb188..d8f9ee728 100644 --- a/ipalib/base.py +++ b/ipalib/base.py @@ -469,7 +469,7 @@ class NameSpace(ReadOnly): if isinstance(key, str): return self.__map[key] if type(key) in (int, slice): - return self.__members[key] + return self.__members[key] # pylint: disable=invalid-sequence-index raise TypeError( TYPE_ERROR % ('key', (str, int, slice, 'object with __name__'), key, type(key))