Skip to content
Merged
Changes from 1 commit
Commits
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
Redesign sentinel
  • Loading branch information
lmazuel committed Aug 1, 2019
commit 1efdebc77daa806e6ed832b751d6decf0f017d35
16 changes: 10 additions & 6 deletions sdk/core/azure-core/azure/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"""

from collections import namedtuple
from enum import Enum
import logging
import os
import six
Expand All @@ -53,8 +54,10 @@
__all__ = ("settings",)


class _Unset(AbstractSpan):
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 @@ -166,15 +169,16 @@ def convert_tracing_impl(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()
if wrapper_class is _Unset:
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