diff --git a/.pylintrc b/.pylintrc index 2e58f1d5..35aba38a 100644 --- a/.pylintrc +++ b/.pylintrc @@ -1,7 +1,13 @@ [MESSAGES CONTROL] disable=all -enable=line-too-long,invalid-name,pointless-statement,unspecified-encoding, - missing-function-docstring,missing-param-doc,differing-param-doc +enable=line-too-long, + invalid-name, + pointless-statement, + unspecified-encoding, + missing-function-docstring, + missing-param-doc, + differing-param-doc, + unnecessary-dunder-call max-line-length=240 good-names-rgxs=^[_a-z][_a-z0-9]?$ diff --git a/opensearchpy/.pylintrc b/opensearchpy/.pylintrc index f9f7b38f..6a1a6a95 100644 --- a/opensearchpy/.pylintrc +++ b/opensearchpy/.pylintrc @@ -1,5 +1,9 @@ [MESSAGES CONTROL] disable=all -enable=line-too-long,invalid-name,pointless-statement,unspecified-encoding +enable=line-too-long, + invalid-name, + pointless-statement, + unspecified-encoding, + unnecessary-dunder-call max-line-length=240 good-names-rgxs=^[_a-z][_a-z0-9]?$ \ No newline at end of file diff --git a/opensearchpy/helpers/utils.py b/opensearchpy/helpers/utils.py index c46c374a..cad415b9 100644 --- a/opensearchpy/helpers/utils.py +++ b/opensearchpy/helpers/utils.py @@ -174,7 +174,7 @@ def __getattr__(self, attr_name: Any) -> Any: def get(self, key: Any, default: Any = None) -> Any: try: - return self.__getattr__(key) + return self.__getattr__(key) # pylint: disable=unnecessary-dunder-call except AttributeError: if default is not None: return default diff --git a/test_opensearchpy/.pylintrc b/test_opensearchpy/.pylintrc index 1e223125..fb981792 100644 --- a/test_opensearchpy/.pylintrc +++ b/test_opensearchpy/.pylintrc @@ -5,6 +5,7 @@ enable=line-too-long, pointless-statement, unspecified-encoding, missing-param-doc, - differing-param-doc + differing-param-doc, + unnecessary-dunder-call max-line-length=240 good-names-rgxs=^[_a-z][_a-z0-9]?$ \ No newline at end of file diff --git a/test_opensearchpy/test_async/test_plugins_client.py b/test_opensearchpy/test_async/test_plugins_client.py index 04eaa7eb..3e014111 100644 --- a/test_opensearchpy/test_async/test_plugins_client.py +++ b/test_opensearchpy/test_async/test_plugins_client.py @@ -23,7 +23,7 @@ async def test_plugins_client(self) -> None: with warnings.catch_warnings(record=True) as w: client = AsyncOpenSearch() # testing double-init here - client.plugins.__init__(client) # type: ignore + client.plugins.__init__(client) # type: ignore # pylint: disable=unnecessary-dunder-call assert ( str(w[0].message) == "Cannot load `alerting` directly to AsyncOpenSearch as it already exists. Use " diff --git a/test_opensearchpy/test_async/test_server/test_helpers/test_document.py b/test_opensearchpy/test_async/test_server/test_helpers/test_document.py index bf02161d..6a14cb7d 100644 --- a/test_opensearchpy/test_async/test_server/test_helpers/test_document.py +++ b/test_opensearchpy/test_async/test_server/test_helpers/test_document.py @@ -275,22 +275,22 @@ async def test_save_and_update_return_doc_meta(write_client: Any) -> None: resp = await w.save(return_doc_meta=True) assert resp["_index"] == "test-wiki" assert resp["result"] == "created" - assert resp.keys().__contains__("_id") - assert resp.keys().__contains__("_primary_term") - assert resp.keys().__contains__("_seq_no") - assert resp.keys().__contains__("_shards") - assert resp.keys().__contains__("_version") + assert "_id" in resp.keys() + assert "_primary_term" in resp.keys() + assert "_seq_no" in resp.keys() + assert "_shards" in resp.keys() + assert "_version" in resp.keys() resp = await w.update( script="ctx._source.views += params.inc", inc=5, return_doc_meta=True ) assert resp["_index"] == "test-wiki" assert resp["result"] == "updated" - assert resp.keys().__contains__("_id") - assert resp.keys().__contains__("_primary_term") - assert resp.keys().__contains__("_seq_no") - assert resp.keys().__contains__("_shards") - assert resp.keys().__contains__("_version") + assert "_id" in resp.keys() + assert "_primary_term" in resp.keys() + assert "_seq_no" in resp.keys() + assert "_shards" in resp.keys() + assert "_version" in resp.keys() async def test_init(write_client: Any) -> None: diff --git a/test_opensearchpy/test_client/test_plugins/test_plugins_client.py b/test_opensearchpy/test_client/test_plugins/test_plugins_client.py index 1b794486..658defa6 100644 --- a/test_opensearchpy/test_client/test_plugins/test_plugins_client.py +++ b/test_opensearchpy/test_client/test_plugins/test_plugins_client.py @@ -17,7 +17,7 @@ def test_plugins_client(self) -> None: with self.assertWarns(Warning) as w: client = OpenSearch() # double-init - client.plugins.__init__(client) # type: ignore + client.plugins.__init__(client) # type: ignore # pylint: disable=unnecessary-dunder-call self.assertEqual( str(w.warnings[0].message), "Cannot load `alerting` directly to OpenSearch as " diff --git a/test_opensearchpy/test_server/test_helpers/test_document.py b/test_opensearchpy/test_server/test_helpers/test_document.py index 53e24173..573240a2 100644 --- a/test_opensearchpy/test_server/test_helpers/test_document.py +++ b/test_opensearchpy/test_server/test_helpers/test_document.py @@ -284,22 +284,22 @@ def test_save_and_update_return_doc_meta(write_client: Any) -> None: resp = w.save(return_doc_meta=True) assert resp["_index"] == "test-wiki" assert resp["result"] == "created" - assert resp.keys().__contains__("_id") - assert resp.keys().__contains__("_primary_term") - assert resp.keys().__contains__("_seq_no") - assert resp.keys().__contains__("_shards") - assert resp.keys().__contains__("_version") + assert "_id" in resp.keys() + assert "_primary_term" in resp.keys() + assert "_seq_no" in resp.keys() + assert "_shards" in resp.keys() + assert "_version" in resp.keys() resp = w.update( script="ctx._source.views += params.inc", inc=5, return_doc_meta=True ) assert resp["_index"] == "test-wiki" assert resp["result"] == "updated" - assert resp.keys().__contains__("_id") - assert resp.keys().__contains__("_primary_term") - assert resp.keys().__contains__("_seq_no") - assert resp.keys().__contains__("_shards") - assert resp.keys().__contains__("_version") + assert "_id" in resp.keys() + assert "_primary_term" in resp.keys() + assert "_seq_no" in resp.keys() + assert "_shards" in resp.keys() + assert "_version" in resp.keys() def test_init(write_client: Any) -> None: