Skip to content

Commit def10f4

Browse files
authored
Clean up public surface (#43124)
* Clean up public surface since list GA * Fixed return types * Remove unused imports * Remove List type
1 parent 5631058 commit def10f4

File tree

4 files changed

+29
-29
lines changed

4 files changed

+29
-29
lines changed

sdk/cosmos/azure-cosmos/azure/cosmos/_global_endpoint_manager.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,10 @@ def _endpoints_health_check(self, **kwargs):
188188
self.location_cache.location_unavailability_info_by_endpoint):
189189
# if the endpoint is unavailable, we need to lower the timeouts to be more aggressive in the
190190
# health check. This helps reduce the time the health check is blocking all requests.
191-
self.client.connection_policy.override_dba_timeouts(constants._Constants
192-
.UnavailableEndpointDBATimeouts,
193-
constants._Constants
194-
.UnavailableEndpointDBATimeouts)
191+
self.client.connection_policy._override_dba_timeouts(constants._Constants
192+
.UnavailableEndpointDBATimeouts,
193+
constants._Constants
194+
.UnavailableEndpointDBATimeouts)
195195
self.client._GetDatabaseAccountCheck(endpoint, **kwargs)
196196
else:
197197
self.client._GetDatabaseAccountCheck(endpoint, **kwargs)
@@ -202,8 +202,8 @@ def _endpoints_health_check(self, **kwargs):
202202

203203
finally:
204204
# after the health check for that endpoint setting the timeouts back to their original values
205-
self.client.connection_policy.override_dba_timeouts(previous_dba_read_timeout,
206-
previous_dba_connection_timeout)
205+
self.client.connection_policy._override_dba_timeouts(previous_dba_read_timeout,
206+
previous_dba_connection_timeout)
207207
self.location_cache.update_location_cache()
208208

209209
def _GetDatabaseAccountStub(self, endpoint, **kwargs):
@@ -220,15 +220,15 @@ def _GetDatabaseAccountStub(self, endpoint, **kwargs):
220220
try:
221221
# if the endpoint is unavailable, we need to lower the timeouts to be more aggressive in the
222222
# health check. This helps reduce the time the health check is blocking all requests.
223-
self.client.connection_policy.override_dba_timeouts(constants._Constants
224-
.UnavailableEndpointDBATimeouts,
225-
constants._Constants
226-
.UnavailableEndpointDBATimeouts)
223+
self.client.connection_policy._override_dba_timeouts(constants._Constants
224+
.UnavailableEndpointDBATimeouts,
225+
constants._Constants
226+
.UnavailableEndpointDBATimeouts)
227227
database_account = self.client.GetDatabaseAccount(endpoint, **kwargs)
228228
finally:
229229
# after the health check for that endpoint setting the timeouts back to their original values
230-
self.client.connection_policy.override_dba_timeouts(previous_dba_read_timeout,
231-
previous_dba_connection_timeout)
230+
self.client.connection_policy._override_dba_timeouts(previous_dba_read_timeout,
231+
previous_dba_connection_timeout)
232232
else:
233233
database_account = self.client.GetDatabaseAccount(endpoint, **kwargs)
234234
return database_account

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
# pylint: disable=missing-client-constructor-parameter-credential,missing-client-constructor-parameter-kwargs
6666
# pylint: disable=docstring-keyword-should-match-keyword-only
6767

68-
def get_epk_range_for_partition_key(
68+
def _get_epk_range_for_partition_key(
6969
container_properties: Dict[str, Any],
7070
partition_key_value: _PartitionKeyType) -> Range:
7171
partition_key_obj: PartitionKey = _build_partition_key_from_properties(container_properties)
@@ -657,7 +657,7 @@ def query_items_change_feed(
657657
partition_key = kwargs.pop("partition_key")
658658
change_feed_state_context["partitionKey"] = self._set_partition_key(cast(_PartitionKeyType, partition_key))
659659
change_feed_state_context["partitionKeyFeedRange"] = \
660-
get_epk_range_for_partition_key(container_properties, partition_key)
660+
_get_epk_range_for_partition_key(container_properties, partition_key)
661661
if "feed_range" in kwargs:
662662
change_feed_state_context["feedRange"] = kwargs.pop('feed_range')
663663
if "continuation" in feed_options:
@@ -1910,7 +1910,7 @@ def feed_range_from_partition_key(self, partition_key: _PartitionKeyType) -> Dic
19101910
"""
19111911
container_properties = self._get_properties()
19121912
partition_key_value = self._set_partition_key(partition_key)
1913-
epk_range_for_partition_key = get_epk_range_for_partition_key(container_properties, partition_key_value)
1913+
epk_range_for_partition_key = _get_epk_range_for_partition_key(container_properties, partition_key_value)
19141914
return FeedRangeInternalEpk(epk_range_for_partition_key).to_dict()
19151915

19161916
def is_feed_range_subset(self, parent_feed_range: Dict[str, Any], child_feed_range: Dict[str, Any]) -> bool:

sdk/cosmos/azure-cosmos/azure/cosmos/documents.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"""Classes and enums for documents in the Azure Cosmos database service.
2323
"""
2424

25-
from typing import List, Optional, TYPE_CHECKING, Union, Dict, Any
25+
from typing import Optional, TYPE_CHECKING, Union
2626

2727
from typing_extensions import Literal, TypedDict
2828

@@ -75,23 +75,23 @@ def __init__(self) -> None:
7575
self.ReservedDocumentStorageInMB: int = 0
7676
self.ProvisionedDocumentStorageInMB: int = 0
7777
self.ConsistencyPolicy: Optional[UserConsistencyPolicy] = None
78-
self._WritableLocations: List[dict] = []
79-
self._ReadableLocations: List[dict] = []
78+
self._WritableLocations: list[dict[str, str]] = []
79+
self._ReadableLocations: list[dict[str, str]] = []
8080
self._EnableMultipleWritableLocations = False
8181

8282
@property
83-
def WritableLocations(self) -> List[Dict[Any, Any]]:
83+
def WritableLocations(self) -> list[dict[str, str]]:
8484
"""The list of writable locations for a geo-replicated database account.
8585
:returns: List of writable locations for the database account.
86-
:rtype: List[str]
86+
:rtype: list[dict[str, str]]
8787
"""
8888
return self._WritableLocations
8989

9090
@property
91-
def ReadableLocations(self) -> List[Dict[Any, Any]]:
91+
def ReadableLocations(self) -> list[dict[str, str]]:
9292
"""The list of readable locations for a geo-replicated database account.
9393
:returns: List of readable locations for the database account.
94-
:rtype: List[str]
94+
:rtype: list[dict[str, str]]
9595
"""
9696
return self._ReadableLocations
9797

@@ -307,14 +307,14 @@ class ConnectionPolicy: # pylint: disable=too-many-instance-attributes
307307
taking into consideration the order specified in PreferredLocations. The
308308
locations in this list are specified as the names of the azure Cosmos
309309
locations like, 'West US', 'East US', 'Central India' and so on.
310-
:vartype PreferredLocations: List[str]
310+
:vartype PreferredLocations: list[str]
311311
:ivar ExcludedLocations:
312312
Gets or sets the excluded locations for geo-replicated database
313313
accounts. When ExcludedLocations is non-empty, the client will skip this
314314
set of locations from the final location evaluation. The locations in
315315
this list are specified as the names of the azure Cosmos locations like,
316316
'West US', 'East US', 'Central India' and so on.
317-
:vartype ExcludedLocations: List[str]
317+
:vartype ExcludedLocations: list[str]
318318
:ivar RetryOptions:
319319
Gets or sets the retry options to be applied to all requests when
320320
retrying.
@@ -359,16 +359,16 @@ def __init__(self) -> None:
359359
self.SSLConfiguration: Optional[SSLConfiguration] = None
360360
self.ProxyConfiguration: Optional[ProxyConfiguration] = None
361361
self.EnableEndpointDiscovery: bool = True
362-
self.PreferredLocations: List[str] = []
363-
self.ExcludedLocations: Optional[List[str]] = None
362+
self.PreferredLocations: list[str] = []
363+
self.ExcludedLocations: Optional[list[str]] = None
364364
self.RetryOptions: RetryOptions = RetryOptions()
365365
self.DisableSSLVerification: bool = False
366366
self.UseMultipleWriteLocations: bool = False
367367
self.ConnectionRetryConfiguration: Optional["ConnectionRetryPolicy"] = None
368368
self.ResponsePayloadOnWriteDisabled: bool = False
369369
self.RetryNonIdempotentWrites: bool = False
370370

371-
def override_dba_timeouts(
371+
def _override_dba_timeouts(
372372
self,
373373
connection_timeout: Optional[int] = None,
374374
read_timeout: Optional[int] = None

sdk/cosmos/azure-cosmos/tests/test_changefeed_partition_key_variation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import azure.cosmos.cosmos_client as cosmos_client
99
import test_config
1010
from azure.cosmos.partition_key import PartitionKey, _get_partition_key_from_partition_key_definition
11-
from azure.cosmos.container import get_epk_range_for_partition_key
11+
from azure.cosmos.container import _get_epk_range_for_partition_key
1212

1313
@pytest.mark.cosmosEmulator
1414
class TestChangeFeedPKVariation(unittest.TestCase):
@@ -263,7 +263,7 @@ def _get_properties_override():
263263

264264
for item in items:
265265
try:
266-
epk_range = get_epk_range_for_partition_key(container_properties, item["pk"])
266+
epk_range = _get_epk_range_for_partition_key(container_properties, item["pk"])
267267
assert epk_range is not None, f"EPK range should not be None for partition key {item['pk']}."
268268
except Exception as e:
269269
assert False, f"Failed to get EPK range for partition key {item['pk']}: {str(e)}"

0 commit comments

Comments
 (0)