Skip to content

Commit ecaac22

Browse files
authored
add reprs to common user-facing classes (#8241)
* add reprs to common user-facing classes * typo class name * disable errant linter objection
1 parent 39a2acd commit ecaac22

File tree

5 files changed

+20
-0
lines changed

5 files changed

+20
-0
lines changed

sdk/cosmos/azure-cosmos/azure/cosmos/container.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ def __init__(self, client_connection, database_link, id, properties=None): # py
6767
self._is_system_key = None
6868
self._scripts = None # type: Optional[ScriptsProxy]
6969

70+
def __repr__(self):
71+
# type () -> str
72+
return "<ContainerProxy [{}]>".format(self.container_link)[:1024]
73+
7074
def _get_properties(self):
7175
# type: () -> Dict[str, Any]
7276
if self._properties is None:

sdk/cosmos/azure-cosmos/azure/cosmos/cosmos_client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,10 @@ def __init__(self, url, credential, consistency_level="Session", **kwargs):
194194
url, auth=auth, consistency_level=consistency_level, connection_policy=connection_policy, **kwargs
195195
)
196196

197+
def __repr__(self): # pylint:disable=client-method-name-no-double-underscore
198+
# type () -> str
199+
return "<CosmosClient [{}]>".format(self.client_connection.url_connection)[:1024]
200+
197201
def __enter__(self):
198202
self.client_connection.pipeline_client.__enter__()
199203
return self

sdk/cosmos/azure-cosmos/azure/cosmos/database.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ def __init__(self, client_connection, id, properties=None): # pylint: disable=r
7676
self.database_link = u"dbs/{}".format(self.id)
7777
self._properties = properties
7878

79+
def __repr__(self):
80+
# type () -> str
81+
return "<DatabaseProxy [{}]>".format(self.database_link)[:1024]
82+
7983
@staticmethod
8084
def _get_container_id(container_or_id):
8185
# type: (Union[str, ContainerProxy, Dict[str, Any]]) -> str

sdk/cosmos/azure-cosmos/azure/cosmos/partition_key.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ def __init__(self, path, kind="Hash", version=2): # pylint: disable=super-init-
5454
self.kind = kind
5555
self.version = version
5656

57+
def __repr__(self):
58+
# type () -> str
59+
return "<PartitionKey [{}]>".format(self.path)[:1024]
60+
5761
@property
5862
def kind(self):
5963
return self["kind"]

sdk/cosmos/azure-cosmos/azure/cosmos/user.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ def __init__(self, client_connection, id, database_link, properties=None): # py
4747
self.user_link = u"{}/users/{}".format(database_link, id)
4848
self._properties = properties
4949

50+
def __repr__(self):
51+
# type () -> str
52+
return "<UserProxy [{}]>".format(self.user_link)[:1024]
53+
5054
def _get_permission_link(self, permission_or_id):
5155
# type: (Union[Permission, str, Dict[str, Any]]) -> str
5256
if isinstance(permission_or_id, six.string_types):

0 commit comments

Comments
 (0)