Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unnecessary-dunder-call for pylint; exception caught in run_tests.py #655

Merged
merged 1 commit into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading