Azure-cli: update Azure CLI for compatibility with Python 3.8

Created on 28 Feb 2020  Â·  16Comments  Â·  Source: Azure/azure-cli

Describe the bug
latest build from home-brew (Mac) has incompatibilities with Python 3.8

/usr/local/Cellar/azure-cli/2.1.0/libexec/lib/python3.8/site-packages/azure/storage/blob/_upload_chunking.py:403: SyntaxWarning: "is" with a literal. Did you mean "=="? if n is 0 or self._buffer.closed: /usr/local/Cellar/azure-cli/2.1.0/libexec/lib/python3.8/site-packages/azure/storage/blob/baseblobservice.py:1009: SyntaxWarning: "is not" with a literal. Did you mean "!="? if lease_duration is not -1 and \ /usr/local/Cellar/azure-cli/2.1.0/libexec/lib/python3.8/site-packages/azure/storage/blob/baseblobservice.py:2660: SyntaxWarning: "is not" with a literal. Did you mean "!="? if lease_duration is not -1 and \ /usr/local/Cellar/azure-cli/2.1.0/libexec/lib/python3.8/site-packages/azure/storage/common/_connection.py:82: SyntaxWarning: "is" with a literal. Did you mean "=="? self.protocol = self.protocol if parsed_url.scheme is '' else parsed_url.scheme
see: https://docs.python.org/3.8/whatsnew/3.8.html#changes-in-python-behavior

The compiler now produces a SyntaxWarning when identity checks (is and is not) are used with certain types of literals (e.g. strings, numbers). These can often work by accident in CPython, but are not guaranteed by the language spec. The warning advises users to use equality tests (== and !=) instead. (Contributed by Serhiy Storchaka in bpo-34850.)

To Reproduce
probably many other ways, for me this arose with az acr login -n {registry}

Expected behavior
no syntax error reporting

Environment summary
brew install azure-cli

{ "azure-cli": "2.1.0", "azure-cli-command-modules-nspkg": "2.0.3", "azure-cli-core": "2.1.0", "azure-cli-nspkg": "3.0.4", "azure-cli-telemetry": "1.0.4", "extensions": { "interactive": "0.4.3" } }

OKR3.2 Candidate Packaging PackaginHomebrew

Most helpful comment

This is the same issue with 2.6.0:

➜ ~ az group create \
--name $RESOURCE_GROUP \
--location $REGION_NAME
/usr/local/Cellar/azure-cli/2.6.0/libexec/lib/python3.8/site-packages/jmespath/visitor.py:32: SyntaxWarning: "is" with a literal. Did you mean "=="?
if x is 0 or x is 1:
/usr/local/Cellar/azure-cli/2.6.0/libexec/lib/python3.8/site-packages/jmespath/visitor.py:32: SyntaxWarning: "is" with a literal. Did you mean "=="?
if x is 0 or x is 1:
/usr/local/Cellar/azure-cli/2.6.0/libexec/lib/python3.8/site-packages/jmespath/visitor.py:34: SyntaxWarning: "is" with a literal. Did you mean "=="?
elif y is 0 or y is 1:
/usr/local/Cellar/azure-cli/2.6.0/libexec/lib/python3.8/site-packages/jmespath/visitor.py:34: SyntaxWarning: "is" with a literal. Did you mean "=="?
elif y is 0 or y is 1:
/usr/local/Cellar/azure-cli/2.6.0/libexec/lib/python3.8/site-packages/jmespath/visitor.py:260: SyntaxWarning: "is" with a literal. Did you mean "=="?
if original_result is 0:
{
"id": "/subscriptions/a481f10b-726d-493f-930f-ab1bee4b539a/resourceGroups/rg-nwi-aksworkshop",
"location": "northeurope",
"managedBy": null,
"name": "rg-nwi-aksworkshop",
"properties": {
"provisioningState": "Succeeded"
},

All 16 comments

HI @fengzhou-msft could you pls help to have a look? thanks.

This warning comes from a dependency SDK azure-storage-blob==1.5.0. We will check with newer versions.

The version bump of azure-storage-blob relies on track 2 adoption. We'll do it after we add support for track 2 SDKs.

Same problem with the command az acr show --query "id" --output tsv

/usr/local/Cellar/azure-cli/2.3.1/libexec/lib/python3.8/site-packages/azure/storage/blob/_upload_chunking.py:403: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if n is 0 or self._buffer.closed:
/usr/local/Cellar/azure-cli/2.3.1/libexec/lib/python3.8/site-packages/azure/storage/blob/baseblobservice.py:1009: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if lease_duration is not -1 and \
/usr/local/Cellar/azure-cli/2.3.1/libexec/lib/python3.8/site-packages/azure/storage/blob/baseblobservice.py:2660: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if lease_duration is not -1 and \
/usr/local/Cellar/azure-cli/2.3.1/libexec/lib/python3.8/site-packages/azure/storage/common/_connection.py:82: SyntaxWarning: "is" with a literal. Did you mean "=="?
  self.protocol = self.protocol if parsed_url.scheme is '' else parsed_url.scheme

Azure cli installed with homebrew:

This command is in preview. It may be changed/removed in a future release.
{
  "azure-cli": "2.3.1",
  "azure-cli-command-modules-nspkg": "2.0.3",
  "azure-cli-core": "2.3.1",
  "azure-cli-nspkg": "3.0.4",
  "azure-cli-telemetry": "1.0.4",
  "extensions": {}
}

Not sure if a new issue is warranted but I experience similar warnings with the bundled python 3.6 in the azure-cli RPM package. This happens to break terraform.

/usr/lib64/az/lib/python3.6/site-packages/jmespath/visitor.py:32: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if x is 0 or x is 1:
/usr/lib64/az/lib/python3.6/site-packages/jmespath/visitor.py:32: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if x is 0 or x is 1:
/usr/lib64/az/lib/python3.6/site-packages/jmespath/visitor.py:34: SyntaxWarning: "is" with a literal. Did you mean "=="?
  elif y is 0 or y is 1:
/usr/lib64/az/lib/python3.6/site-packages/jmespath/visitor.py:34: SyntaxWarning: "is" with a literal. Did you mean "=="?
  elif y is 0 or y is 1:
/usr/lib64/az/lib/python3.6/site-packages/jmespath/visitor.py:260: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if original_result is 0:

@oszi a fix for your issue is on the way: https://github.com/Azure/azure-cli/pull/13435

Fixed with https://github.com/Azure/azure-cli/pull/13411, will be released with 2.6.0 next Tuesday.

This is the same issue with 2.6.0:

➜ ~ az group create \
--name $RESOURCE_GROUP \
--location $REGION_NAME
/usr/local/Cellar/azure-cli/2.6.0/libexec/lib/python3.8/site-packages/jmespath/visitor.py:32: SyntaxWarning: "is" with a literal. Did you mean "=="?
if x is 0 or x is 1:
/usr/local/Cellar/azure-cli/2.6.0/libexec/lib/python3.8/site-packages/jmespath/visitor.py:32: SyntaxWarning: "is" with a literal. Did you mean "=="?
if x is 0 or x is 1:
/usr/local/Cellar/azure-cli/2.6.0/libexec/lib/python3.8/site-packages/jmespath/visitor.py:34: SyntaxWarning: "is" with a literal. Did you mean "=="?
elif y is 0 or y is 1:
/usr/local/Cellar/azure-cli/2.6.0/libexec/lib/python3.8/site-packages/jmespath/visitor.py:34: SyntaxWarning: "is" with a literal. Did you mean "=="?
elif y is 0 or y is 1:
/usr/local/Cellar/azure-cli/2.6.0/libexec/lib/python3.8/site-packages/jmespath/visitor.py:260: SyntaxWarning: "is" with a literal. Did you mean "=="?
if original_result is 0:
{
"id": "/subscriptions/a481f10b-726d-493f-930f-ab1bee4b539a/resourceGroups/rg-nwi-aksworkshop",
"location": "northeurope",
"managedBy": null,
"name": "rg-nwi-aksworkshop",
"properties": {
"provisioningState": "Succeeded"
},

How was the "fix" validated? This issue very much exists with v2.6.

az cloud set --name AzureCloud
/usr/local/Cellar/azure-cli/2.6.0/libexec/lib/python3.8/site-packages/jmespath/visitor.py:32: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if x is 0 or x is 1:

Still having this issue.

Azure CLI versions:

{
  "azure-cli": "2.6.0",
  "azure-cli-command-modules-nspkg": "2.0.3",
  "azure-cli-core": "2.6.0",
  "azure-cli-nspkg": "3.0.4",
  "azure-cli-telemetry": "1.0.4",
  "extensions": {
    "azure-devops": "0.11.0"
  }
}

Error message when trying to to a az aks get-credentials

<path-to-python-install>/python3.8/site-packages/jmespath/visitor.py:32: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if x is 0 or x is 1:

Still having this issue as well:

$ az version
/usr/lib64/az/lib/python3.6/site-packages/jmespath/visitor.py:32: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if x is 0 or x is 1:
/usr/lib64/az/lib/python3.6/site-packages/jmespath/visitor.py:32: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if x is 0 or x is 1:
/usr/lib64/az/lib/python3.6/site-packages/jmespath/visitor.py:34: SyntaxWarning: "is" with a literal. Did you mean "=="?
  elif y is 0 or y is 1:
/usr/lib64/az/lib/python3.6/site-packages/jmespath/visitor.py:34: SyntaxWarning: "is" with a literal. Did you mean "=="?
  elif y is 0 or y is 1:
/usr/lib64/az/lib/python3.6/site-packages/jmespath/visitor.py:260: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if original_result is 0:
{
  "azure-cli": "2.6.0",
  "azure-cli-command-modules-nspkg": "2.0.3",
  "azure-cli-core": "2.6.0",
  "azure-cli-nspkg": "3.0.4",
  "azure-cli-telemetry": "1.0.4",
  "extensions": {}
}

The issue with jmespath is fixed in 2.7.0. Issue with azure-multiapi-storage is tracked by #14083.

@fengzhou-msft You previously said this issue was fixed in 2.6.0, why should anyone believe you now?

@asarkar The PR(#13435) to fix jmespath was planned to release with 2.6.0 but somehow missed the build date. Then it is merged and built into 2.7.0.

The PR(#13411) I mentioned to fix the original issue with azure-storage-blob was released with 2.6.0.

I'm still having this issue with 2.9.0.. More details in #14083 14083

Having this issue with 2.10 as well

az storage account list
/usr/local/Cellar/azure-cli/2.10.0/libexec/lib/python3.8/site-packages/azure/multiapi/storage/v2018_11_09/blob/_upload_chunking.py:403: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if n is 0 or self._buffer.closed:
/usr/local/Cellar/azure-cli/2.10.0/libexec/lib/python3.8/site-packages/azure/multiapi/storage/v2018_11_09/blob/baseblobservice.py:1063: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if lease_duration is not -1 and \
/usr/local/Cellar/azure-cli/2.10.0/libexec/lib/python3.8/site-packages/azure/multiapi/storage/v2018_11_09/blob/baseblobservice.py:2719: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if lease_duration is not -1 and \
/usr/local/Cellar/azure-cli/2.10.0/libexec/lib/python3.8/site-packages/azure/multiapi/storage/v2018_11_09/common/_connection.py:82: SyntaxWarning: "is" with a literal. Did you mean "=="?
  self.protocol = self.protocol if parsed_url.scheme is '' else parsed_url.scheme
/usr/local/Cellar/azure-cli/2.10.0/libexec/lib/python3.8/site-packages/azure/multiapi/cosmosdb/v2017_04_17/common/_connection.py:91: SyntaxWarning: "is" with a literal. Did you mean "=="?
  self.protocol = self.protocol if parsed_url.scheme is '' else parsed_url.scheme

az version
{
  "azure-cli": "2.10.0",
  "azure-cli-command-modules-nspkg": "2.0.3",
  "azure-cli-core": "2.10.0",
  "azure-cli-nspkg": "3.0.4",
  "azure-cli-telemetry": "1.0.4",
  "extensions": {}
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

nerdondon picture nerdondon  Â·  26Comments

davis-x picture davis-x  Â·  47Comments

colemickens picture colemickens  Â·  46Comments

ejizba picture ejizba  Â·  50Comments

mwieczorek picture mwieczorek  Â·  27Comments