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 Python 3.6 and six references #26150

Closed
wants to merge 7 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
1 change: 1 addition & 0 deletions sdk/keyvault/azure-keyvault-administration/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
### Other Changes
- Updated minimum `azure-core` version to 1.24.0
- Updated minimum `msrest` version to 0.7.1
- Python 3.6 is no longer supported. Please use Python version 3.7 or later.

## 4.2.0 (2022-09-19)

Expand Down
3 changes: 2 additions & 1 deletion sdk/keyvault/azure-keyvault-administration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ create, manage, and deploy public and private SSL/TLS certificates
## _Disclaimer_

_Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For more information and questions, please refer to https://github.com/Azure/azure-sdk-for-python/issues/20691_.
_Python 3.7 or later is required to use this package. For more details, please refer to [Azure SDK for Python version support policy](https://github.com/Azure/azure-sdk-for-python/wiki/Azure-SDKs-Python-version-support-policy)._

## Getting started
### Install packages
Expand All @@ -32,7 +33,7 @@ authentication as demonstrated below.

### Prerequisites
* An [Azure subscription][azure_sub]
* Python 3.6 or later
* Python 3.7 or later
* An existing [Key Vault Managed HSM][managed_hsm]. If you need to create one, you can do so using the Azure CLI by following the steps in [this document][managed_hsm_cli].

### Authenticate the client
Expand Down
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 @@ -73,13 +72,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 @@ -138,13 +134,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
5 changes: 2 additions & 3 deletions sdk/keyvault/azure-keyvault-administration/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
"Programming Language :: Python",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
Expand All @@ -65,6 +64,6 @@
"azure.keyvault",
]
),
python_requires=">=3.6",
install_requires=["azure-common~=1.1", "azure-core<2.0.0,>=1.24.0", "msrest>=0.7.1", "six>=1.11.0"],
python_requires=">=3.7",
install_requires=["azure-common~=1.1", "azure-core<2.0.0,>=1.24.0", "msrest>=0.7.1"],
)
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
import urllib

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 = urllib.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,15 +4,13 @@
# ------------------------------------
import json

import six

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


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())
1 change: 1 addition & 0 deletions sdk/keyvault/azure-keyvault-certificates/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
### Bugs Fixed

### Other Changes
- Python 3.6 is no longer supported. Please use Python version 3.7 or later.

## 4.6.0 (2022-09-19)

Expand Down
3 changes: 2 additions & 1 deletion sdk/keyvault/azure-keyvault-certificates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and other secrets
## _Disclaimer_

_Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For more information and questions, please refer to https://github.com/Azure/azure-sdk-for-python/issues/20691_.
_Python 3.7 or later is required to use this package. For more details, please refer to [Azure SDK for Python version support policy](https://github.com/Azure/azure-sdk-for-python/wiki/Azure-SDKs-Python-version-support-policy)._

## Getting started
### Install the package
Expand All @@ -27,7 +28,7 @@ authentication as demonstrated below.

### Prerequisites
* An [Azure subscription][azure_sub]
* Python 3.6 or later
* Python 3.7 or later
* An existing [Azure Key Vault][azure_keyvault]. If you need to create one, you can do so using the Azure CLI by following the steps in [this document][azure_keyvault_cli].

### Authenticate the client
Expand Down
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 @@ -8,7 +8,6 @@

from enum import Enum, EnumMeta
import msrest.serialization
from six import with_metaclass


class Action(msrest.serialization.Model):
Expand Down Expand Up @@ -1348,14 +1347,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 +1397,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 +1406,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 +1416,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
8 changes: 3 additions & 5 deletions sdk/keyvault/azure-keyvault-certificates/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
"Programming Language :: Python",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
Expand All @@ -65,11 +64,10 @@
"azure.keyvault",
]
),
python_requires=">=3.6",
python_requires=">=3.7",
install_requires=[
"azure-core<2.0.0,>=1.20.0",
"msrest>=0.6.21",
"azure-core<2.0.0,>=1.24.0",
"msrest>=0.7.1",
"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
import urllib

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 = urllib.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,15 +4,13 @@
# ------------------------------------
import json

import six

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


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())
Loading