def from_mapping(self, *mapping, **kwargs) -> bool:
""" Updates the config like :meth:`update` but ignoring items with
non-upper keys.
"""
if len(mapping) > 1:
raise TypeError(
'expected at most 1 positional argument, got %d' % len(mapping)
)
dict_: dict = {}
if len(mapping) == 1:
dict_ = mapping[0]
if not isinstance(dict_, dict):
raise TypeError(
'expected dict type argument, got %s' % dict_.__class__
)
for key, value in chain(*map(methodcaller('items'),
(dict_, kwargs))):
if key.isupper():
self.data[key] = value
return True
评论列表
文章目录