Skip to content

Commit

Permalink
added unnecessary-dunder-call to pylintrc files; disabled for certain…
Browse files Browse the repository at this point in the history
… lines (#655)

in run_tests.py, exception thrown by 'git remote add origin' when the remote already exists will not exit

Signed-off-by: Mark Cohen <[email protected]>
  • Loading branch information
macohen authored Jan 22, 2024
1 parent 7c66e8c commit 6e58837
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 27 deletions.
10 changes: 8 additions & 2 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -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]?$

6 changes: 5 additions & 1 deletion opensearchpy/.pylintrc
Original file line number Diff line number Diff line change
@@ -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]?$
2 changes: 1 addition & 1 deletion opensearchpy/helpers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion test_opensearchpy/.pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -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]?$
2 changes: 1 addition & 1 deletion test_opensearchpy/test_async/test_plugins_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down
20 changes: 10 additions & 10 deletions test_opensearchpy/test_server/test_helpers/test_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 6e58837

Please sign in to comment.