Skip to content

Commit

Permalink
fix(deps): Update mypy requirement from ==0.910 to ==1.8.0 (#251)
Browse files Browse the repository at this point in the history
  • Loading branch information
dependabot[bot] authored Jan 18, 2024
1 parent b3cc0fa commit cea865e
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 23 deletions.
2 changes: 1 addition & 1 deletion ldclient/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
22 changes: 11 additions & 11 deletions ldclient/impl/events/event_context_formatter.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -17,24 +17,24 @@ 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:
out[c.kind] = self._format_context_single(c, False)
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:
Expand All @@ -43,18 +43,18 @@ 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

for attr in context.custom_attributes:
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:
Expand All @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions ldclient/impl/events/event_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion ldclient/impl/events/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
7 changes: 6 additions & 1 deletion ldclient/impl/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
8 changes: 4 additions & 4 deletions ldclient/integrations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion ldclient/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""
Expand Down Expand Up @@ -941,6 +941,7 @@ def stale(self) -> bool:
:return: true if data should be rewritten
"""
return self.__stale


class DataStoreUpdateSink:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion testing/impl/events/test_event_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit cea865e

Please sign in to comment.