Azure / Azure/azure-storage-python

[Storage] Storage data-plane track 1 SDK triggers SyntaxWarning on Python 3.8

Đang mở
#669 3 bình luận 0 reaction 1 người được giao Được @xiafu-msft nhận Xem trên GitHub
Ngôn ngữ chính
Python
Star
343
Fork
243
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

- **Package Name** and **Package Version**:
https://pypi.org/project/azure-storage-blob/2.1.0/

- **Operating System**:
All

- **Python Version**:
3.8

**Describe the bug**

When the source of **Storage data-plane track 1 SDK** is compiled for the first time (no `__pycache__` folders present), Python 3.8 gives warning:

```py
>>> import azure.storage.blob
d:\cli\env38\lib\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:
d:\cli\env38\lib\site-packages\azure\storage\blob\baseblobservice.py:1009: SyntaxWarning: "is not" with a literal. Did you mean "!="?
if lease_duration is not -1 and \
d:\cli\env38\lib\site-packages\azure\storage\blob\baseblobservice.py:2660: SyntaxWarning: "is not" with a literal. Did you mean "!="?
if lease_duration is not -1 and \
d:\cli\env38\lib\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
```

This usage is against the Python 3.8 definition:

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.

**To Reproduce**

Clear `azure\storage\blob\__pycache__` and `azure\storage\common\__pycache__`, then run

```py
import azure.storage.blob
```

**Expected behavior**

No warning should appear.

**Additional context**

Internal ticket and screenshots: https://dev.azure.com/azuretracking/Azure%20tracking/_workitems/edit/1271

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.