Show warning on ref_name collisions

Closes #156
This commit is contained in:
Cristi Vîjdea
2018-08-06 20:00:20 +03:00
parent 3f2d2871f0
commit 5cd642c9a0
4 changed files with 41 additions and 7 deletions
+9 -1
View File
@@ -1,3 +1,4 @@
import logging
import re
from collections import OrderedDict
@@ -7,6 +8,8 @@ from inflection import camelize
from .utils import filter_none
logger = logging.getLogger(__name__)
TYPE_OBJECT = "object" #:
TYPE_STRING = "string" #:
TYPE_NUMBER = "number" #:
@@ -628,8 +631,13 @@ class ReferenceResolver(object):
ret = self.getdefault(name, None, scope)
if ret is None:
ret = maker()
value = self.getdefault(name, None, scope)
assert ret is not None, "maker returned None; referenced objects cannot be None/null"
self.set(name, ret, scope)
if value is None:
self.set(name, ret, scope)
elif value != ret:
logger.debug("during setdefault, maker for %s inserted a value and returned a different value", name)
ret = value
return ret