From 06ed07456ca5f645f8673314306735360d346727 Mon Sep 17 00:00:00 2001 From: Bryan Van de Ven Date: Mon, 28 Oct 2019 10:40:11 -0700 Subject: [PATCH 1/3] add reprs to common user-facing classes --- sdk/cosmos/azure-cosmos/azure/cosmos/container.py | 4 ++++ sdk/cosmos/azure-cosmos/azure/cosmos/cosmos_client.py | 4 ++++ sdk/cosmos/azure-cosmos/azure/cosmos/database.py | 4 ++++ sdk/cosmos/azure-cosmos/azure/cosmos/partition_key.py | 4 ++++ sdk/cosmos/azure-cosmos/azure/cosmos/user.py | 4 ++++ 5 files changed, 20 insertions(+) diff --git a/sdk/cosmos/azure-cosmos/azure/cosmos/container.py b/sdk/cosmos/azure-cosmos/azure/cosmos/container.py index 73441d19f5ab..3480e39c485d 100644 --- a/sdk/cosmos/azure-cosmos/azure/cosmos/container.py +++ b/sdk/cosmos/azure-cosmos/azure/cosmos/container.py @@ -67,6 +67,10 @@ def __init__(self, client_connection, database_link, id, properties=None): # py self._is_system_key = None self._scripts = None # type: Optional[ScriptsProxy] + def __repr__(self): + # type () -> str + return "".format(self.container_link)[:1024] + def _get_properties(self): # type: () -> Dict[str, Any] if self._properties is None: diff --git a/sdk/cosmos/azure-cosmos/azure/cosmos/cosmos_client.py b/sdk/cosmos/azure-cosmos/azure/cosmos/cosmos_client.py index c7065f8f8e5b..8849128b1f9d 100644 --- a/sdk/cosmos/azure-cosmos/azure/cosmos/cosmos_client.py +++ b/sdk/cosmos/azure-cosmos/azure/cosmos/cosmos_client.py @@ -194,6 +194,10 @@ def __init__(self, url, credential, consistency_level="Session", **kwargs): url, auth=auth, consistency_level=consistency_level, connection_policy=connection_policy, **kwargs ) + def __repr__(self): + # type () -> str + return "".format(self.client_connection.url_connection)[:1024] + def __enter__(self): self.client_connection.pipeline_client.__enter__() return self diff --git a/sdk/cosmos/azure-cosmos/azure/cosmos/database.py b/sdk/cosmos/azure-cosmos/azure/cosmos/database.py index cc5067d003db..ec4397753271 100644 --- a/sdk/cosmos/azure-cosmos/azure/cosmos/database.py +++ b/sdk/cosmos/azure-cosmos/azure/cosmos/database.py @@ -76,6 +76,10 @@ def __init__(self, client_connection, id, properties=None): # pylint: disable=r self.database_link = u"dbs/{}".format(self.id) self._properties = properties + def __repr__(self): + # type () -> str + return "".format(self.database_link)[:1024] + @staticmethod def _get_container_id(container_or_id): # type: (Union[str, ContainerProxy, Dict[str, Any]]) -> str diff --git a/sdk/cosmos/azure-cosmos/azure/cosmos/partition_key.py b/sdk/cosmos/azure-cosmos/azure/cosmos/partition_key.py index 309e27ba64de..e361ee45b7bc 100644 --- a/sdk/cosmos/azure-cosmos/azure/cosmos/partition_key.py +++ b/sdk/cosmos/azure-cosmos/azure/cosmos/partition_key.py @@ -54,6 +54,10 @@ def __init__(self, path, kind="Hash", version=2): # pylint: disable=super-init- self.kind = kind self.version = version + def __repr__(self): + # type () -> str + return "".format(self.path)[:1024] + @property def kind(self): return self["kind"] diff --git a/sdk/cosmos/azure-cosmos/azure/cosmos/user.py b/sdk/cosmos/azure-cosmos/azure/cosmos/user.py index 9352d6755582..b312658eba63 100644 --- a/sdk/cosmos/azure-cosmos/azure/cosmos/user.py +++ b/sdk/cosmos/azure-cosmos/azure/cosmos/user.py @@ -47,6 +47,10 @@ def __init__(self, client_connection, id, database_link, properties=None): # py self.user_link = u"{}/users/{}".format(database_link, id) self._properties = properties + def __repr__(self): + # type () -> str + return "".format(self.user_link)[:1024] + def _get_permission_link(self, permission_or_id): # type: (Union[Permission, str, Dict[str, Any]]) -> str if isinstance(permission_or_id, six.string_types): From 15bc359c5ff0fa9d66b23029b63975ffb9075031 Mon Sep 17 00:00:00 2001 From: Bryan Van de Ven Date: Mon, 28 Oct 2019 11:08:11 -0700 Subject: [PATCH 2/3] typo class name --- sdk/cosmos/azure-cosmos/azure/cosmos/user.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/cosmos/azure-cosmos/azure/cosmos/user.py b/sdk/cosmos/azure-cosmos/azure/cosmos/user.py index b312658eba63..8b9af8893c75 100644 --- a/sdk/cosmos/azure-cosmos/azure/cosmos/user.py +++ b/sdk/cosmos/azure-cosmos/azure/cosmos/user.py @@ -49,7 +49,7 @@ def __init__(self, client_connection, id, database_link, properties=None): # py def __repr__(self): # type () -> str - return "".format(self.user_link)[:1024] + return "".format(self.user_link)[:1024] def _get_permission_link(self, permission_or_id): # type: (Union[Permission, str, Dict[str, Any]]) -> str From cb752b02c6e995fa30502eb2ef45ff3d649d9fa4 Mon Sep 17 00:00:00 2001 From: Bryan Van de Ven Date: Mon, 28 Oct 2019 13:48:48 -0700 Subject: [PATCH 3/3] disable errant linter objection --- sdk/cosmos/azure-cosmos/azure/cosmos/cosmos_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/cosmos/azure-cosmos/azure/cosmos/cosmos_client.py b/sdk/cosmos/azure-cosmos/azure/cosmos/cosmos_client.py index 8849128b1f9d..9d8199d08c3d 100644 --- a/sdk/cosmos/azure-cosmos/azure/cosmos/cosmos_client.py +++ b/sdk/cosmos/azure-cosmos/azure/cosmos/cosmos_client.py @@ -194,7 +194,7 @@ def __init__(self, url, credential, consistency_level="Session", **kwargs): url, auth=auth, consistency_level=consistency_level, connection_policy=connection_policy, **kwargs ) - def __repr__(self): + def __repr__(self): # pylint:disable=client-method-name-no-double-underscore # type () -> str return "".format(self.client_connection.url_connection)[:1024]