-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Description
Certain methods return sets from the graph's internals, e.g.
find_modules_directly_imported_by
If the graph is mutated while iterating through these sets, this can can a RuntimeError, e.g.
for imported_module in graph.find_modules_directly_imported_by("foo"):
graph.remove_import(importer="foo", imported=imported_module)
This can be mitigated by copying the set before iterating over it, e.g.
for imported_module in graph.find_modules_directly_imported_by("foo").copy():
graph.remove_import(importer="foo", imported=imported_module)
But probably it would be better for the method to return a copy.
Metadata
Metadata
Assignees
Labels
No labels