Fix topological sort

Fixes https://github.com/django/django/pull/3525
use dict comprehension: `{op: set() for op in ops}` (although maybe you could use defaultdict too)