Skip to content

Commit 92968ff

Browse files
committed
contrib/sync-places: filter tags during creation
In older versions of python, when iterating over a dictionary, a copy would be created allowing us to modify the dictionary while we're iterating over it. Newer versions however do not make this copy and now raise runtime errors when the keys change while we're iterating over them. Transform the key/values during creation of the 'tags' dictionary to avoid having to delete keys afterwards. Signed-off-by: Bryan Brattlof <[email protected]>
1 parent 83d306c commit 92968ff

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

contrib/sync-places.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,7 @@ async def do_sync(session, args):
117117
await session.sync_with_coordinator()
118118
changed = True
119119

120-
tags = config["places"][name].get("tags", {}).copy()
121-
for k, v in tags.items():
122-
if not isinstance(k, str) or not isinstance(v, str):
123-
del(tags[k])
124-
tags[str(k)] = str(v)
120+
tags = { str(k): str(v) for k, v in config["places"][name].get("tags", {}).items() }
125121

126122
if place_tags != tags:
127123
print(

0 commit comments

Comments
 (0)