From 3b85355dbb6b96644928c74e22a70a6375e7809a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pavel=20K=C3=A1cha?= <ph@cesnet.cz>
Date: Tue, 24 Oct 2017 15:36:48 +0200
Subject: [PATCH] Fixed regression on unknown keys

---
 test_typedcols.py | 10 ++++++----
 typedcols.py      |  4 ++--
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/test_typedcols.py b/test_typedcols.py
index 03baef5..6e0ab5c 100755
--- a/test_typedcols.py
+++ b/test_typedcols.py
@@ -42,7 +42,8 @@ person_init_data = {
     "address": {
         "street": "Vrchlikova",
         "num": 12.3,
-        "city": "Kocourkov"
+        "city": "Kocourkov",
+        "unknown": "blah"
     },
     "discard1": "junk",
     "discard2": "garbage",
@@ -76,7 +77,8 @@ class TestTypedDict(unittest.TestCase):
             "address": {
                 "street": "Vrchlikova",
                 "num": 12,
-                "city": "Kocourkov"}})
+                "city": "Kocourkov",
+                "unknown": "blah"}})
 
     def testSetGetKnownOk(self):
         self.person["address"]["city"] = "Brno"
@@ -126,7 +128,7 @@ class TestTypedDict(unittest.TestCase):
             it = self.person.items()
         res = sorted([v for v in it])
         self.assertEqual(res, [
-            ("address", {"city": "Kocourkov", "street": "Vrchlikova", "num": 12}),
+            ("address", {"city": "Kocourkov", "street": "Vrchlikova", "num": 12, "unknown": "blah"}),
             ("age", 34),
             ("name", "_Default_Value_"),
             ("note", None)
@@ -136,7 +138,7 @@ class TestTypedDict(unittest.TestCase):
 class TestOpenTypedDict(TestTypedDict):
 
     def setUp(self):
-        open_address_dict = OpenTypedDict(typedef=address_typedef.copy())
+        open_address_dict = OpenTypedDict(typedef=address_typedef.copy(), allow_unknown=True)
 
         open_person_typedef = person_typedef.copy()
         open_person_typedef["address"] = open_address_dict
diff --git a/typedcols.py b/typedcols.py
index e614419..427fb56 100644
--- a/typedcols.py
+++ b/typedcols.py
@@ -10,7 +10,7 @@ Defines TypedDict and TypedList, which enforce inserted types based on simple
 type definition.
 """
 
-__version__ = '0.1.10'
+__version__ = '0.1.11'
 __author__ = 'Pavel Kácha <pavel.kacha@cesnet.cz>'
 
 import collections
@@ -130,7 +130,7 @@ class TypedDictBase(collections.MutableMapping):
             If key is not defined and allow_unknown is True, empty
             definition is returned, otherwise KeyNotAllowed gets raised.
         """
-        tdef = {}
+        tdef = {"type": Any}
         try:
             tdef = self.typedef[key]
         except KeyError:
-- 
GitLab