From 1c2781c5ccfcadb9b22c596fc23a3f2dc724506f Mon Sep 17 00:00:00 2001 From: Yalin Li Date: Mon, 9 Sep 2024 20:17:48 -0700 Subject: [PATCH] [ACR] Fix content validation issues for github.io (#37269) --- .../azure-containerregistry/README.md | 20 +++--- .../_anonymous_exchange_client.py | 6 +- .../azure/containerregistry/_base_client.py | 2 +- .../_container_registry_client.py | 66 ++++++++++--------- .../containerregistry/_exchange_client.py | 8 +-- .../_generated/aio/operations/_patch.py | 4 +- .../_generated/operations/_patch.py | 4 +- .../aio/_async_anonymous_exchange_client.py | 6 +- .../aio/_async_base_client.py | 2 +- .../aio/_async_container_registry_client.py | 66 ++++++++++--------- .../aio/_async_exchange_client.py | 8 +-- 11 files changed, 98 insertions(+), 94 deletions(-) diff --git a/sdk/containerregistry/azure-containerregistry/README.md b/sdk/containerregistry/azure-containerregistry/README.md index 584300d7803..e70242a5cde 100644 --- a/sdk/containerregistry/azure-containerregistry/README.md +++ b/sdk/containerregistry/azure-containerregistry/README.md @@ -65,15 +65,15 @@ For more information please see [Container Registry Concepts](https://docs.micro The following sections provide several code snippets covering some of the most common ACR Service tasks, including: - Registry operations: - - [List repositories](#list-repositories) - - [List tags with anonymous access](#list-tags-with-anonymous-access) - - [Set artifact properties](#set-artifact-properties) - - [Delete images](#delete-images) + - [List repositories](#list-repositories "List repositories") + - [List tags with anonymous access](#list-tags-with-anonymous-access "List tags with anonymous access") + - [Set artifact properties](#set-artifact-properties "Set artifact properties") + - [Delete images](#delete-images "Delete images") - Blob and manifest operations: - - [Upload images](#upload-images) - - [Download images](#download-images) - - [Delete manifest](#delete-manifest) - - [Delete blob](#delete-blob) + - [Upload images](#upload-images "Upload images") + - [Download images](#download-images "Download images") + - [Delete manifests](#delete-manifests "Delete manifests") + - [Delete blobs](#delete-blobs "Delete blobs") Please note that each sample assumes there is a `CONTAINERREGISTRY_ENDPOINT` environment variable set to a string containing the `https://` prefix and the name of the login server, for example "https://myregistry.azurecr.io". Anonymous access samples are getting endpoint value from environment variable`CONTAINERREGISTRY_ANONREGISTRY_ENDPOINT`. @@ -238,7 +238,7 @@ with ContainerRegistryClient(self.endpoint, self.credential) as client: -### Delete manifest +### Delete manifests @@ -251,7 +251,7 @@ with ContainerRegistryClient(self.endpoint, self.credential) as client: -### Delete blob +### Delete blobs diff --git a/sdk/containerregistry/azure-containerregistry/azure/containerregistry/_anonymous_exchange_client.py b/sdk/containerregistry/azure-containerregistry/azure/containerregistry/_anonymous_exchange_client.py index fcef7c52652..1963936fde9 100644 --- a/sdk/containerregistry/azure-containerregistry/azure/containerregistry/_anonymous_exchange_client.py +++ b/sdk/containerregistry/azure-containerregistry/azure/containerregistry/_anonymous_exchange_client.py @@ -17,7 +17,7 @@ from ._user_agent import USER_AGENT class AnonymousAccessCredential(TokenCredential): def get_token( - self, *scopes: str, claims: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs + self, *scopes: str, claims: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any ) -> AccessToken: raise ValueError("This credential cannot be used to obtain access tokens.") @@ -46,7 +46,7 @@ class AnonymousACRExchangeClient(object): ) def get_acr_access_token( # pylint:disable=client-method-missing-tracing-decorator - self, challenge: str, **kwargs + self, challenge: str, **kwargs: Any ) -> Optional[str]: parsed_challenge = _parse_challenge(challenge) return self.exchange_refresh_token_for_access_token( @@ -58,7 +58,7 @@ class AnonymousACRExchangeClient(object): ) def exchange_refresh_token_for_access_token( # pylint:disable=client-method-missing-tracing-decorator - self, refresh_token: str, service: str, scope: str, grant_type: Union[str, TokenGrantType], **kwargs + self, refresh_token: str, service: str, scope: str, grant_type: Union[str, TokenGrantType], **kwargs: Any ) -> Optional[str]: auth_operation = cast(AuthenticationOperations, self._client.authentication) access_token = auth_operation.exchange_acr_refresh_token_for_acr_access_token( diff --git a/sdk/containerregistry/azure-containerregistry/azure/containerregistry/_base_client.py b/sdk/containerregistry/azure-containerregistry/azure/containerregistry/_base_client.py index 6008f02e04d..042b3474e3b 100644 --- a/sdk/containerregistry/azure-containerregistry/azure/containerregistry/_base_client.py +++ b/sdk/containerregistry/azure-containerregistry/azure/containerregistry/_base_client.py @@ -71,7 +71,7 @@ class TransportWrapper(HttpTransport): def __init__(self, transport): self._transport = transport - def send(self, request, **kwargs): + def send(self, request, **kwargs: Any): return self._transport.send(request, **kwargs) def open(self): diff --git a/sdk/containerregistry/azure-containerregistry/azure/containerregistry/_container_registry_client.py b/sdk/containerregistry/azure-containerregistry/azure/containerregistry/_container_registry_client.py index a8156d38c7f..97a1d66e95d 100644 --- a/sdk/containerregistry/azure-containerregistry/azure/containerregistry/_container_registry_client.py +++ b/sdk/containerregistry/azure-containerregistry/azure/containerregistry/_container_registry_client.py @@ -117,14 +117,14 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): return tag_props.digest @distributed_trace - def delete_repository(self, repository: str, **kwargs) -> None: + def delete_repository(self, repository: str, **kwargs: Any) -> None: """Delete a repository. If the repository cannot be found or a response status code of 404 is returned an error will not be raised. :param str repository: The repository to delete :returns: None :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: .. admonition:: Example: @@ -138,14 +138,14 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): self._client.container_registry.delete_repository(repository, **kwargs) @distributed_trace - def list_repository_names(self, *, results_per_page: Optional[int] = None, **kwargs) -> ItemPaged[str]: + def list_repository_names(self, *, results_per_page: Optional[int] = None, **kwargs: Any) -> ItemPaged[str]: """List all repositories :keyword results_per_page: Number of repositories to return per page :paramtype results_per_page: int :returns: An iterable of strings :rtype: ~azure.core.paging.ItemPaged[str] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: .. admonition:: Example: @@ -244,13 +244,13 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): return ItemPaged(get_next, extract_data) @distributed_trace - def get_repository_properties(self, repository: str, **kwargs) -> RepositoryProperties: + def get_repository_properties(self, repository: str, **kwargs: Any) -> RepositoryProperties: """Get the properties of a repository :param str repository: Name of the repository :rtype: ~azure.containerregistry.RepositoryProperties :return: The properties of a repository - :raises: ~azure.core.exceptions.ResourceNotFoundError + :raises ~azure.core.exceptions.ResourceNotFoundError: """ return RepositoryProperties._from_generated( # pylint: disable=protected-access self._client.container_registry.get_properties(repository, **kwargs) @@ -263,7 +263,7 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): *, order_by: Optional[Union["ArtifactManifestOrder", str]] = None, results_per_page: Optional[int] = None, - **kwargs, + **kwargs: Any, ) -> ItemPaged[ArtifactManifestProperties]: """List the artifacts for a repository @@ -274,7 +274,7 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): :paramtype results_per_page: int :returns: An iterable of :class:`~azure.containerregistry.ArtifactManifestProperties` :rtype: ~azure.core.paging.ItemPaged[~azure.containerregistry.ArtifactManifestProperties] - :raises: ~azure.core.exceptions.ResourceNotFoundError + :raises ~azure.core.exceptions.ResourceNotFoundError: """ name = repository last = kwargs.pop("last", None) @@ -380,7 +380,7 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): return ItemPaged(get_next, extract_data) @distributed_trace - def delete_tag(self, repository: str, tag: str, **kwargs) -> None: + def delete_tag(self, repository: str, tag: str, **kwargs: Any) -> None: """Delete a tag from a repository. If the tag cannot be found or a response status code of 404 is returned an error will not be raised. @@ -388,7 +388,7 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): :param str tag: The tag to be deleted :returns: None :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: Example @@ -404,14 +404,14 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): self._client.container_registry.delete_tag(repository, tag, **kwargs) @distributed_trace - def get_manifest_properties(self, repository: str, tag_or_digest: str, **kwargs) -> ArtifactManifestProperties: + def get_manifest_properties(self, repository: str, tag_or_digest: str, **kwargs: Any) -> ArtifactManifestProperties: """Get the properties of a registry artifact :param str repository: Name of the repository :param str tag_or_digest: Tag or digest of the manifest :return: The properties of a registry artifact :rtype: ~azure.containerregistry.ArtifactManifestProperties - :raises: ~azure.core.exceptions.ResourceNotFoundError + :raises ~azure.core.exceptions.ResourceNotFoundError: Example @@ -437,14 +437,14 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): ) @distributed_trace - def get_tag_properties(self, repository: str, tag: str, **kwargs) -> ArtifactTagProperties: + def get_tag_properties(self, repository: str, tag: str, **kwargs: Any) -> ArtifactTagProperties: """Get the properties for a tag :param str repository: Name of the repository :param str tag: The tag to get tag properties for :return: The properties for a tag :rtype: ~azure.containerregistry.ArtifactTagProperties - :raises: ~azure.core.exceptions.ResourceNotFoundError + :raises ~azure.core.exceptions.ResourceNotFoundError: Example @@ -470,7 +470,7 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): *, order_by: Optional[Union["ArtifactTagOrder", str]] = None, results_per_page: Optional[int] = None, - **kwargs, + **kwargs: Any, ) -> ItemPaged[ArtifactTagProperties]: """List the tags for a repository @@ -481,7 +481,7 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): :paramtype results_per_page: int :returns: An iterable of :class:`~azure.containerregistry.ArtifactTagProperties` :rtype: ~azure.core.paging.ItemPaged[~azure.containerregistry.ArtifactTagProperties] - :raises: ~azure.core.exceptions.ResourceNotFoundError + :raises ~azure.core.exceptions.ResourceNotFoundError: Example @@ -612,7 +612,7 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): parameter. Please provide either this or individual keyword parameters. :type properties: ~azure.containerregistry.ArtifactManifestProperties :rtype: ~azure.containerregistry.ArtifactManifestProperties - :raises: ~azure.core.exceptions.ResourceNotFoundError + :raises ~azure.core.exceptions.ResourceNotFoundError: Example @@ -656,7 +656,7 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): :keyword bool can_read: Read permissions for a manifest. :keyword bool can_write: Write permissions for a manifest. :rtype: ~azure.containerregistry.ArtifactManifestProperties - :raises: ~azure.core.exceptions.ResourceNotFoundError + :raises ~azure.core.exceptions.ResourceNotFoundError: Example @@ -679,7 +679,7 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): @distributed_trace def update_manifest_properties( - self, *args: Union[str, ArtifactManifestProperties], **kwargs + self, *args: Union[str, ArtifactManifestProperties], **kwargs: Any ) -> ArtifactManifestProperties: repository = str(args[0]) tag_or_digest = str(args[1]) @@ -720,7 +720,7 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): parameter. Please provide either this or individual keyword parameters. :type properties: ~azure.containerregistry.ArtifactTagProperties :rtype: ~azure.containerregistry.ArtifactTagProperties - :raises: ~azure.core.exceptions.ResourceNotFoundError + :raises ~azure.core.exceptions.ResourceNotFoundError: Example @@ -761,7 +761,7 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): :keyword bool can_read: Read permissions for a tag. :keyword bool can_write: Write permissions for a tag. :rtype: ~azure.containerregistry.ArtifactTagProperties - :raises: ~azure.core.exceptions.ResourceNotFoundError + :raises ~azure.core.exceptions.ResourceNotFoundError: Example @@ -782,7 +782,7 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): """ @distributed_trace - def update_tag_properties(self, *args: Union[str, ArtifactTagProperties], **kwargs) -> ArtifactTagProperties: + def update_tag_properties(self, *args: Union[str, ArtifactTagProperties], **kwargs: Any) -> ArtifactTagProperties: repository = str(args[0]) tag = str(args[1]) properties = None @@ -817,7 +817,7 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): parameter. Please provide either this or individual keyword parameters. :type properties: ~azure.containerregistry.RepositoryProperties :rtype: ~azure.containerregistry.RepositoryProperties - :raises: ~azure.core.exceptions.ResourceNotFoundError + :raises ~azure.core.exceptions.ResourceNotFoundError: """ @overload @@ -841,11 +841,13 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): :keyword bool can_read: Read permissions for a repository. :keyword bool can_write: Write permissions for a repository. :rtype: ~azure.containerregistry.RepositoryProperties - :raises: ~azure.core.exceptions.ResourceNotFoundError + :raises ~azure.core.exceptions.ResourceNotFoundError: """ @distributed_trace - def update_repository_properties(self, *args: Union[str, RepositoryProperties], **kwargs) -> RepositoryProperties: + def update_repository_properties( + self, *args: Union[str, RepositoryProperties], **kwargs: Any + ) -> RepositoryProperties: repository = str(args[0]) properties = None if len(args) == 2: @@ -872,7 +874,7 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): *, tag: Optional[str] = None, media_type: str = OCI_IMAGE_MANIFEST, - **kwargs, + **kwargs: Any, ) -> str: """Set a manifest for an artifact. @@ -919,7 +921,7 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): return digest @distributed_trace - def get_manifest(self, repository: str, tag_or_digest: str, **kwargs) -> GetManifestResult: + def get_manifest(self, repository: str, tag_or_digest: str, **kwargs: Any) -> GetManifestResult: """Get the manifest for an artifact. :param str repository: Name of the repository. @@ -965,7 +967,7 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): return GetManifestResult(digest=digest, manifest=manifest_json, media_type=media_type) @distributed_trace - def upload_blob(self, repository: str, data: IO[bytes], **kwargs) -> Tuple[str, int]: + def upload_blob(self, repository: str, data: IO[bytes], **kwargs: Any) -> Tuple[str, int]: """Upload an artifact blob. :param str repository: Name of the repository. @@ -1017,7 +1019,7 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): return f"sha256:{hasher.hexdigest()}", location, blob_size @distributed_trace - def download_blob(self, repository: str, digest: str, **kwargs) -> DownloadBlobStream: + def download_blob(self, repository: str, digest: str, **kwargs: Any) -> DownloadBlobStream: """Download a blob that is part of an artifact to a stream. :param str repository: Name of the repository. @@ -1052,14 +1054,14 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): ) @distributed_trace - def delete_manifest(self, repository: str, tag_or_digest: str, **kwargs) -> None: + def delete_manifest(self, repository: str, tag_or_digest: str, **kwargs: Any) -> None: """Delete a manifest. If the manifest cannot be found or a response status code of 404 is returned an error will not be raised. :param str repository: Name of the repository the manifest belongs to :param str tag_or_digest: Tag or digest of the manifest to be deleted :returns: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: Example @@ -1077,7 +1079,7 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): self._client.container_registry.delete_manifest(repository, tag_or_digest, **kwargs) @distributed_trace - def delete_blob(self, repository: str, digest: str, **kwargs) -> None: + def delete_blob(self, repository: str, digest: str, **kwargs: Any) -> None: """Delete a blob. If the blob cannot be found or a response status code of 404 is returned an error will not be raised. diff --git a/sdk/containerregistry/azure-containerregistry/azure/containerregistry/_exchange_client.py b/sdk/containerregistry/azure-containerregistry/azure/containerregistry/_exchange_client.py index 7da05961bee..3fd6d3047a4 100644 --- a/sdk/containerregistry/azure-containerregistry/azure/containerregistry/_exchange_client.py +++ b/sdk/containerregistry/azure-containerregistry/azure/containerregistry/_exchange_client.py @@ -57,7 +57,7 @@ class ACRExchangeClient(object): self._expiration_time: float = 0 def get_acr_access_token( # pylint:disable=client-method-missing-tracing-decorator - self, challenge: str, **kwargs + self, challenge: str, **kwargs: Any ) -> Optional[str]: parsed_challenge = _parse_challenge(challenge) refresh_token = self.get_refresh_token(parsed_challenge["service"], **kwargs) @@ -66,7 +66,7 @@ class ACRExchangeClient(object): ) def get_refresh_token( # pylint:disable=client-method-missing-tracing-decorator - self, service: str, **kwargs + self, service: str, **kwargs: Any ) -> str: if not self._refresh_token or self._expiration_time - time.time() > 300: self._refresh_token = self.exchange_aad_token_for_refresh_token(service, **kwargs) @@ -74,7 +74,7 @@ class ACRExchangeClient(object): return self._refresh_token def exchange_aad_token_for_refresh_token( # pylint:disable=client-method-missing-tracing-decorator - self, service: str, **kwargs + self, service: str, **kwargs: Any ) -> str: auth_operation = cast(AuthenticationOperations, self._client.authentication) refresh_token = auth_operation.exchange_aad_access_token_for_acr_refresh_token( @@ -86,7 +86,7 @@ class ACRExchangeClient(object): return refresh_token.refresh_token if refresh_token.refresh_token is not None else "" def exchange_refresh_token_for_access_token( # pylint:disable=client-method-missing-tracing-decorator - self, refresh_token: str, service: str, scope: str, **kwargs + self, refresh_token: str, service: str, scope: str, **kwargs: Any ) -> Optional[str]: auth_operation = cast(AuthenticationOperations, self._client.authentication) access_token = auth_operation.exchange_acr_refresh_token_for_acr_access_token( diff --git a/sdk/containerregistry/azure-containerregistry/azure/containerregistry/_generated/aio/operations/_patch.py b/sdk/containerregistry/azure-containerregistry/azure/containerregistry/_generated/aio/operations/_patch.py index a2da554aba8..28f7b7d642e 100644 --- a/sdk/containerregistry/azure-containerregistry/azure/containerregistry/_generated/aio/operations/_patch.py +++ b/sdk/containerregistry/azure-containerregistry/azure/containerregistry/_generated/aio/operations/_patch.py @@ -60,7 +60,7 @@ class AuthenticationOperations(AuthenticationOperationsGenerated): :keyword callable cls: A custom type or function that will be passed the direct response :return: AcrRefreshToken, or the result of cls(response) :rtype: ~container_registry.models.AcrRefreshToken - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop("error_map", {}) or {}) @@ -134,7 +134,7 @@ class AuthenticationOperations(AuthenticationOperationsGenerated): :keyword callable cls: A custom type or function that will be passed the direct response :return: AcrAccessToken, or the result of cls(response) :rtype: ~container_registry.models.AcrAccessToken - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop("error_map", {}) or {}) diff --git a/sdk/containerregistry/azure-containerregistry/azure/containerregistry/_generated/operations/_patch.py b/sdk/containerregistry/azure-containerregistry/azure/containerregistry/_generated/operations/_patch.py index 9ddb4b7649e..1cdf038ca53 100644 --- a/sdk/containerregistry/azure-containerregistry/azure/containerregistry/_generated/operations/_patch.py +++ b/sdk/containerregistry/azure-containerregistry/azure/containerregistry/_generated/operations/_patch.py @@ -130,7 +130,7 @@ class AuthenticationOperations(AuthenticationOperationsGenerated): :keyword callable cls: A custom type or function that will be passed the direct response :return: AcrRefreshToken, or the result of cls(response) :rtype: ~container_registry.models.AcrRefreshToken - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop("error_map", {}) or {}) @@ -205,7 +205,7 @@ class AuthenticationOperations(AuthenticationOperationsGenerated): :keyword callable cls: A custom type or function that will be passed the direct response :return: AcrAccessToken, or the result of cls(response) :rtype: ~container_registry.models.AcrAccessToken - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop("error_map", {}) or {}) diff --git a/sdk/containerregistry/azure-containerregistry/azure/containerregistry/aio/_async_anonymous_exchange_client.py b/sdk/containerregistry/azure-containerregistry/azure/containerregistry/aio/_async_anonymous_exchange_client.py index 08a8ac3d302..3543382b9a2 100644 --- a/sdk/containerregistry/azure-containerregistry/azure/containerregistry/aio/_async_anonymous_exchange_client.py +++ b/sdk/containerregistry/azure-containerregistry/azure/containerregistry/aio/_async_anonymous_exchange_client.py @@ -19,7 +19,7 @@ from .._user_agent import USER_AGENT class AsyncAnonymousAccessCredential(AsyncTokenCredential): async def get_token( - self, *scopes: str, claims: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs + self, *scopes: str, claims: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any ) -> AccessToken: raise ValueError("This credential cannot be used to obtain access tokens.") @@ -62,7 +62,7 @@ class AnonymousACRExchangeClient(object): ) async def get_acr_access_token( # pylint:disable=client-method-missing-tracing-decorator-async - self, challenge: str, **kwargs + self, challenge: str, **kwargs: Any ) -> Optional[str]: parsed_challenge = _parse_challenge(challenge) return await self.exchange_refresh_token_for_access_token( @@ -74,7 +74,7 @@ class AnonymousACRExchangeClient(object): ) async def exchange_refresh_token_for_access_token( # pylint:disable=client-method-missing-tracing-decorator-async - self, refresh_token: str, service: str, scope: str, grant_type: Union[str, TokenGrantType], **kwargs + self, refresh_token: str, service: str, scope: str, grant_type: Union[str, TokenGrantType], **kwargs: Any ) -> Optional[str]: auth_operation = cast(AuthenticationOperations, self._client.authentication) access_token = await auth_operation.exchange_acr_refresh_token_for_acr_access_token( diff --git a/sdk/containerregistry/azure-containerregistry/azure/containerregistry/aio/_async_base_client.py b/sdk/containerregistry/azure-containerregistry/azure/containerregistry/aio/_async_base_client.py index 502f68249cd..fd260cdfa3f 100644 --- a/sdk/containerregistry/azure-containerregistry/azure/containerregistry/aio/_async_base_client.py +++ b/sdk/containerregistry/azure-containerregistry/azure/containerregistry/aio/_async_base_client.py @@ -75,7 +75,7 @@ class AsyncTransportWrapper(AsyncHttpTransport): def __init__(self, async_transport): self._transport = async_transport - async def send(self, request, **kwargs): + async def send(self, request, **kwargs: Any): return await self._transport.send(request, **kwargs) async def open(self): diff --git a/sdk/containerregistry/azure-containerregistry/azure/containerregistry/aio/_async_container_registry_client.py b/sdk/containerregistry/azure-containerregistry/azure/containerregistry/aio/_async_container_registry_client.py index 24fdaecd542..1da360b7f75 100644 --- a/sdk/containerregistry/azure-containerregistry/azure/containerregistry/aio/_async_container_registry_client.py +++ b/sdk/containerregistry/azure-containerregistry/azure/containerregistry/aio/_async_container_registry_client.py @@ -119,14 +119,14 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): return tag_props.digest @distributed_trace_async - async def delete_repository(self, repository: str, **kwargs) -> None: + async def delete_repository(self, repository: str, **kwargs: Any) -> None: """Delete a repository. If the repository cannot be found or a response status code of 404 is returned an error will not be raised. :param str repository: The repository to delete :returns: None :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: .. admonition:: Example: @@ -140,14 +140,14 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): await self._client.container_registry.delete_repository(repository, **kwargs) @distributed_trace - def list_repository_names(self, *, results_per_page: Optional[int] = None, **kwargs) -> AsyncItemPaged[str]: + def list_repository_names(self, *, results_per_page: Optional[int] = None, **kwargs: Any) -> AsyncItemPaged[str]: """List all repositories :keyword results_per_page: Number of repositories to return per page :paramtype results_per_page: int :returns: An iterable of strings :rtype: ~azure.core.async_paging.AsyncItemPaged[str] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: .. admonition:: Example: @@ -246,13 +246,13 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): return AsyncItemPaged(get_next, extract_data) @distributed_trace_async - async def get_repository_properties(self, repository: str, **kwargs) -> RepositoryProperties: + async def get_repository_properties(self, repository: str, **kwargs: Any) -> RepositoryProperties: """Get the properties of a repository :param str repository: Name of the repository :return: The properties of a repository. :rtype: ~azure.containerregistry.RepositoryProperties - :raises: ~azure.core.exceptions.ResourceNotFoundError + :raises ~azure.core.exceptions.ResourceNotFoundError: """ return RepositoryProperties._from_generated( # pylint: disable=protected-access await self._client.container_registry.get_properties(repository, **kwargs) @@ -265,7 +265,7 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): *, order_by: Optional[Union["ArtifactManifestOrder", str]] = None, results_per_page: Optional[int] = None, - **kwargs, + **kwargs: Any, ) -> AsyncItemPaged[ArtifactManifestProperties]: """List the manifests of a repository @@ -276,7 +276,7 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): :paramtype results_per_page: int :returns: An iterable of :class:`~azure.containerregistry.ArtifactManifestProperties` :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.containerregistry.ArtifactManifestProperties] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ name = repository last = kwargs.pop("last", None) @@ -382,7 +382,7 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): return AsyncItemPaged(get_next, extract_data) @distributed_trace_async - async def delete_tag(self, repository: str, tag: str, **kwargs) -> None: + async def delete_tag(self, repository: str, tag: str, **kwargs: Any) -> None: """Delete a tag from a repository. If the tag cannot be found or a response status code of 404 is returned an error will not be raised. @@ -390,7 +390,7 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): :param str tag: The tag to be deleted :returns: None :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: Example @@ -407,7 +407,7 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): @distributed_trace_async async def get_manifest_properties( - self, repository: str, tag_or_digest: str, **kwargs + self, repository: str, tag_or_digest: str, **kwargs: Any ) -> ArtifactManifestProperties: """Get the properties of a registry artifact @@ -415,7 +415,7 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): :param str tag_or_digest: The tag or digest of the manifest :return: The properties of a registry artifact :rtype: ~azure.containerregistry.ArtifactManifestProperties - :raises: ~azure.core.exceptions.ResourceNotFoundError + :raises ~azure.core.exceptions.ResourceNotFoundError: Example @@ -441,7 +441,7 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): ) @distributed_trace_async - async def get_tag_properties(self, repository: str, tag: str, **kwargs) -> ArtifactTagProperties: + async def get_tag_properties(self, repository: str, tag: str, **kwargs: Any) -> ArtifactTagProperties: """Get the properties for a tag :param str repository: Repository the tag belongs to @@ -449,7 +449,7 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): :type tag: str :return: The properties for a tag. :rtype: ~azure.containerregistry.ArtifactTagProperties - :raises: ~azure.core.exceptions.ResourceNotFoundError + :raises ~azure.core.exceptions.ResourceNotFoundError: Example @@ -475,7 +475,7 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): *, order_by: Optional[Union["ArtifactTagOrder", str]] = None, results_per_page: Optional[int] = None, - **kwargs, + **kwargs: Any, ) -> AsyncItemPaged[ArtifactTagProperties]: """List the tags for a repository @@ -486,7 +486,7 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): :paramtype results_per_page: int :returns: An iterable of :class:`~azure.containerregistry.ArtifactTagProperties` :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.containerregistry.ArtifactTagProperties] - :raises: ~azure.core.exceptions.ResourceNotFoundError + :raises ~azure.core.exceptions.ResourceNotFoundError: Example @@ -616,7 +616,7 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): parameter. Please provide either this or individual keyword parameters. :type properties: ~azure.containerregistry.RepositoryProperties :rtype: ~azure.containerregistry.RepositoryProperties - :raises: ~azure.core.exceptions.ResourceNotFoundError + :raises ~azure.core.exceptions.ResourceNotFoundError: """ @overload @@ -640,12 +640,12 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): :keyword bool can_read: Read permissions for a repository. :keyword bool can_write: Write permissions for a repository. :rtype: ~azure.containerregistry.RepositoryProperties - :raises: ~azure.core.exceptions.ResourceNotFoundError + :raises ~azure.core.exceptions.ResourceNotFoundError: """ @distributed_trace_async async def update_repository_properties( - self, *args: Union[str, RepositoryProperties], **kwargs + self, *args: Union[str, RepositoryProperties], **kwargs: Any ) -> RepositoryProperties: repository = str(args[0]) properties = None @@ -679,7 +679,7 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): parameter. Please provide either this or individual keyword parameters. :type properties: ~azure.containerregistry.ArtifactManifestProperties :rtype: ~azure.containerregistry.ArtifactManifestProperties - :raises: ~azure.core.exceptions.ResourceNotFoundError + :raises ~azure.core.exceptions.ResourceNotFoundError: Example @@ -724,7 +724,7 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): :keyword bool can_read: Read permissions for a manifest. :keyword bool can_write: Write permissions for a manifest. :rtype: ~azure.containerregistry.ArtifactManifestProperties - :raises: ~azure.core.exceptions.ResourceNotFoundError + :raises ~azure.core.exceptions.ResourceNotFoundError: Example @@ -747,7 +747,7 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): @distributed_trace_async async def update_manifest_properties( - self, *args: Union[str, ArtifactManifestProperties], **kwargs + self, *args: Union[str, ArtifactManifestProperties], **kwargs: Any ) -> ArtifactManifestProperties: repository = str(args[0]) tag_or_digest = str(args[1]) @@ -788,7 +788,7 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): parameter. Please provide either this or individual keyword parameters. :type properties: ~azure.containerregistry.ArtifactTagProperties :rtype: ~azure.containerregistry.ArtifactTagProperties - :raises: ~azure.core.exceptions.ResourceNotFoundError + :raises ~azure.core.exceptions.ResourceNotFoundError: Example @@ -830,7 +830,7 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): :keyword bool can_read: Read permissions for a tag. :keyword bool can_write: Write permissions for a tag. :rtype: ~azure.containerregistry.ArtifactTagProperties - :raises: ~azure.core.exceptions.ResourceNotFoundError + :raises ~azure.core.exceptions.ResourceNotFoundError: Example @@ -852,7 +852,9 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): """ @distributed_trace_async - async def update_tag_properties(self, *args: Union[str, ArtifactTagProperties], **kwargs) -> ArtifactTagProperties: + async def update_tag_properties( + self, *args: Union[str, ArtifactTagProperties], **kwargs: Any + ) -> ArtifactTagProperties: repository = str(args[0]) tag = str(args[1]) properties = None @@ -882,7 +884,7 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): *, tag: Optional[str] = None, media_type: str = OCI_IMAGE_MANIFEST, - **kwargs, + **kwargs: Any, ) -> str: """Set a manifest for an artifact. @@ -928,7 +930,7 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): return digest @distributed_trace_async - async def get_manifest(self, repository: str, tag_or_digest: str, **kwargs) -> GetManifestResult: + async def get_manifest(self, repository: str, tag_or_digest: str, **kwargs: Any) -> GetManifestResult: """Get the manifest for an artifact. :param str repository: Name of the repository. @@ -974,7 +976,7 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): return GetManifestResult(digest=digest, manifest=manifest_json, media_type=media_type) @distributed_trace_async - async def upload_blob(self, repository: str, data: IO[bytes], **kwargs) -> Tuple[str, int]: + async def upload_blob(self, repository: str, data: IO[bytes], **kwargs: Any) -> Tuple[str, int]: """Upload an artifact blob. :param str repository: Name of the repository. @@ -1033,7 +1035,7 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): return f"sha256:{hasher.hexdigest()}", location, blob_size @distributed_trace_async - async def download_blob(self, repository: str, digest: str, **kwargs) -> AsyncDownloadBlobStream: + async def download_blob(self, repository: str, digest: str, **kwargs: Any) -> AsyncDownloadBlobStream: """Download a blob that is part of an artifact to a stream. :param str repository: Name of the repository. @@ -1068,7 +1070,7 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): ) @distributed_trace_async - async def delete_manifest(self, repository: str, tag_or_digest: str, **kwargs) -> None: + async def delete_manifest(self, repository: str, tag_or_digest: str, **kwargs: Any) -> None: """Delete a manifest. If the manifest cannot be found or a response status code of 404 is returned an error will not be raised. @@ -1076,7 +1078,7 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): :param str tag_or_digest: Tag or digest of the manifest to be deleted. :returns: None :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: Example @@ -1094,7 +1096,7 @@ class ContainerRegistryClient(ContainerRegistryBaseClient): await self._client.container_registry.delete_manifest(repository, tag_or_digest, **kwargs) @distributed_trace_async - async def delete_blob(self, repository: str, digest: str, **kwargs) -> None: + async def delete_blob(self, repository: str, digest: str, **kwargs: Any) -> None: """Delete a blob. If the blob cannot be found or a response status code of 404 is returned an error will not be raised. diff --git a/sdk/containerregistry/azure-containerregistry/azure/containerregistry/aio/_async_exchange_client.py b/sdk/containerregistry/azure-containerregistry/azure/containerregistry/aio/_async_exchange_client.py index 06ad14701c9..4bd6085e5be 100644 --- a/sdk/containerregistry/azure-containerregistry/azure/containerregistry/aio/_async_exchange_client.py +++ b/sdk/containerregistry/azure-containerregistry/azure/containerregistry/aio/_async_exchange_client.py @@ -57,7 +57,7 @@ class ACRExchangeClient(object): self._expiration_time: float = 0 async def get_acr_access_token( # pylint:disable=client-method-missing-tracing-decorator-async - self, challenge: str, **kwargs + self, challenge: str, **kwargs: Any ) -> Optional[str]: parsed_challenge = _parse_challenge(challenge) refresh_token = await self.get_refresh_token(parsed_challenge["service"], **kwargs) @@ -66,7 +66,7 @@ class ACRExchangeClient(object): ) async def get_refresh_token( # pylint:disable=client-method-missing-tracing-decorator-async - self, service: str, **kwargs + self, service: str, **kwargs: Any ) -> str: if not self._refresh_token or self._expiration_time - time.time() > 300: self._refresh_token = await self.exchange_aad_token_for_refresh_token(service, **kwargs) @@ -74,7 +74,7 @@ class ACRExchangeClient(object): return self._refresh_token async def exchange_aad_token_for_refresh_token( # pylint:disable=client-method-missing-tracing-decorator-async - self, service: str, **kwargs + self, service: str, **kwargs: Any ) -> str: auth_operation = cast(AuthenticationOperations, self._client.authentication) token = await self._credential.get_token(*self.credential_scopes) @@ -84,7 +84,7 @@ class ACRExchangeClient(object): return refresh_token.refresh_token if refresh_token.refresh_token is not None else "" async def exchange_refresh_token_for_access_token( # pylint:disable=client-method-missing-tracing-decorator-async - self, refresh_token: str, service: str, scope: str, **kwargs + self, refresh_token: str, service: str, scope: str, **kwargs: Any ) -> Optional[str]: auth_operation = cast(AuthenticationOperations, self._client.authentication) access_token = await auth_operation.exchange_acr_refresh_token_for_acr_access_token(