Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Cosmos] Next-Pylint support #31096

Merged
merged 24 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
56a82e5
sync client public surface area
simorenoh Jul 11, 2023
7dabb38
sync private files
simorenoh Jul 12, 2023
1838dac
private async files
simorenoh Jul 13, 2023
f3038ab
small fixes
simorenoh Jul 13, 2023
df7072e
long lines
simorenoh Jul 13, 2023
53586c2
removing populate_query_metrics from irrelevant methods
simorenoh Jul 14, 2023
052411b
Update CHANGELOG.md
simorenoh Jul 14, 2023
f0ed97e
Update test_diagnostics.py
simorenoh Jul 17, 2023
9446a8f
spellcheck on ci
simorenoh Jul 17, 2023
7987e5c
Merge branch 'main' into next-pylint-cosmos
simorenoh Jul 26, 2023
dab254a
revert removal of populate query metrics, add pylint ignore for each
simorenoh Jul 31, 2023
0f4c64c
some changes from comments
simorenoh Aug 28, 2023
2ee0a13
Update sdk/cosmos/azure-cosmos/azure/cosmos/database.py
simorenoh Aug 28, 2023
0888f45
Update diagnostics.py
simorenoh Aug 28, 2023
06f21d9
Merge branch 'next-pylint-cosmos' of https://github.com/simorenoh/azu…
simorenoh Aug 28, 2023
45b2fd2
changes to make documentation look good again
simorenoh Aug 29, 2023
7f1b456
Merge branch 'main' into next-pylint-cosmos
annatisch Sep 14, 2023
a2e03e7
update core version
simorenoh Sep 19, 2023
cdabb2c
Update sdk/cosmos/azure-cosmos/azure/cosmos/database.py
simorenoh Sep 19, 2023
2e4c37b
Update sdk/cosmos/azure-cosmos/azure/cosmos/database.py
simorenoh Sep 19, 2023
11db4b8
removal of user.UserProxy/ partition_key.PartitionKey
simorenoh Sep 19, 2023
25fa8a8
Update container.py
simorenoh Sep 19, 2023
ac0b780
Merge branch 'next-pylint-cosmos' of https://github.com/simorenoh/azu…
simorenoh Sep 19, 2023
76f2203
Merge branch 'main' into next-pylint-cosmos
simorenoh Oct 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions sdk/cosmos/azure-cosmos/azure/cosmos/_auth_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,10 @@ def send(self, request):
# type: (PipelineRequest) -> PipelineResponse
"""Authorize request with a bearer token and send it to the next policy

:param request: The pipeline request object
:param request: The pipeline request object.
:type request: ~azure.core.pipeline.PipelineRequest
:returns: The pipeline response object.
:rtype: ~azure.core.pipeline.PipelineResponse
"""
self.on_request(request)
try:
Expand Down Expand Up @@ -138,9 +140,10 @@ def on_challenge(self, request, response):

:param ~azure.core.pipeline.PipelineRequest request: the request which elicited an authentication challenge
:param ~azure.core.pipeline.PipelineResponse response: the resource provider's response
:returns: a bool indicating whether the policy should send the request
:returns: a boolean indicating whether the policy should send the request
:rtype: bool
"""
# pylint:disable=unused-argument,no-self-use
# pylint:disable=unused-argument
return False

def on_response(self, request, response):
Expand All @@ -162,5 +165,5 @@ def on_exception(self, request):
:param request: The Pipeline request object
:type request: ~azure.core.pipeline.PipelineRequest
"""
# pylint: disable=no-self-use,unused-argument
# pylint: disable=unused-argument
return
30 changes: 17 additions & 13 deletions sdk/cosmos/azure-cosmos/azure/cosmos/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def GetHeaders( # pylint: disable=too-many-statements,too-many-branches
):
"""Gets HTTP request headers.

:param cosmos_client_connection.CosmosClient cosmos_client:
:param _cosmos_client_connection.CosmosClientConnection cosmos_client_connection:
:param dict default_headers:
:param str verb:
:param str path:
Expand Down Expand Up @@ -229,10 +229,11 @@ def GetHeaders( # pylint: disable=too-many-statements,too-many-branches
headers[http_constants.HttpHeaders.PopulateQueryMetrics] = options["populateQueryMetrics"]

if options.get("responseContinuationTokenLimitInKb"):
headers[http_constants.HttpHeaders.ResponseContinuationTokenLimitInKb] = options["responseContinuationTokenLimitInKb"] # pylint: disable=line-too-long
headers[http_constants.HttpHeaders.ResponseContinuationTokenLimitInKb] = options[
"responseContinuationTokenLimitInKb"]

if cosmos_client_connection.master_key:
#formatedate guarantees RFC 1123 date format regardless of current locale
# formatedate guarantees RFC 1123 date format regardless of current locale
headers[http_constants.HttpHeaders.XDate] = formatdate(timeval=None, localtime=False, usegmt=True)

if cosmos_client_connection.master_key or cosmos_client_connection.resource_tokens:
Expand Down Expand Up @@ -491,7 +492,7 @@ def IsItemContainerLink(link): # pylint: disable=too-many-return-statements
return True


def GetItemContainerInfo(self_link, alt_content_path, id_from_response):
def GetItemContainerInfo(self_link, alt_content_path, resource_id):
"""Given the self link and alt_content_path from the response header and
result extract the collection name and collection id.

Expand Down Expand Up @@ -521,13 +522,13 @@ def GetItemContainerInfo(self_link, alt_content_path, id_from_response):
# this is a collection request
index_second_slash = IndexOfNth(alt_content_path, "/", 2)
if index_second_slash == -1:
collection_name = alt_content_path + "/colls/" + urllib_quote(id_from_response)
collection_name = alt_content_path + "/colls/" + urllib_quote(resource_id)
return collection_id, collection_name
collection_name = alt_content_path
return collection_id, collection_name
raise ValueError(
"Response Not from Server Partition, self_link: {0}, alt_content_path: {1}, id: {2}".format(
self_link, alt_content_path, id_from_response
self_link, alt_content_path, resource_id
)
)

Expand Down Expand Up @@ -700,11 +701,11 @@ def _set_throughput_options(offer: Union[int, ThroughputProperties], request_opt
if offer.offer_throughput:
request_options["offerThroughput"] = offer.offer_throughput

except AttributeError:
except AttributeError as e:
if isinstance(offer, int):
request_options["offerThroughput"] = offer
else:
raise TypeError("offer_throughput must be int or an instance of ThroughputProperties")
raise TypeError("offer_throughput must be int or an instance of ThroughputProperties") from e


def _deserialize_throughput(throughput: list) -> Any:
Expand Down Expand Up @@ -739,18 +740,21 @@ def _replace_throughput(throughput: Union[int, ThroughputProperties], new_throug
if throughput.offer_throughput:
new_throughput_properties["content"]["offerThroughput"] = throughput.offer_throughput

except AttributeError:
except AttributeError as e:
if isinstance(throughput, int):
new_throughput_properties["content"]["offerThroughput"] = throughput
else:
raise TypeError("offer_throughput must be int or an instance of ThroughputProperties")
raise TypeError("offer_throughput must be int or an instance of ThroughputProperties") from e


def _internal_resourcetype(resource_type: str) -> str:
"""Partitionkey is used as the resource type for deleting all items by partition key in
other SDKs, but the colls resource type needs to be sent for the feature to work. In order to keep it consistent
"""Partition key is used as the resource type for deleting all items by partition key in other SDKs,
but the colls (collection) resource type needs to be sent for the feature to work. In order to keep it consistent
with other SDKs, we switch it here.
:param str resource_type: the resource type
:return: the resource type after checking if we're doing partition key delete.
:rtype: str
"""
if resource_type.lower() == "partitionkey":
if resource_type.lower() == "partitionkey":
return "colls"
return resource_type
Loading