Skip to content

Commit

Permalink
add reprs to common user-facing classes (#8241)
Browse files Browse the repository at this point in the history
* add reprs to common user-facing classes

* typo class name

* disable errant linter objection
  • Loading branch information
bryevdv authored Oct 28, 2019
1 parent 39a2acd commit ecaac22
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions sdk/cosmos/azure-cosmos/azure/cosmos/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 "<ContainerProxy [{}]>".format(self.container_link)[:1024]

def _get_properties(self):
# type: () -> Dict[str, Any]
if self._properties is None:
Expand Down
4 changes: 4 additions & 0 deletions sdk/cosmos/azure-cosmos/azure/cosmos/cosmos_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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): # pylint:disable=client-method-name-no-double-underscore
# type () -> str
return "<CosmosClient [{}]>".format(self.client_connection.url_connection)[:1024]

def __enter__(self):
self.client_connection.pipeline_client.__enter__()
return self
Expand Down
4 changes: 4 additions & 0 deletions sdk/cosmos/azure-cosmos/azure/cosmos/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 "<DatabaseProxy [{}]>".format(self.database_link)[:1024]

@staticmethod
def _get_container_id(container_or_id):
# type: (Union[str, ContainerProxy, Dict[str, Any]]) -> str
Expand Down
4 changes: 4 additions & 0 deletions sdk/cosmos/azure-cosmos/azure/cosmos/partition_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 "<PartitionKey [{}]>".format(self.path)[:1024]

@property
def kind(self):
return self["kind"]
Expand Down
4 changes: 4 additions & 0 deletions sdk/cosmos/azure-cosmos/azure/cosmos/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 "<UserProxy [{}]>".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):
Expand Down

0 comments on commit ecaac22

Please sign in to comment.