Skip to content

Commit 88f293a

Browse files
authored
fail registration if codemod id is already registered (#787)
1 parent ccb1df0 commit 88f293a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/codemodder/registry.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ def default_include_paths(self) -> list[str]:
5353
def add_codemod_collection(self, collection: CodemodCollection):
5454
for codemod in collection.codemods:
5555
wrapper = codemod() if isinstance(codemod, type) else codemod
56+
if wrapper.id in self._codemods_by_id:
57+
raise KeyError(
58+
f"Codemod with id {wrapper.id} is already registered. Consider changing the codemod name or origin."
59+
)
60+
5661
self._codemods_by_id[wrapper.id] = wrapper
5762
self._default_include_paths.update(
5863
chain(

0 commit comments

Comments
 (0)