* import-azure-core

* fix-test

* revert-yml
This commit is contained in:
changlong-liu 2022-05-18 08:35:15 +08:00 коммит произвёл GitHub
Родитель f5b857b2bc
Коммит c97db9df00
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
8 изменённых файлов: 34 добавлений и 19 удалений

Просмотреть файл

@ -20,6 +20,14 @@ To install:
Release History
---------------
2022-05-05 Version 0.7.0
+++++++++++++++++++++++++
**Features**
- Add `azure-core` as installation requirement #247
- Replace `SerializationError` and `DeserializationError` in `msrest.exceptions` with those in `azure.core` #247
2021-01-26 Version 0.6.21
+++++++++++++++++++++++++

Просмотреть файл

@ -11,4 +11,5 @@ pylint
aiohttp;python_full_version>="3.5.2"
# async in msrest was experimental, we won't update
trio==0.14.0;python_version == '3.5'
trio==0.16.0;python_version >= '3.6'
trio==0.16.0;python_version >= '3.6' and python_version < '3.10'
trio==0.20.0;python_version >= '3.10'

Просмотреть файл

@ -28,7 +28,7 @@ import logging
import sys
from typing import Callable, Any, Optional, TYPE_CHECKING
from azure.core.exceptions import SerializationError, DeserializationError
_LOGGER = logging.getLogger(__name__)
@ -68,16 +68,6 @@ class ClientException(Exception):
super(ClientException, self).__init__(message, *args, **kwargs) # type: ignore
class SerializationError(ClientException):
"""Error raised during request serialization."""
pass
class DeserializationError(ClientException):
"""Error raised during response deserialization."""
pass
class TokenExpiredError(ClientException):
"""OAuth token expired, request failed."""
pass

Просмотреть файл

@ -569,7 +569,9 @@ class Serializer(object):
_serialized.update(_new_attr)
_new_attr = _new_attr[k]
_serialized = _serialized[k]
except ValueError:
except ValueError as err:
if isinstance(err, SerializationError):
raise err
continue
except (AttributeError, KeyError, TypeError) as err:
@ -776,6 +778,8 @@ class Serializer(object):
data, data_type[1:-1], **kwargs)
except (ValueError, TypeError) as err:
if (isinstance(err, SerializationError)):
raise err # don't rewrap as SerializationError
msg = "Unable to serialize value: {!r} as type: {!r}."
raise_with_traceback(
SerializationError, msg.format(data, data_type), err)
@ -858,7 +862,9 @@ class Serializer(object):
for d in data:
try:
serialized.append(self.serialize_data(d, iter_type, **kwargs))
except ValueError:
except ValueError as err:
if isinstance(err, SerializationError):
raise err
serialized.append(None)
if div:
@ -914,7 +920,9 @@ class Serializer(object):
try:
serialized[self.serialize_unicode(key)] = self.serialize_data(
value, dict_type, **kwargs)
except ValueError:
except ValueError as err:
if isinstance(err, SerializationError):
raise err
serialized[self.serialize_unicode(key)] = None
if 'xml' in serialization_ctxt:

Просмотреть файл

@ -161,7 +161,7 @@ try:
async def __anext__(self):
try:
chunk = await trio.run_sync_in_worker_thread(
chunk = await trio.to_thread.run_sync(
_msrest_next,
self.iter_content_func,
)
@ -209,7 +209,7 @@ try:
session = kwargs.pop('session', self.session)
trio_limiter = kwargs.get("trio_limiter", None)
future = trio.run_sync_in_worker_thread(
future = trio.to_thread.run_sync(
functools.partial(
session.request,
request.method,

Просмотреть файл

@ -25,4 +25,4 @@
# --------------------------------------------------------------------------
#: version of this package. Use msrest.__version__ instead
msrest_version = "0.6.21"
msrest_version = "0.7.0"

Просмотреть файл

@ -28,7 +28,7 @@ from setuptools import setup, find_packages
setup(
name='msrest',
version='0.6.21',
version='0.7.0',
author='Microsoft Corporation',
packages=find_packages(exclude=["tests", "tests.*"]),
url=("https://github.com/Azure/msrest-for-python"),
@ -53,6 +53,7 @@ setup(
"requests_oauthlib>=0.5.0",
"isodate>=0.6.0",
"certifi>=2017.4.17",
"azure-core>=1.24.0",
],
include_package_data=True,
package_data={

Просмотреть файл

@ -42,6 +42,7 @@ from requests import Response
from msrest.serialization import Model, last_restapi_key_transformer, full_restapi_key_transformer, rest_key_extractor
from msrest import Serializer, Deserializer
from msrest.exceptions import SerializationError, DeserializationError, ValidationError
from azure.core.exceptions import SerializationError as AzureCoreSerializationError, DeserializationError as AzureCoreDeserializationError
from . import storage_models
@ -2579,5 +2580,11 @@ class TestModelInstanceEquality(unittest.TestCase):
self.assertTrue(animal1!=animal2)
self.assertTrue(animal1==animal3)
class TestAzureCoreExceptions(unittest.TestCase):
def test_azure_core_exceptions(self):
self.assertEqual(SerializationError, AzureCoreSerializationError)
self.assertEqual(DeserializationError, AzureCoreDeserializationError)
if __name__ == '__main__':
unittest.main()