From 1c546a8244e9d334b835d9e74bfeb1b3eafdae40 Mon Sep 17 00:00:00 2001 From: jesopo Date: Sat, 8 Dec 2018 09:13:01 +0000 Subject: [PATCH] Add typing hints to CaseInsensitiveDict, fix it's __setitem__ signature, call .items() on `other` in ctor --- src/utils/__init__.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/utils/__init__.py b/src/utils/__init__.py index 1b218b60..5267b79f 100644 --- a/src/utils/__init__.py +++ b/src/utils/__init__.py @@ -173,9 +173,9 @@ def top_10(items: typing.Dict[typing.Any, typing.Any], return top_10_items class CaseInsensitiveDict(dict): - def __init__(self, other): - dict.__init__(self, ((k.lower(), v) for k, v in other)) - def __getitem__(self, key): + def __init__(self, other: typing.Dict[str, typing.Any]): + dict.__init__(self, ((k.lower(), v) for k, v in other.items())) + def __getitem__(self, key: str) -> typing.Any: return dict.__getitem__(self, key.lower()) - def __setitem__(self, key): - return dict.__setitem__(self, key.lower()) + def __setitem__(self, key: str, value: typing.Any) -> typing.Any: + return dict.__setitem__(self, key.lower(), value)