Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
66359b8
document async transport requirement (#6541)
chlowell Jul 30, 2019
379c1a1
[AutoPR] alertsmanagement/resource-manager (#5697)
AutorestCI Jul 30, 2019
7a0f5d3
Synchronous username/password auth (#6416)
chlowell Jul 30, 2019
f9f2db1
Synchronous interactive browser authentication (#6466)
chlowell Jul 30, 2019
f583901
we dont need thread locks (#6551)
SuyogSoti Jul 30, 2019
e833df0
KV aiohttp by default (#6563)
lmazuel Jul 31, 2019
95220b7
[AutoPR hanaonazure/resource-manager] Removing monitoring hana instan…
AutorestCI Jul 31, 2019
02e17b7
KV moved paging return type to ItemPaged (#6558)
lmazuel Jul 31, 2019
37c46c6
azure-core history 1.0.0b2 (#6562)
lmazuel Jul 31, 2019
c6ebc93
Make private Cosmos modules private [WIP] (#6329)
bryevdv Jul 31, 2019
d3d96df
Accept extension of JSON content-type (#6583)
lmazuel Jul 31, 2019
d2ed7d8
Remove docdb mgmt package from master (#6585)
lmazuel Jul 31, 2019
92583cf
Revert "Remove docdb mgmt package from master (#6585)" (#6593)
lmazuel Jul 31, 2019
1d86ae8
azure-core black/pylint/mypy (#6581)
lmazuel Aug 1, 2019
a08c25a
adjusting to allow default omission of packages for CI. (#6595)
scbedd Aug 1, 2019
b0bd437
Synchronous device code credential (#6464)
chlowell Aug 1, 2019
f700299
[AutoPR alertsmanagement/resource-manager] fixing subscription id iss…
AutorestCI Aug 1, 2019
64b121c
Remove Configuration from public API (#6603)
chlowell Aug 1, 2019
ccd73c1
[AutoPR] security/resource-manager (#5709)
AutorestCI Aug 1, 2019
33d6e4a
Minimal change to disable code coverage publishing for PRs. (#6614)
mitchdenny Aug 1, 2019
0249a7c
Readme doc update for azure-core (#6611)
lmazuel Aug 1, 2019
e12b658
Mypy fixes for azure.core.tracing (#6590)
SuyogSoti Aug 2, 2019
abc3f20
MyPy azure-core (#6619)
lmazuel Aug 2, 2019
8eb5e9b
Update Key Vault docstrings (#6632)
chlowell Aug 2, 2019
2a7a965
Update Key Vault user agent (#6640)
chlowell Aug 2, 2019
b647582
Update README.md (#6635)
lmazuel Aug 2, 2019
f9ab732
mypy fixes (#6641)
SuyogSoti Aug 2, 2019
46c7ad6
Policies as kwargs for KeyVault (#6616)
lmazuel Aug 3, 2019
5b5ed26
Mypy fixes (#6646)
xiangyan99 Aug 3, 2019
8d17ca3
[AutoPR healthcareapis/resource-manager] Fixed healthcareapi readme.m…
AutorestCI Aug 5, 2019
c257006
fixed bug in maxItemCount propagation for Order by queries (#6608)
Aug 5, 2019
4470f79
Final azure-identity preview 2 changes (#6664)
chlowell Aug 5, 2019
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
Prev Previous commit
Next Next commit
MyPy azure-core (#6619)
* MyPy azure-core settings

* MyPy azure-core aiohttp

* Redesign sentinel
  • Loading branch information
lmazuel authored Aug 2, 2019
commit abc3f20b003bd24f662f4a9eb36bf5cfbbc3efba
4 changes: 2 additions & 2 deletions sdk/core/azure-core/azure/core/pipeline/transport/aiohttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import aiohttp

from azure.core.configuration import ConnectionConfiguration
from azure.core.exceptions import ServiceRequestError, ServiceResponseError
from azure.core.exceptions import ServiceRequestError, ServiceResponseError, AzureError
from azure.core.pipeline import Pipeline

from requests.exceptions import (
Expand Down Expand Up @@ -159,7 +159,7 @@ async def send(self, request: HttpRequest, **config: Any) -> Optional[AsyncHttpR
config['proxy'] = proxies[protocol]
break

error = None
error = None # type: Optional[AzureError]
response = None
config['ssl'] = self._build_ssl_config(
cert=config.pop('connection_cert', self.connection_config.cert),
Expand Down
46 changes: 28 additions & 18 deletions sdk/core/azure-core/azure/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,23 @@
"""

from collections import namedtuple
from enum import Enum
import logging
import os
import six
import sys

try:
from typing import TYPE_CHECKING
from typing import Type, Optional, Dict, Callable, cast, TYPE_CHECKING
except ImportError:
TYPE_CHECKING = False

if TYPE_CHECKING:
from typing import Any, Union
try:
from azure.core.tracing.ext.opencensus_span import OpenCensusSpan
except ImportError:
pass


from azure.core.tracing import AbstractSpan
Expand All @@ -49,8 +54,10 @@
__all__ = ("settings",)


class _Unset(object):
pass
# https://www.python.org/dev/peps/pep-0484/#support-for-singleton-types-in-unions
class _Unset(Enum):
token = 0
_unset = _Unset.token


def convert_bool(value):
Expand Down Expand Up @@ -119,7 +126,7 @@ def convert_logging(value):


def get_opencensus_span():
# type: () -> OpenCensusSpan
# type: () -> Optional[Type[AbstractSpan]]
"""Returns the OpenCensusSpan if opencensus is installed else returns None"""
try:
from azure.core.tracing.ext.opencensus_span import OpenCensusSpan
Expand All @@ -130,16 +137,17 @@ def get_opencensus_span():


def get_opencensus_span_if_opencensus_is_imported():
# type: () -> Optional[Type[AbstractSpan]]
if "opencensus" not in sys.modules:
return None
return get_opencensus_span()


_tracing_implementation_dict = {"opencensus": get_opencensus_span}
_tracing_implementation_dict = {"opencensus": get_opencensus_span} # type: Dict[str, Callable[[], Optional[Type[AbstractSpan]]]]


def convert_tracing_impl(value):
# type: (Union[str, AbstractSpan]) -> AbstractSpan
# type: (Union[str, Type[AbstractSpan]]) -> Optional[Type[AbstractSpan]]
"""Convert a string to AbstractSpan

If a AbstractSpan is passed in, it is returned as-is. Otherwise the function
Expand All @@ -156,19 +164,21 @@ def convert_tracing_impl(value):
if value is None:
return get_opencensus_span_if_opencensus_is_imported()

wrapper_class = value
if isinstance(value, six.string_types):
value = value.lower()
get_wrapper_class = _tracing_implementation_dict.get(value, lambda: _Unset)
wrapper_class = get_wrapper_class()
if wrapper_class is _Unset:
raise ValueError(
"Cannot convert {} to AbstractSpan, valid values are: {}".format(
value, ", ".join(_tracing_implementation_dict)
)
if not isinstance(value, six.string_types):
return value

value = cast(str, value) # mypy clarity
value = value.lower()
get_wrapper_class = _tracing_implementation_dict.get(value, lambda: _unset)
wrapper_class = get_wrapper_class() # type: Union[None, _Unset, Type[AbstractSpan]]
if wrapper_class is _unset:
raise ValueError(
"Cannot convert {} to AbstractSpan, valid values are: {}".format(
value, ", ".join(_tracing_implementation_dict)
)

return wrapper_class
)
# type ignored until https://github.com/python/mypy/issues/7279
return wrapper_class # type: ignore


class PrioritizedSetting(object):
Expand Down