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

[KeyVault] Remove references to six package #25902

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
import pickle
from typing import TYPE_CHECKING

from six import raise_from
from six.moves.urllib_parse import urlparse
from urllib.parse import urlparse

from ._models import KeyVaultBackupResult
from ._internal import KeyVaultClientBase, parse_folder_url
Expand Down Expand Up @@ -65,13 +64,10 @@ def begin_backup(self, blob_storage_url, sas_token, **kwargs):
try:
job_id = _parse_status_url(status_url)
except Exception as ex: # pylint: disable=broad-except
raise_from(
ValueError(
"The provided continuation_token is malformed. A valid token can be obtained from the "
+ "operation poller's continuation_token() method"
),
ex,
)
raise ValueError(
"The provided continuation_token is malformed. A valid token can be obtained from the "
+ "operation poller's continuation_token() method"
) from ex

pipeline_response = self._client.full_backup_status(
vault_base_url=self._vault_url, job_id=job_id, cls=lambda pipeline_response, _, __: pipeline_response
Expand Down Expand Up @@ -130,13 +126,10 @@ def begin_restore(self, folder_url, sas_token, **kwargs):
try:
job_id = _parse_status_url(status_url)
except Exception as ex: # pylint: disable=broad-except
raise_from(
ValueError(
"The provided continuation_token is malformed. A valid token can be obtained from the "
+ "operation poller's continuation_token() method"
),
ex,
)
raise ValueError(
"The provided continuation_token is malformed. A valid token can be obtained from the "
+ "operation poller's continuation_token() method"
) from ex

pipeline_response = self._client.restore_status(
vault_base_url=self._vault_url, job_id=job_id, cls=lambda pipeline_response, _, __: pipeline_response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,18 @@
# Licensed under the MIT License.
# ------------------------------------
from enum import Enum
from six import with_metaclass

from azure.core import CaseInsensitiveEnumMeta

# pylint:skip-file (avoids crash due to six.with_metaclass https://github.com/PyCQA/astroid/issues/713)


class KeyVaultRoleScope(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
class KeyVaultRoleScope(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Collection of well known role scopes. This list is not exhaustive."""

GLOBAL = "/" #: use this if you want role assignments to apply to everything on the resource
KEYS = "/keys" #: use this if you want role assignments to apply to all keys


class KeyVaultDataAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
class KeyVaultDataAction(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Supported permissions for data actions."""

#: Read HSM key metadata.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# ------------------------------------
from collections import namedtuple

from six.moves.urllib_parse import urlparse
from urllib.parse import urlparse

from .challenge_auth_policy import ChallengeAuthPolicy
from .client_base import KeyVaultClientBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# ------------------------------------
# pylint:skip-file (avoids crash due to six.with_metaclass https://github.com/PyCQA/astroid/issues/713)
from typing import TYPE_CHECKING
from enum import Enum
from six import with_metaclass

from azure.core import CaseInsensitiveEnumMeta
from azure.core.pipeline.policies import HttpLoggingPolicy
Expand All @@ -20,7 +18,7 @@
from azure.core.credentials import TokenCredential


class ApiVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
class ApiVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Key Vault API versions supported by this package"""

#: this is the default version
Expand Down
2 changes: 1 addition & 1 deletion sdk/keyvault/azure-keyvault-administration/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,5 @@
]
),
python_requires=">=3.6",
install_requires=["azure-common~=1.1", "azure-core<2.0.0,>=1.24.0", "msrest>=0.6.21", "six>=1.11.0"],
install_requires=["azure-common~=1.1", "azure-core<2.0.0,>=1.24.0", "msrest>=0.6.21"],
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Licensed under the MIT License.
# ------------------------------------
import json
import six
from urllib import parse

try:
from unittest import mock
Expand Down Expand Up @@ -47,7 +47,7 @@ def add_discrepancy(name, expected, actual):
if self.url_substring and self.url_substring not in request.url:
add_discrepancy("url substring", self.url_substring, request.url)

parsed = six.moves.urllib_parse.urlparse(request.url)
parsed = parse.urlparse(request.url)
if self.authority and parsed.netloc != self.authority:
add_discrepancy("authority", self.authority, parsed.netloc)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# ------------------------------------
import json

import six

_has_json_body = lambda req: req.body and "json" in req.headers.get("Content-Type", "")

Expand All @@ -13,6 +12,6 @@ def json_attribute_matcher(r1, r2):
"""Tests whether two vcr.py requests have JSON content with identical attributes (ignoring values)."""

if _has_json_body(r1) and _has_json_body(r2):
c1 = json.loads(six.ensure_str(r1.body))
c2 = json.loads(six.ensure_str(r2.body))
c1 = json.loads(str(r1.body))
c2 = json.loads(str(r2.body))
assert sorted(c1.keys()) == sorted(c2.keys())
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,26 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# ------------------------------------
# pylint:skip-file (avoids crash due to six.with_metaclass https://github.com/PyCQA/astroid/issues/713)
from enum import Enum
from six import with_metaclass

from azure.core import CaseInsensitiveEnumMeta


class CertificatePolicyAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
class CertificatePolicyAction(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The supported action types for the lifetime of a certificate"""

email_contacts = "EmailContacts"
auto_renew = "AutoRenew"


class CertificateContentType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
class CertificateContentType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Content type of the secrets as specified in Certificate Policy"""

pkcs12 = "application/x-pkcs12"
pem = "application/x-pem-file"


class KeyUsageType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
class KeyUsageType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The supported types of key usages"""

digital_signature = "digitalSignature"
Expand All @@ -37,7 +35,7 @@ class KeyUsageType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
decipher_only = "decipherOnly"


class KeyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
class KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Supported key types"""

ec = "EC" #: Elliptic Curve
Expand All @@ -55,7 +53,7 @@ def _missing_(cls, value):
raise ValueError(f"{value} is not a valid KeyType")


class KeyCurveName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
class KeyCurveName(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Supported elliptic curves"""

p_256 = "P-256" #: The NIST P-256 elliptic curve, AKA SECG curve SECP256R1.
Expand All @@ -64,7 +62,7 @@ class KeyCurveName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
p_256_k = "P-256K" #: The SECG SECP256K1 elliptic curve.


class WellKnownIssuerNames(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
class WellKnownIssuerNames(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Collection of well-known issuer names"""

self = "Self" #: Use this issuer for a self-signed certificate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------
# pylint: skip-file (avoids crash due to six.with_metaclass https://github.com/PyCQA/astroid/issues/713)
# pylint: disable=too-many-lines

from enum import Enum, EnumMeta
import msrest.serialization
from six import with_metaclass
ponopono0322 marked this conversation as resolved.
Show resolved Hide resolved


class Action(msrest.serialization.Model):
Expand Down Expand Up @@ -1348,14 +1346,14 @@ def __getattr__(cls, name):
raise AttributeError(name)


class ActionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)):
class ActionType(str, Enum, metaclass=_CaseInsensitiveEnumMeta):
"""The type of the action.
"""

EMAIL_CONTACTS = "EmailContacts"
AUTO_RENEW = "AutoRenew"

class DeletionRecoveryLevel(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)):
class DeletionRecoveryLevel(str, Enum, metaclass=_CaseInsensitiveEnumMeta):
"""Reflects the deletion recovery level currently in effect for certificates in the current vault.
If it contains 'Purgeable', the certificate can be permanently deleted by a privileged user;
otherwise, only the system can purge the certificate, at the end of the retention interval.
Expand Down Expand Up @@ -1398,7 +1396,7 @@ class DeletionRecoveryLevel(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum))
#: that the subscription itself cannot be cancelled.
CUSTOMIZED_RECOVERABLE_PROTECTED_SUBSCRIPTION = "CustomizedRecoverable+ProtectedSubscription"

class JsonWebKeyCurveName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)):
class JsonWebKeyCurveName(str, Enum, metaclass=_CaseInsensitiveEnumMeta):
"""Elliptic curve name. For valid values, see JsonWebKeyCurveName.
"""

Expand All @@ -1407,7 +1405,7 @@ class JsonWebKeyCurveName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)):
P521 = "P-521"
P256_K = "P-256K"

class JsonWebKeyType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)):
class JsonWebKeyType(str, Enum, metaclass=_CaseInsensitiveEnumMeta):
"""The type of key pair to be used for the certificate.
"""

Expand All @@ -1417,7 +1415,7 @@ class JsonWebKeyType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)):
RSA_HSM = "RSA-HSM"
OCT = "oct"

class KeyUsageType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)):
class KeyUsageType(str, Enum, metaclass=_CaseInsensitiveEnumMeta):

DIGITAL_SIGNATURE = "digitalSignature"
NON_REPUDIATION = "nonRepudiation"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# ------------------------------------
# pylint:skip-file (avoids crash due to six.with_metaclass https://github.com/PyCQA/astroid/issues/713)
from typing import TYPE_CHECKING
from enum import Enum
from six import with_metaclass

from azure.core import CaseInsensitiveEnumMeta
from azure.core.pipeline.policies import HttpLoggingPolicy
Expand All @@ -20,7 +18,7 @@
from azure.core.credentials import TokenCredential


class ApiVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
class ApiVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Key Vault API versions supported by this package"""

#: this is the default version
Expand Down
1 change: 0 additions & 1 deletion sdk/keyvault/azure-keyvault-certificates/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,5 @@
"azure-core<2.0.0,>=1.20.0",
"msrest>=0.6.21",
"azure-common~=1.1",
"six>=1.11.0",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Licensed under the MIT License.
# ------------------------------------
import json
import six
from urllib import parse

try:
from unittest import mock
Expand Down Expand Up @@ -47,7 +47,7 @@ def add_discrepancy(name, expected, actual):
if self.url_substring and self.url_substring not in request.url:
add_discrepancy("url substring", self.url_substring, request.url)

parsed = six.moves.urllib_parse.urlparse(request.url)
parsed = parse.urlparse(request.url)
if self.authority and parsed.netloc != self.authority:
add_discrepancy("authority", self.authority, parsed.netloc)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# ------------------------------------
import json

import six

_has_json_body = lambda req: req.body and "json" in req.headers.get("Content-Type", "")

Expand All @@ -13,6 +12,6 @@ def json_attribute_matcher(r1, r2):
"""Tests whether two vcr.py requests have JSON content with identical attributes (ignoring values)."""

if _has_json_body(r1) and _has_json_body(r2):
c1 = json.loads(six.ensure_str(r1.body))
c2 = json.loads(six.ensure_str(r2.body))
c1 = json.loads(str(r1.body))
c2 = json.loads(str(r2.body))
assert sorted(c1.keys()) == sorted(c2.keys())
12 changes: 5 additions & 7 deletions sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/_enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# ------------------------------------
# pylint:skip-file (avoids crash due to six.with_metaclass https://github.com/PyCQA/astroid/issues/713)
from enum import Enum
from six import with_metaclass

from azure.core import CaseInsensitiveEnumMeta


class KeyCurveName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
class KeyCurveName(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Supported elliptic curves"""

p_256 = "P-256" #: The NIST P-256 elliptic curve, AKA SECG curve SECP256R1.
Expand All @@ -18,15 +16,15 @@ class KeyCurveName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
p_256_k = "P-256K" #: The SECG SECP256K1 elliptic curve.


class KeyExportEncryptionAlgorithm(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
class KeyExportEncryptionAlgorithm(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Supported algorithms for protecting exported key material"""

ckm_rsa_aes_key_wrap = "CKM_RSA_AES_KEY_WRAP"
rsa_aes_key_wrap_256 = "RSA_AES_KEY_WRAP_256"
rsa_aes_key_wrap_384 = "RSA_AES_KEY_WRAP_384"


class KeyOperation(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
class KeyOperation(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Supported key operations"""

encrypt = "encrypt"
Expand All @@ -39,14 +37,14 @@ class KeyOperation(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
export = "export"


class KeyRotationPolicyAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
class KeyRotationPolicyAction(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The action that will be executed in a key rotation policy"""

rotate = "Rotate" #: Rotate the key based on the key policy.
notify = "Notify" #: Trigger Event Grid events.


class KeyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
class KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Supported key types"""

ec = "EC" #: Elliptic Curve
Expand Down
Loading