Utilise defaultdicts

This code originates from the Python 2.4 supporting version of Flask,
with defaultdicts being added in 2.5. Using defaultdict makes the
intentional usage clearer, and slightly simplifies the code.
This commit is contained in:
pgjones 2021-02-21 12:55:30 +00:00 committed by David Lord
parent 5fea7caba2
commit fd62210f58
No known key found for this signature in database
GPG key ID: 7A1C87E3F5BC42A8
3 changed files with 23 additions and 21 deletions

View file

@ -251,7 +251,7 @@ class Blueprint(Scaffold):
"""
for key, values in self_dict.items():
key = self.name if key is None else f"{self.name}.{key}"
app_dict.setdefault(key, []).extend(values)
app_dict[key].extend(values)
def merge_dict_nested(self_dict, app_dict):
"""Merges self_dict into app_dict. Replaces None keys with self.name.