From cea865e967eb8eeedde69c05ed5a89ba4ee4cd63 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 18 Jan 2024 11:30:53 -0500 Subject: [PATCH] fix(deps): Update mypy requirement from ==0.910 to ==1.8.0 (#251) --- ldclient/config.py | 2 +- .../impl/events/event_context_formatter.py | 22 +++++++++---------- ldclient/impl/events/event_processor.py | 4 ++-- ldclient/impl/events/types.py | 2 +- ldclient/impl/operators.py | 7 +++++- ldclient/integrations/__init__.py | 8 +++---- ldclient/interfaces.py | 3 ++- pyproject.toml | 2 +- testing/impl/events/test_event_processor.py | 2 +- 9 files changed, 29 insertions(+), 23 deletions(-) diff --git a/ldclient/config.py b/ldclient/config.py index 47d747eb..25f0f849 100644 --- a/ldclient/config.py +++ b/ldclient/config.py @@ -160,7 +160,7 @@ def __init__(self, use_ldd: bool=False, feature_store: Optional[FeatureStore]=None, feature_requester_class=None, - event_processor_class: Callable[['Config'], EventProcessor]=None, + event_processor_class: Optional[Callable[['Config'], EventProcessor]]=None, private_attributes: Set[str]=set(), all_attributes_private: bool=False, offline: bool=False, diff --git a/ldclient/impl/events/event_context_formatter.py b/ldclient/impl/events/event_context_formatter.py index 7af7b50b..a2929537 100644 --- a/ldclient/impl/events/event_context_formatter.py +++ b/ldclient/impl/events/event_context_formatter.py @@ -1,4 +1,4 @@ -from typing import Any, List, Optional +from typing import Any, List, Optional, Dict from ldclient.context import Context from ldclient.impl.model import AttributeRef @@ -17,9 +17,9 @@ def __init__(self, all_attributes_private: bool, private_attributes: List[str]): if ar.valid: self._private_attributes.append(ar) - def format_context(self, context: Context) -> dict: + def format_context(self, context: Context) -> Dict: if context.multiple: - out = {'kind': 'multi'} # type: dict[str, Any] + out = {'kind': 'multi'} # type: Dict[str, Any] for i in range(context.individual_context_count): c = context.get_individual_context(i) if c is not None: @@ -27,14 +27,14 @@ def format_context(self, context: Context) -> dict: return out else: return self._format_context_single(context, True) - - def _format_context_single(self, context: Context, include_kind: bool) -> dict: - out = {'key': context.key} # type: dict[str, Any] + + def _format_context_single(self, context: Context, include_kind: bool) -> Dict: + out = {'key': context.key} # type: Dict[str, Any] if include_kind: out['kind'] = context.kind if context.anonymous: out['anonymous'] = True - + redacted = [] # type: List[str] all_private = self._private_attributes for p in context.private_attributes: @@ -43,7 +43,7 @@ def _format_context_single(self, context: Context, include_kind: bool) -> dict: ar = AttributeRef.from_path(p) if ar.valid: all_private.append(ar) - + if context.name is not None and not self._check_whole_attr_private('name', all_private, redacted): out['name'] = context.name @@ -51,10 +51,10 @@ def _format_context_single(self, context: Context, include_kind: bool) -> dict: if not self._check_whole_attr_private(attr, all_private, redacted): value = context.get(attr) out[attr] = self._redact_json_value(None, attr, value, all_private, redacted) - + if len(redacted) != 0: out['_meta'] = {'redactedAttributes': redacted} - + return out def _check_whole_attr_private(self, attr: str, all_private: List[AttributeRef], redacted: List[str]) -> bool: @@ -66,7 +66,7 @@ def _check_whole_attr_private(self, attr: str, all_private: List[AttributeRef], redacted.append(attr) return True return False - + def _redact_json_value(self, parent_path: Optional[List[str]], name: str, value: Any, all_private: List[AttributeRef], redacted: List[str]) -> Any: if not isinstance(value, dict) or len(value) == 0: diff --git a/ldclient/impl/events/event_processor.py b/ldclient/impl/events/event_processor.py index ac8bf3cc..81a276a1 100644 --- a/ldclient/impl/events/event_processor.py +++ b/ldclient/impl/events/event_processor.py @@ -167,10 +167,10 @@ def make_output_event(self, e: Any): Transform summarizer data into the format used for the event payload. """ def make_summary_event(self, summary: EventSummary): - flags_out = dict() # type: dict[str, Any] + flags_out = dict() # type: Dict[str, Any] for key, flag_data in summary.flags.items(): flag_data_out = {'default': flag_data.default, 'contextKinds': list(flag_data.context_kinds)} - counters = [] # type: list[dict[str, Any]] + counters = [] # type: List[Dict[str, Any]] for ckey, cval in flag_data.counters.items(): variation, version = ckey counter = { diff --git a/ldclient/impl/events/types.py b/ldclient/impl/events/types.py index e120e81e..d8cb4818 100644 --- a/ldclient/impl/events/types.py +++ b/ldclient/impl/events/types.py @@ -29,7 +29,7 @@ def __eq__(self, other) -> bool: # used only in tests return isinstance(other, EventInput) and self.to_debugging_dict() == other.to_debugging_dict() def to_debugging_dict(self) -> dict: - pass + return {} class EventInputEvaluation(EventInput): diff --git a/ldclient/impl/operators.py b/ldclient/impl/operators.py index bf4b5578..2bc31995 100644 --- a/ldclient/impl/operators.py +++ b/ldclient/impl/operators.py @@ -109,4 +109,9 @@ def _semver_greater_than(context_value: Any, clause_value: Any, clause_preproces "semVerGreaterThan": _semver_greater_than } -ops = defaultdict(lambda: lambda l, r, p: False, ops) + +def __default_factory(): + return lambda _l, _r, _p: False + + +ops = defaultdict(__default_factory, ops) diff --git a/ldclient/integrations/__init__.py b/ldclient/integrations/__init__.py index 79735fe7..636179a1 100644 --- a/ldclient/integrations/__init__.py +++ b/ldclient/integrations/__init__.py @@ -23,10 +23,10 @@ class Consul: DEFAULT_PREFIX = "launchdarkly" @staticmethod - def new_feature_store(host: str=None, - port: int=None, - prefix: str=None, - consul_opts: dict=None, + def new_feature_store(host: Optional[str]=None, + port: Optional[int]=None, + prefix: Optional[str]=None, + consul_opts: Optional[dict]=None, caching: CacheConfig=CacheConfig.default()) -> CachingStoreWrapper: """Creates a Consul-backed implementation of :class:`ldclient.interfaces.FeatureStore`. For more details about how and why you can use a persistent feature store, see the diff --git a/ldclient/interfaces.py b/ldclient/interfaces.py index 30180e5a..0a524d6d 100644 --- a/ldclient/interfaces.py +++ b/ldclient/interfaces.py @@ -266,7 +266,7 @@ class UpdateProcessor(BackgroundOperation): """ __metaclass__ = ABCMeta - def initialized(self) -> bool: + def initialized(self) -> bool: # type: ignore[empty-body] """ Returns whether the update processor has received feature flags and has initialized its feature store. """ @@ -941,6 +941,7 @@ def stale(self) -> bool: :return: true if data should be rewritten """ + return self.__stale class DataStoreUpdateSink: diff --git a/pyproject.toml b/pyproject.toml index 0a866742..38cf08b8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -57,7 +57,7 @@ coverage = ">=4.4" jsonpickle = ">1.4.1" pytest-cov = ">=2.4.0" pytest-mypy = "==0.10.3" -mypy = "==0.910" +mypy = "==1.8.0" [tool.poetry.group.contract-tests] diff --git a/testing/impl/events/test_event_processor.py b/testing/impl/events/test_event_processor.py index 62e3b6da..b2bf91de 100644 --- a/testing/impl/events/test_event_processor.py +++ b/testing/impl/events/test_event_processor.py @@ -47,7 +47,7 @@ def teardown_function(): ep.stop() def make_context_keys(context: Context) -> dict: - ret = {} # type: dict[str, str] + ret = {} # type: Dict[str, str] for i in range(context.individual_context_count): c = context.get_individual_context(i) if c is not None: