26
26
"""
27
27
# https://github.com/PyCQA/pylint/issues/3112
28
28
# Currently pylint is locked to 2.3.3 and this is fixed in 2.4.4
29
- from typing import Dict , Any , Optional # pylint: disable=unused-import
30
- import six
29
+ from typing import Dict , Any , Optional # pylint: disable=unused-import
30
+ import urllib . parse
31
31
from urllib3 .util .retry import Retry
32
32
from azure .core .paging import ItemPaged # type: ignore
33
33
from azure .core import PipelineClient # type: ignore
59
59
from . import _utils
60
60
from .partition_key import _Undefined , _Empty
61
61
62
+
62
63
# pylint: disable=protected-access
63
64
64
65
@@ -87,12 +88,12 @@ class _QueryCompatibilityMode:
87
88
_DefaultStringRangePrecision = - 1
88
89
89
90
def __init__ (
90
- self ,
91
- url_connection , # type: str
92
- auth , # type: Dict[str, Any]
93
- connection_policy = None , # type: Optional[ConnectionPolicy]
94
- consistency_level = documents .ConsistencyLevel .Session , # type: str
95
- ** kwargs # type: Any
91
+ self ,
92
+ url_connection , # type: str
93
+ auth , # type: Dict[str, Any]
94
+ connection_policy = None , # type: Optional[ConnectionPolicy]
95
+ consistency_level = documents .ConsistencyLevel .Session , # type: str
96
+ ** kwargs # type: Any
96
97
):
97
98
# type: (...) -> None
98
99
"""
@@ -177,9 +178,9 @@ def __init__(
177
178
proxies = kwargs .pop ('proxies' , {})
178
179
if self .connection_policy .ProxyConfiguration and self .connection_policy .ProxyConfiguration .Host :
179
180
host = self .connection_policy .ProxyConfiguration .Host
180
- url = six . moves . urllib .parse .urlparse (host )
181
+ url = urllib .parse .urlparse (host )
181
182
proxy = host if url .port else host + ":" + str (self .connection_policy .ProxyConfiguration .Port )
182
- proxies .update ({url .scheme : proxy })
183
+ proxies .update ({url .scheme : proxy })
183
184
184
185
policies = [
185
186
HeadersPolicy (** kwargs ),
@@ -191,7 +192,7 @@ def __init__(
191
192
NetworkTraceLoggingPolicy (** kwargs ),
192
193
DistributedTracingPolicy (** kwargs ),
193
194
HttpLoggingPolicy (** kwargs ),
194
- ]
195
+ ]
195
196
196
197
transport = kwargs .pop ("transport" , None )
197
198
self .pipeline_client = PipelineClient (base_url = url_connection , transport = transport , policies = policies )
@@ -840,13 +841,13 @@ def ReadItems(self, collection_link, feed_options=None, response_hook=None, **kw
840
841
return self .QueryItems (collection_link , None , feed_options , response_hook = response_hook , ** kwargs )
841
842
842
843
def QueryItems (
843
- self ,
844
- database_or_container_link ,
845
- query ,
846
- options = None ,
847
- partition_key = None ,
848
- response_hook = None ,
849
- ** kwargs
844
+ self ,
845
+ database_or_container_link ,
846
+ query ,
847
+ options = None ,
848
+ partition_key = None ,
849
+ response_hook = None ,
850
+ ** kwargs
850
851
):
851
852
"""Queries documents in a collection.
852
853
@@ -936,7 +937,8 @@ def QueryItemsChangeFeed(self, collection_link, options=None, response_hook=None
936
937
)
937
938
938
939
def _QueryChangeFeed (
939
- self , collection_link , resource_type , options = None , partition_key_range_id = None , response_hook = None , ** kwargs
940
+ self , collection_link , resource_type , options = None , partition_key_range_id = None , response_hook = None ,
941
+ ** kwargs
940
942
):
941
943
"""Queries change feed of a resource in a collection.
942
944
@@ -1129,10 +1131,10 @@ def UpsertItem(self, database_or_container_link, document, options=None, **kwarg
1129
1131
return self .Upsert (document , path , "docs" , collection_id , None , options , ** kwargs )
1130
1132
1131
1133
PartitionResolverErrorMessage = (
1132
- "Couldn't find any partition resolvers for the database link provided. "
1133
- + "Ensure that the link you used when registering the partition resolvers "
1134
- + "matches the link provided or you need to register both types of database "
1135
- + "link(self link as well as ID based link)."
1134
+ "Couldn't find any partition resolvers for the database link provided. "
1135
+ + "Ensure that the link you used when registering the partition resolvers "
1136
+ + "matches the link provided or you need to register both types of database "
1137
+ + "link(self link as well as ID based link)."
1136
1138
)
1137
1139
1138
1140
# Gets the collection id and path for the document
@@ -2040,7 +2042,7 @@ def GetDatabaseAccount(self, url_connection=None, **kwargs):
2040
2042
]
2041
2043
2042
2044
self ._useMultipleWriteLocations = (
2043
- self .connection_policy .UseMultipleWriteLocations and database_account ._EnableMultipleWritableLocations
2045
+ self .connection_policy .UseMultipleWriteLocations and database_account ._EnableMultipleWritableLocations
2044
2046
)
2045
2047
return database_account
2046
2048
@@ -2107,7 +2109,8 @@ def Upsert(self, body, path, typ, id, initial_headers, options=None, **kwargs):
2107
2109
self ._UpdateSessionIfRequired (headers , result , self .last_response_headers )
2108
2110
return result
2109
2111
2110
- def Replace (self , resource , path , typ , id , initial_headers , options = None , ** kwargs ): # pylint: disable=redefined-builtin
2112
+ def Replace (self , resource , path , typ , id , initial_headers , options = None ,
2113
+ ** kwargs ): # pylint: disable=redefined-builtin
2111
2114
"""Replaces a Azure Cosmos resource and returns it.
2112
2115
2113
2116
:param dict resource:
@@ -2163,7 +2166,8 @@ def Read(self, path, typ, id, initial_headers, options=None, **kwargs): # pylin
2163
2166
result , self .last_response_headers = self .__Get (path , request_params , headers , ** kwargs )
2164
2167
return result
2165
2168
2166
- def DeleteResource (self , path , typ , id , initial_headers , options = None , ** kwargs ): # pylint: disable=redefined-builtin
2169
+ def DeleteResource (self , path , typ , id , initial_headers , options = None ,
2170
+ ** kwargs ): # pylint: disable=redefined-builtin
2167
2171
"""Deletes a Azure Cosmos resource and returns it.
2168
2172
2169
2173
:param str path:
@@ -2327,18 +2331,18 @@ def QueryFeed(self, path, collection_id, query, options, partition_key_range_id=
2327
2331
)
2328
2332
2329
2333
def __QueryFeed (
2330
- self ,
2331
- path ,
2332
- typ ,
2333
- id_ ,
2334
- result_fn ,
2335
- create_fn ,
2336
- query ,
2337
- options = None ,
2338
- partition_key_range_id = None ,
2339
- response_hook = None ,
2340
- is_query_plan = False ,
2341
- ** kwargs
2334
+ self ,
2335
+ path ,
2336
+ typ ,
2337
+ id_ ,
2338
+ result_fn ,
2339
+ create_fn ,
2340
+ query ,
2341
+ options = None ,
2342
+ partition_key_range_id = None ,
2343
+ response_hook = None ,
2344
+ is_query_plan = False ,
2345
+ ** kwargs
2342
2346
):
2343
2347
"""Query for more than one Azure Cosmos resources.
2344
2348
@@ -2380,8 +2384,8 @@ def __GetBodiesFromQueryResult(result):
2380
2384
# Copy to make sure that default_headers won't be changed.
2381
2385
if query is None :
2382
2386
# Query operations will use ReadEndpoint even though it uses GET(for feed requests)
2383
- request_params = _request_object .RequestObject (typ ,
2384
- documents ._OperationType .QueryPlan if is_query_plan else documents ._OperationType .ReadFeed )
2387
+ request_params = _request_object .RequestObject (
2388
+ typ , documents ._OperationType .QueryPlan if is_query_plan else documents ._OperationType .ReadFeed )
2385
2389
headers = base .GetHeaders (self , initial_headers , "get" , path , id_ , typ , options , partition_key_range_id )
2386
2390
result , self .last_response_headers = self .__Get (path , request_params , headers , ** kwargs )
2387
2391
if response_hook :
@@ -2395,8 +2399,8 @@ def __GetBodiesFromQueryResult(result):
2395
2399
initial_headers [http_constants .HttpHeaders .IsQuery ] = "true"
2396
2400
2397
2401
if (
2398
- self ._query_compatibility_mode == CosmosClientConnection ._QueryCompatibilityMode .Default
2399
- or self ._query_compatibility_mode == CosmosClientConnection ._QueryCompatibilityMode .Query
2402
+ self ._query_compatibility_mode == CosmosClientConnection ._QueryCompatibilityMode .Default
2403
+ or self ._query_compatibility_mode == CosmosClientConnection ._QueryCompatibilityMode .Query
2400
2404
):
2401
2405
initial_headers [http_constants .HttpHeaders .ContentType ] = runtime_constants .MediaTypes .QueryJson
2402
2406
elif self ._query_compatibility_mode == CosmosClientConnection ._QueryCompatibilityMode .SqlQuery :
@@ -2428,7 +2432,7 @@ def _GetQueryPlanThroughGateway(self, query, resource_link, **kwargs):
2428
2432
"isQueryPlanRequest" : True ,
2429
2433
"supportedQueryFeatures" : supported_query_features ,
2430
2434
"queryVersion" : http_constants .Versions .QueryVersion
2431
- }
2435
+ }
2432
2436
2433
2437
resource_link = base .TrimBeginningAndEndingSlashes (resource_link )
2434
2438
path = base .GetPathFromLink (resource_link , "docs" )
@@ -2459,18 +2463,18 @@ def __CheckAndUnifyQueryFormat(self, query_body):
2459
2463
dict or string
2460
2464
"""
2461
2465
if (
2462
- self ._query_compatibility_mode == CosmosClientConnection ._QueryCompatibilityMode .Default
2463
- or self ._query_compatibility_mode == CosmosClientConnection ._QueryCompatibilityMode .Query
2466
+ self ._query_compatibility_mode == CosmosClientConnection ._QueryCompatibilityMode .Default
2467
+ or self ._query_compatibility_mode == CosmosClientConnection ._QueryCompatibilityMode .Query
2464
2468
):
2465
- if not isinstance (query_body , dict ) and not isinstance (query_body , six . string_types ):
2469
+ if not isinstance (query_body , dict ) and not isinstance (query_body , str ):
2466
2470
raise TypeError ("query body must be a dict or string." )
2467
2471
if isinstance (query_body , dict ) and not query_body .get ("query" ):
2468
2472
raise ValueError ('query body must have valid query text with key "query".' )
2469
- if isinstance (query_body , six . string_types ):
2473
+ if isinstance (query_body , str ):
2470
2474
return {"query" : query_body }
2471
2475
elif (
2472
- self ._query_compatibility_mode == CosmosClientConnection ._QueryCompatibilityMode .SqlQuery
2473
- and not isinstance (query_body , six . string_types )
2476
+ self ._query_compatibility_mode == CosmosClientConnection ._QueryCompatibilityMode .SqlQuery
2477
+ and not isinstance (query_body , str )
2474
2478
):
2475
2479
raise TypeError ("query body must be a string." )
2476
2480
else :
0 commit comments