Skip to content

Commit b66c0e2

Browse files
authored
[CodemodCommand] Make transform_module supported_transforms order deterministic by using List over Dict (#1424)
1 parent c2169d2 commit b66c0e2

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

libcst/codemod/_command.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import argparse
77
import inspect
88
from abc import ABC, abstractmethod
9-
from typing import Dict, Generator, List, Type, TypeVar
9+
from typing import Dict, Generator, List, Tuple, Type, TypeVar
1010

1111
from libcst import Module
1212
from libcst.codemod._codemod import Codemod
@@ -75,13 +75,13 @@ def transform_module(self, tree: Module) -> Module:
7575
# have a static method that other transforms can use which takes
7676
# a context and other optional args and modifies its own context key
7777
# accordingly. We import them here so that we don't have circular imports.
78-
supported_transforms: Dict[str, Type[Codemod]] = {
79-
AddImportsVisitor.CONTEXT_KEY: AddImportsVisitor,
80-
RemoveImportsVisitor.CONTEXT_KEY: RemoveImportsVisitor,
81-
}
78+
supported_transforms: List[Tuple[str, Type[Codemod]]] = [
79+
(AddImportsVisitor.CONTEXT_KEY, AddImportsVisitor),
80+
(RemoveImportsVisitor.CONTEXT_KEY, RemoveImportsVisitor),
81+
]
8282

8383
# For any visitors that we support auto-running, run them here if needed.
84-
for key, transform in supported_transforms.items():
84+
for key, transform in supported_transforms:
8585
if key in self.context.scratch:
8686
# We have work to do, so lets run this.
8787
tree = self._instantiate_and_run(transform, tree)

0 commit comments

Comments
 (0)