From 2bfc4091779c11b79f0d9941d4c9a7d24a84f2cc Mon Sep 17 00:00:00 2001 From: "Daniel (dB.) Doubrovkine" Date: Mon, 9 Oct 2023 13:45:18 -0400 Subject: [PATCH] Fix: typos. (#526) * Fix: typo. Signed-off-by: dblock * Fix: typo. Signed-off-by: dblock * Fixed its. Signed-off-by: dblock * Added Visual Code settings to .gitignore. Signed-off-by: dblock * Added loop type for async client. Signed-off-by: dblock --------- Signed-off-by: dblock --- .gitignore | 5 ++++- opensearchpy/_async/http_aiohttp.pyi | 3 ++- opensearchpy/_async/transport.py | 6 +++--- opensearchpy/connection/base.py | 4 ++-- opensearchpy/connection_pool.py | 14 +++++++------- opensearchpy/helpers/utils.py | 6 +++--- opensearchpy/transport.py | 6 +++--- .../test_server/test_helpers/test_data.py | 2 +- .../test_server/test_plugins/test_alerting.py | 6 +++--- .../test_async/test_server/test_rest_api_spec.py | 6 +++--- .../test_server/test_helpers/test_data.py | 2 +- .../test_server/test_plugins/test_alerting.py | 6 +++--- .../test_server/test_rest_api_spec.py | 2 +- 13 files changed, 36 insertions(+), 32 deletions(-) diff --git a/.gitignore b/.gitignore index 019de716..153eea24 100644 --- a/.gitignore +++ b/.gitignore @@ -148,6 +148,9 @@ test_opensearch/cover test_opensearch/local.py .ci/output -#Vi text editor +# vi text editor .*.swp *~ + +# Visual Studio Code +.vscode \ No newline at end of file diff --git a/opensearchpy/_async/http_aiohttp.pyi b/opensearchpy/_async/http_aiohttp.pyi index 4dea4317..223fdfff 100644 --- a/opensearchpy/_async/http_aiohttp.pyi +++ b/opensearchpy/_async/http_aiohttp.pyi @@ -24,6 +24,7 @@ # specific language governing permissions and limitations # under the License. +from asyncio import AbstractEventLoop from typing import Any, Collection, Mapping, Optional, Tuple, Union from ..connection import Connection @@ -65,7 +66,7 @@ class AIOHttpConnection(AsyncConnection): ssl_context: Optional[Any] = ..., http_compress: Optional[bool] = ..., opaque_id: Optional[str] = ..., - loop: Any = ..., + loop: Optional[AbstractEventLoop] = ..., trust_env: bool = ..., **kwargs: Any ) -> None: ... diff --git a/opensearchpy/_async/transport.py b/opensearchpy/_async/transport.py index e93344bc..3db4516c 100644 --- a/opensearchpy/_async/transport.py +++ b/opensearchpy/_async/transport.py @@ -343,14 +343,14 @@ def get_connection(self): async def perform_request(self, method, url, headers=None, params=None, body=None): """ Perform the actual request. Retrieve a connection from the connection - pool, pass all the information to it's perform_request method and + pool, pass all the information to its perform_request method and return the data. If an exception was raised, mark the connection as failed and retry (up to `max_retries` times). If the operation was successful and the connection used was previously - marked as dead, mark it as live, resetting it's failure count. + marked as dead, mark it as live, resetting its failure count. :arg method: HTTP method to use :arg url: absolute url (without host) to target @@ -412,7 +412,7 @@ async def perform_request(self, method, url, headers=None, params=None, body=Non raise e else: - # connection didn't fail, confirm it's live status + # connection didn't fail, confirm its live status self.connection_pool.mark_live(connection) if method == "HEAD": diff --git a/opensearchpy/connection/base.py b/opensearchpy/connection/base.py index 435996b9..05edca73 100644 --- a/opensearchpy/connection/base.py +++ b/opensearchpy/connection/base.py @@ -56,7 +56,7 @@ class Connection(object): """ Class responsible for maintaining a connection to an OpenSearch node. It - holds persistent connection pool to it and it's main interface + holds persistent connection pool to it and its main interface (`perform_request`) is thread-safe. Also responsible for logging. @@ -158,7 +158,7 @@ def _raise_warnings(self, warning_headers): # Format is: '(number) OpenSearch-(version)-(instance) "(message)"' warning_messages = [] for header in warning_headers: - # Because 'Requests' does it's own folding of multiple HTTP headers + # Because 'Requests' does its own folding of multiple HTTP headers # into one header delimited by commas (totally standard compliant, just # annoying for cases like this) we need to expect there may be # more than one message per 'Warning' header. diff --git a/opensearchpy/connection_pool.py b/opensearchpy/connection_pool.py index 0416fbec..61873748 100644 --- a/opensearchpy/connection_pool.py +++ b/opensearchpy/connection_pool.py @@ -55,8 +55,8 @@ class ConnectionSelector(object): process it will be the dictionary returned by the `host_info_callback`. Example of where this would be useful is a zone-aware selector that would - only select connections from it's own zones and only fall back to other - connections where there would be none in it's zones. + only select connections from its own zones and only fall back to other + connections where there would be none in its zones. """ def __init__(self, opts): @@ -112,7 +112,7 @@ class ConnectionPool(object): future reference. Upon each request the `Transport` will ask for a `Connection` via the - `get_connection` method. If the connection fails (it's `perform_request` + `get_connection` method. If the connection fails (its `perform_request` raises a `ConnectionError`) it will be marked as dead (via `mark_dead`) and put on a timeout (if it fails N times in a row the timeout is exponentially longer - the formula is `default_timeout * 2 ** (fail_count - 1)`). When @@ -132,7 +132,7 @@ def __init__( ): """ :arg connections: list of tuples containing the - :class:`~opensearchpy.Connection` instance and it's options + :class:`~opensearchpy.Connection` instance and its options :arg dead_timeout: number of seconds a connection should be retired for after a failure, increases on consecutive failures :arg timeout_cutoff: number of consecutive failures after which the @@ -211,7 +211,7 @@ def mark_live(self, connection): def resurrect(self, force=False): """ Attempt to resurrect a connection from the dead pool. It will try to - locate one (not all) eligible (it's timeout is over) connection to + locate one (not all) eligible (its timeout is over) connection to return to the live pool. Any resurrected connection is also returned. :arg force: resurrect a connection even if there is none eligible (used @@ -245,7 +245,7 @@ def resurrect(self, force=False): self.dead.put((timeout, connection)) return - # either we were forced or the connection is elligible to be retried + # either we were forced or the connection is eligible to be retried self.connections.append(connection) logger.info("Resurrecting connection %r (force=%s).", connection, force) return connection @@ -259,7 +259,7 @@ def get_connection(self): no connections are available and passes the list of live connections to the selector instance to choose from. - Returns a connection instance and it's current fail count. + Returns a connection instance and its current fail count. """ self.resurrect() connections = self.connections[:] diff --git a/opensearchpy/helpers/utils.py b/opensearchpy/helpers/utils.py index 3ebea18e..04f2ee37 100644 --- a/opensearchpy/helpers/utils.py +++ b/opensearchpy/helpers/utils.py @@ -222,7 +222,7 @@ class DslMeta(type): It then uses the information from that registry (as well as `name` and `shortcut` attributes from the base class) to construct any subclass based - on it's name. + on its name. For typical use see `QueryMeta` and `Query` in `opensearchpy.query`. """ @@ -235,7 +235,7 @@ def __init__(cls, name, bases, attrs): if not hasattr(cls, "_type_shortcut"): return if cls.name is None: - # abstract base class, register it's shortcut + # abstract base class, register its shortcut cls._types[cls._type_name] = cls._type_shortcut # and create a registry for subclasses if not hasattr(cls, "_classes"): @@ -264,7 +264,7 @@ class DslBase(object): - to_dict method to serialize into dict (to be sent via opensearch-py) - basic logical operators (&, | and ~) using a Bool(Filter|Query) TODO: move into a class specific for Query/Filter - - respects the definition of the class and (de)serializes it's + - respects the definition of the class and (de)serializes its attributes based on the `_param_defs` definition (for example turning all values in the `must` attribute into Query objects) """ diff --git a/opensearchpy/transport.py b/opensearchpy/transport.py index c1d69d2c..32c9baf4 100644 --- a/opensearchpy/transport.py +++ b/opensearchpy/transport.py @@ -341,14 +341,14 @@ def mark_dead(self, connection): def perform_request(self, method, url, headers=None, params=None, body=None): """ Perform the actual request. Retrieve a connection from the connection - pool, pass all the information to it's perform_request method and + pool, pass all the information to its perform_request method and return the data. If an exception was raised, mark the connection as failed and retry (up to `max_retries` times). If the operation was successful and the connection used was previously - marked as dead, mark it as live, resetting it's failure count. + marked as dead, mark it as live, resetting its failure count. :arg method: HTTP method to use :arg url: absolute url (without host) to target @@ -409,7 +409,7 @@ def perform_request(self, method, url, headers=None, params=None, body=None): raise e else: - # connection didn't fail, confirm it's live status + # connection didn't fail, confirm its live status self.connection_pool.mark_live(connection) if method == "HEAD": diff --git a/test_opensearchpy/test_async/test_server/test_helpers/test_data.py b/test_opensearchpy/test_async/test_server/test_helpers/test_data.py index d513bcff..1194304e 100644 --- a/test_opensearchpy/test_async/test_server/test_helpers/test_data.py +++ b/test_opensearchpy/test_async/test_server/test_helpers/test_data.py @@ -947,7 +947,7 @@ async def create_git_index(client, index): ], "committer": {"name": "Honza Kr\xe1l", "email": "honza.kral@gmail.com"}, "stats": {"deletions": 0, "insertions": 53, "lines": 53, "files": 2}, - "description": "From_dict, Q(dict) and bool query parses it's subqueries", + "description": "From_dict, Q(dict) and bool query parses its subqueries", "author": {"name": "Honza Kr\xe1l", "email": "honza.kral@gmail.com"}, "parent_shas": ["d407f99d1959b7b862a541c066d9fd737ce913f3"], "committed_date": "2014-03-06T20:24:30", diff --git a/test_opensearchpy/test_async/test_server/test_plugins/test_alerting.py b/test_opensearchpy/test_async/test_server/test_plugins/test_alerting.py index f3f7fe32..2ef87bd3 100644 --- a/test_opensearchpy/test_async/test_server/test_plugins/test_alerting.py +++ b/test_opensearchpy/test_async/test_server/test_plugins/test_alerting.py @@ -127,7 +127,7 @@ async def test_search_monitor(self): # Create a dummy monitor await self.test_create_monitor() - # Create a monitor search query by it's name + # Create a monitor search query by its name query = {"query": {"match": {"monitor.name": "test-monitor"}}} # Perform the search with the above query @@ -145,7 +145,7 @@ async def test_get_monitor(self): # Create a dummy monitor await self.test_create_monitor() - # Create a monitor search query by it's name + # Create a monitor search query by its name query = {"query": {"match": {"monitor.name": "test-monitor"}}} # Perform the search with the above query @@ -169,7 +169,7 @@ async def test_run_monitor(self): # Create a dummy monitor await self.test_create_monitor() - # Create a monitor search query by it's name + # Create a monitor search query by its name query = {"query": {"match": {"monitor.name": "test-monitor"}}} # Perform the search with the above query diff --git a/test_opensearchpy/test_async/test_server/test_rest_api_spec.py b/test_opensearchpy/test_async/test_server/test_rest_api_spec.py index 27b20113..0773aab0 100644 --- a/test_opensearchpy/test_async/test_server/test_rest_api_spec.py +++ b/test_opensearchpy/test_async/test_server/test_rest_api_spec.py @@ -26,7 +26,7 @@ """ -Dynamically generated set of TestCases based on set of yaml files decribing +Dynamically generated set of TestCases based on set of yaml files describing some integration tests. These files are shared among all official OpenSearch clients. """ @@ -106,7 +106,7 @@ async def run(self): pass async def run_code(self, test): - """Execute an instruction based on it's type.""" + """Execute an instruction based on its type.""" for action in test: assert len(action) == 1 action_type, action = list(action.items())[0] @@ -126,7 +126,7 @@ async def run_do(self, action): assert len(action) == 1 # Remove the x_pack_rest_user authentication - # if it's given via headers. We're already authenticated + # if its given via headers. We're already authenticated # via the 'elastic' user. if ( headers diff --git a/test_opensearchpy/test_server/test_helpers/test_data.py b/test_opensearchpy/test_server/test_helpers/test_data.py index 20b63e39..059a983a 100644 --- a/test_opensearchpy/test_server/test_helpers/test_data.py +++ b/test_opensearchpy/test_server/test_helpers/test_data.py @@ -964,7 +964,7 @@ def create_git_index(client, index): ], "committer": {"name": "Honza Kr\xe1l", "email": "honza.kral@gmail.com"}, "stats": {"deletions": 0, "insertions": 53, "lines": 53, "files": 2}, - "description": "From_dict, Q(dict) and bool query parses it's subqueries", + "description": "From_dict, Q(dict) and bool query parses its subqueries", "author": {"name": "Honza Kr\xe1l", "email": "honza.kral@gmail.com"}, "parent_shas": ["d407f99d1959b7b862a541c066d9fd737ce913f3"], "committed_date": "2014-03-06T20:24:30", diff --git a/test_opensearchpy/test_server/test_plugins/test_alerting.py b/test_opensearchpy/test_server/test_plugins/test_alerting.py index 406bd71f..3a503e43 100644 --- a/test_opensearchpy/test_server/test_plugins/test_alerting.py +++ b/test_opensearchpy/test_server/test_plugins/test_alerting.py @@ -123,7 +123,7 @@ def test_search_monitor(self): # Create a dummy monitor self.test_create_monitor() - # Create a monitor search query by it's name + # Create a monitor search query by its name query = {"query": {"match": {"monitor.name": "test-monitor"}}} # Perform the search with the above query @@ -141,7 +141,7 @@ def test_get_monitor(self): # Create a dummy monitor self.test_create_monitor() - # Create a monitor search query by it's name + # Create a monitor search query by its name query = {"query": {"match": {"monitor.name": "test-monitor"}}} # Perform the search with the above query @@ -165,7 +165,7 @@ def test_run_monitor(self): # Create a dummy monitor self.test_create_monitor() - # Create a monitor search query by it's name + # Create a monitor search query by its name query = {"query": {"match": {"monitor.name": "test-monitor"}}} # Perform the search with the above query diff --git a/test_opensearchpy/test_server/test_rest_api_spec.py b/test_opensearchpy/test_server/test_rest_api_spec.py index 7d1cbf51..b5d890ab 100644 --- a/test_opensearchpy/test_server/test_rest_api_spec.py +++ b/test_opensearchpy/test_server/test_rest_api_spec.py @@ -205,7 +205,7 @@ def run(self): pass def run_code(self, test): - """Execute an instruction based on it's type.""" + """Execute an instruction based on its type.""" for action in test: assert len(action) == 1 action_type, action = list(action.items())[0]