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

[KeyVault] Remove references to six package #25902

wants to merge 4 commits into from

Conversation

ponopono0322
Copy link
Contributor

Description

Fix #22373.
Removed six package

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

@ghost ghost added KeyVault customer-reported Issues that are reported by GitHub users external to the Azure organization. labels Aug 27, 2022
@ghost
Copy link

ghost commented Aug 27, 2022

Thank you for your contribution ponopono0322! We will review the pull request and get back to you soon.

@ponopono0322
Copy link
Contributor Author

ponopono0322 commented Aug 27, 2022

Summary of changes

  1. six.moves.urllib_parse
    Following docs, same as using urllib.
link = "https://azure.microsoft.com/en-us/"

# Before
import six
q = six.moves.urllib_parse.urlparse(link)
print(p)
# >>> ParseResult(scheme='https', netloc='azure.microsoft.com', path='/en-us/', params='', query='', fragment='')

# After
from urllib import parse
p = parse.urlparse(link)
print(q)
# >>> ParseResult(scheme='https', netloc='azure.microsoft.com', path='/en-us/', params='', query='', fragment='')
  1. six.raise_from
    Following docs, six.raise_from(exc_value, exc_value_from) same as raise exc_value from exc_value_from
# Before
from six import raise_from
try:
    zero_div = 1 / 0
except Exception as ex:
    raise_from(ValueError("zero div"), ex, )
# >>> ValueError: zero div

# After
try:
    zero_div = 1 / 0
except Exception as ex:
    raise ValueError("zero div") from ex
# >>> ValueError: zero div
  1. six.with_metaclass
    In python3, metaclass declaration has changed. I referred to stackoverflow and docs.
from enum import Enum, EnumMeta
class _CaseInsensitiveEnumMeta(EnumMeta):
    def __getitem__(self, name):
        return super().__getitem__(name.upper())

    def __getattr__(cls, name):
        try:
            return cls._member_map_[name.upper()]
        except KeyError:
            raise AttributeError(name)

# Before
from six import with_metaclass
class DeletionRecoveryLevel(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)):
    PURGEABLE = "Purgeable"
    RECOVERABLE_PURGEABLE = "Recoverable+Purgeable"
    RECOVERABLE = "Recoverable"
    RECOVERABLE_PROTECTED_SUBSCRIPTION = "Recoverable+ProtectedSubscription"
    CUSTOMIZED_RECOVERABLE_PURGEABLE = "CustomizedRecoverable+Purgeable"
    CUSTOMIZED_RECOVERABLE = "CustomizedRecoverable"
    CUSTOMIZED_RECOVERABLE_PROTECTED_SUBSCRIPTION = "CustomizedRecoverable+ProtectedSubscription"


print(type(DeletionRecoveryLevel), DeletionRecoveryLevel)
print(type(DeletionRecoveryLevel.PURGEABLE), DeletionRecoveryLevel.PURGEABLE)
# >>> <class '__main__._CaseInsensitiveEnumMeta'> <enum 'DeletionRecoveryLevel'>
# >>> <enum 'DeletionRecoveryLevel'> DeletionRecoveryLevel.PURGEABLE

# After
class DeletionRecoveryLevel(str, Enum, metaclass=_CaseInsensitiveEnumMeta):
    PURGEABLE = "Purgeable"
    RECOVERABLE_PURGEABLE = "Recoverable+Purgeable"
    RECOVERABLE = "Recoverable"
    RECOVERABLE_PROTECTED_SUBSCRIPTION = "Recoverable+ProtectedSubscription"
    CUSTOMIZED_RECOVERABLE_PURGEABLE = "CustomizedRecoverable+Purgeable"
    CUSTOMIZED_RECOVERABLE = "CustomizedRecoverable"
    CUSTOMIZED_RECOVERABLE_PROTECTED_SUBSCRIPTION = "CustomizedRecoverable+ProtectedSubscription"


print(type(DeletionRecoveryLevel), DeletionRecoveryLevel)
print(type(DeletionRecoveryLevel.PURGEABLE), DeletionRecoveryLevel.PURGEABLE)
# >>> <class '__main__._CaseInsensitiveEnumMeta'> <enum 'DeletionRecoveryLevel'>
# >>> <enum 'DeletionRecoveryLevel'> DeletionRecoveryLevel.PURGEABLE
  1. six.ensure_str
    Following docs, six.ensure_str(s, encoding='utf-8', errors='strict') same as str(s).
    It is necessary to confirm whether str guarantees utf-8 or whether it is okay to ignore it.
r1 = """{"body": "something", "header": "anything"}"""
# Before
import six
print(type(six.ensure_str(r1)))
# >>> <class 'str'>

# After
print(type(str(r1)))
# >>> <class 'str'>
  1. six.string_types
    Following docs, string_types same as str
# Before
import six
print("True") if isinstance("key", six.string_types) else print("False")
# >>> True

# After
print("True") if isinstance("key", str) else print("False")
# >>> True
  1. six.byte2int
    Following docs, six.byte2int(bs) same as bs[0].
bs = bytes(5)

# Before
import six
print(bs, type(six.byte2int(bs)), six.byte2int(bs))
# >>> b'\x00\x00\x00\x00\x00' <class 'int'> 0

# After
print(bs, type(bs[0]), bs[0])
# >>> b'\x00\x00\x00\x00\x00' <class 'int'> 0

I checked it reference, type and some tests, but it still needs to be modified. I ran a test proxy for clear results, but I couldn't confirm that it was working properly due to POST error at the moment (even in the main branch).
ERROR says:

args = (<test_examples_crypto.TestCryptoExamples object at 0x10353c490>, <azure.keyvault.keys._client.KeyClient object at 0x103b40bb0>)
kwargs = {'is_hsm': False, 'managed_hsm_url': 'https://managedhsmvaultname.vault.azure.net', 'vault_url': 'https://vaultname.vault.azure.net'}
trimmed_kwargs = {'is_hsm': False, 'managed_hsm_url': 'https://managedhsmvaultname.vault.azure.net', 'vault_url': 'https://vaultname.vault.azure.net'}
test_id = 'sdk/keyvault/azure-keyvault-keys/tests/recordings/test_examples_crypto.pyTestCryptoExamplestest_encrypt_decrypt[7.3_vault]', variables = {}
combined_call = <function recorded_by_proxy.<locals>.record_wrap.<locals>.combined_call at 0x10399a700>, test_variables = None
error_body = {'Message': 'Unable to find a record for the request POST https://vaultname.vault.azure.net/keys/livekvtestcrypto-test...coding> values differ, request <gzip, deflate, br>, record <gzip, deflate>\nBody differences:\n', 'Status': 'NotFound'}
message = 'Unable to find a record for the request POST https://vaultname.vault.azure.net/keys/livekvtestcrypto-test-encrypt-key...rences:\n    <Accept-Encoding> values differ, request <gzip, deflate, br>, record <gzip, deflate>\nBody differences:\n'
error_with_message = ResourceNotFoundError('Unable to find a record for the request POST https://vaultname.vault.azure.net/keys/livekvtestc...ences:\n    <Accept-Encoding> values differ, request <gzip, deflate, br>, record <gzip, deflate>\nBody differences:\n')

@ponopono0322 ponopono0322 changed the title Remove references to six package [KeyVault] Remove references to six package Aug 28, 2022
Copy link
Member

@mccoyp mccoyp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for opening a PR! I'll follow up on the generated code's use of six.with_metaclass and will let you know if I can fix that in a separate PR.

@ponopono0322 ponopono0322 requested review from mccoyp and removed request for schaabs and YalinLi0312 September 4, 2022 11:37
@mccoyp
Copy link
Member

mccoyp commented Sep 26, 2022

Closing in favor of #26150

@mccoyp mccoyp closed this Sep 26, 2022
azure-sdk pushed a commit to azure-sdk/azure-sdk-for-python that referenced this pull request Nov 9, 2023
Release app microsoft.app 2023 08 01 preview (Azure#26352)

* Adds base for updating Microsoft.App from version preview/2023-05-02-preview to version 2023-08-01-preview

* Updates readme

* Updates API version in new specs and examples

* Add type to Certificate (Azure#25380)

* Add type to Certificate

* lint

* Add gpus property to AvailableWorkloadProfiles. (Azure#25328)

* Add gpus property to AvailableWorkloadProfiles.

* Fix.

* Pauld/re add build and builder (Azure#25442)

* cherry picked the build and builder updates

* some more cleanup

* added arm id format, removed extra properties, and named the resource provisioning states

* Add OT and AI config (Azure#25350)

* Add OT and AI config

* resolve comments

* Add service bind properties to dapr component (Azure#25781)

* dapr component sb-bind definition add

* fix

* ran npx prettier

* npx prettier

---------

Co-authored-by: bgashirabake@gmail.com <bgashirabake@microsoft.com>

* Adding patching scenario ARM API (Azure#25446)

* cherry picked the build and builder updates

* some more cleanup

* Adding patching scenario and samples

* Added to readme

* Lint fix

* Linting

* Linting error fix

* Addressed comments and added extra properties

* Linting

* Fixing patch skip post action

* Linting

* Addressing comments

* Reverting patchDetails changes

* Fixing pipeline error

* Linting

* Removed invalid required tag

* Fixed examples

* Addressed comments

---------

Co-authored-by: Paul Dorsch <107068277+pauld-msft@users.noreply.github.com>
Co-authored-by: Paul Dorsch <pauldorsch@microsoft.com>

* Update microsoft.app 2023-08-01-preview for new DaprSubscription API feature (Azure#25631)

* ACA Dapr Subscription: WIP

Signed-off-by: Bernd Verst <github@bernd.dev>

* Add Dapr Subscription examples

Signed-off-by: Bernd Verst <github@bernd.dev>

* complete examples

Signed-off-by: Bernd Verst <github@bernd.dev>

* Add DaprSubscription descriptions

Signed-off-by: Bernd Verst <github@bernd.dev>

* include updated readme

Signed-off-by: Bernd Verst <github@bernd.dev>

* fix casing

Signed-off-by: Bernd Verst <github@bernd.dev>

* formatting

Signed-off-by: Bernd Verst <github@bernd.dev>

* Use Types v5

Signed-off-by: Bernd Verst <github@bernd.dev>

* Revert "Use Types v5"

v5 causes several mysterious SDK build errors in this branch on this PR. To avoid this error we will stick to v3 for now. We will upgrade to v5 in a future net new branch.

This reverts commit 6a43aacf16132ff1918cbeb9d9b15c74b3a55a78.

---------

Signed-off-by: Bernd Verst <github@bernd.dev>

* Support log streaming on build resource (Azure#25902)

* updated the build resource to support build upload and log streaming, with a token to be passed in via header

* add x-ms-secret and update buildendpoint -> endpoint

* retrieve log stream and upload endpoint tokens through post requests, as they are secrets

* remove secret flag from tokenendpoint property, as we expect users to retrieve it

* rename file

* updated format of how build object returns auth token

* fix example

* added expiration date to token response

* fix auth token to also include build resource information

* renamed getAuthToken -> listAuthToken and removed resource information from token response

* fix examples

* updated samples to be more accurate

* Update serviceBinds with clientType and customizedKeys (Azure#26111)

* Update serviceBinds with clientType and customizedKeys

* force ci

* fix missing }

---------

Co-authored-by: Ahmed ElSayed <ahmels@microsoft.com>

* Adds new Dapr Component Resiliency Feature to existing version `Release app microsoft.app 2023 08 01 preview` (Azure#26107)

* Add Dapr Component Resiliency Policies APIs to ContainerApps 2023-08-01-preview

Signed-off-by: Bernd Verst <github@bernd.dev>

* Update deletion return code

* Fix variable name

* Remove invalid status code from example

* prettify

* Register new resource in readme

* Remove existing import cycle

* Use integers not integer strings

* Fix delete status codes

* More changes

* Update examples

* Revert "Remove existing import cycle" which causes unrelated failures

This reverts commit 8ce1a74f9d12b333c43c324f1b2250a64a0f1add.

---------

Signed-off-by: Bernd Verst <github@bernd.dev>

* Add API spec for ContainerApp Resiliency (Azure#25732)

Signed-off-by: Hal Spang <halspang@microsoft.com>

* Add extendedlocation for job (Azure#26196)

* Add extendedlocation for job

* Add sample for container apps on connectedEnvironment

* Fixes for examples

* Fix connected environment example

* Update old examples

* removing SourceToCloud patching from 08-01-preview (Azure#26245)

* Add diagnostic routes to Container App Jobs (Azure#26227)

* Add diagnostic routes to Container App Jobs

* Update

* Update

* Update

* Update

* Update

* Update

* Update operationIds

---------

Co-authored-by: Michimune Kohno <mikono@microsoft.com>

* Update app resiliency rest api spec (#26357)

Signed-off-by: Yash Nisar <yashnisar@microsoft.com>

* Fix ACA component resiliency examples (Azure#26441)

* Fix arm review comments for container app (Azure#26455)

* update

* update

* update

* Fix SDK build error for Microsoft.App (Azure#26416)

* Fix SDK build error for Microsoft.App

* Update

* update

* update

* update

---------

Co-authored-by: Michimune Kohno <mikono@microsoft.com>

* Fix arm review comments for container app (Azure#26479)

* fix

* update

* update

* Fix detectorProperties request path (Azure#26431)

* fix list exception

* change param to enum

* fix lint error

* revert not working changes

* fix enum

* rearrange

---------

Co-authored-by: Chenghui Yu <chenghuiyu@microsoft.com>

* Enable dynamicJsonColumns for log analytics configuration (Azure#26432)

* Enable dynamicJsonColumn for log analysis configuration

* Add missed s

* Fix code style

* Update container app usages value to float (Azure#26448)

* update

* update

* update

* Fix App Resiliency retry example (Azure#26560)

Signed-off-by: Yash Nisar <yashnisar@microsoft.com>

* Fix lint warning for container app (Azure#26523)

* fix warning

* fix warning

* upate

---------

Signed-off-by: Bernd Verst <github@bernd.dev>
Signed-off-by: Hal Spang <halspang@microsoft.com>
Signed-off-by: Yash Nisar <yashnisar@microsoft.com>
Co-authored-by: zhenqxuMSFT <zhenqxu@microsoft.com>
Co-authored-by: yalixiang <88011184+yalixiang@users.noreply.github.com>
Co-authored-by: Paul Dorsch <107068277+pauld-msft@users.noreply.github.com>
Co-authored-by: Michael Dai <michaelkira@live.cn>
Co-authored-by: bgashirabake <85650284+bgashirabake@users.noreply.github.com>
Co-authored-by: bgashirabake@gmail.com <bgashirabake@microsoft.com>
Co-authored-by: Harry Li <110055355+harryli0108@users.noreply.github.com>
Co-authored-by: Paul Dorsch <pauldorsch@microsoft.com>
Co-authored-by: Bernd Verst <bernd.verst@microsoft.com>
Co-authored-by: Ahmed ElSayed <ahmed@elsayed.io>
Co-authored-by: Ahmed ElSayed <ahmels@microsoft.com>
Co-authored-by: halspang <70976921+halspang@users.noreply.github.com>
Co-authored-by: LaylaLiu-gmail <38268900+LaylaLiu-gmail@users.noreply.github.com>
Co-authored-by: michimune <michimune@outlook.com>
Co-authored-by: Michimune Kohno <mikono@microsoft.com>
Co-authored-by: Yash Nisar <yashnisar@microsoft.com>
Co-authored-by: Seris370 <38371667+Seris370@users.noreply.github.com>
Co-authored-by: Chenghui Yu <chenghuiyu@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer-reported Issues that are reported by GitHub users external to the Azure organization. KeyVault
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Key Vault] Remove references to six package
2 participants