Skip to content

Commit

Permalink
fail registration if codemod id is already registered (#787)
Browse files Browse the repository at this point in the history
  • Loading branch information
clavedeluna committed Aug 12, 2024
1 parent ccb1df0 commit 88f293a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/codemodder/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ def default_include_paths(self) -> list[str]:
def add_codemod_collection(self, collection: CodemodCollection):
for codemod in collection.codemods:
wrapper = codemod() if isinstance(codemod, type) else codemod
if wrapper.id in self._codemods_by_id:
raise KeyError(
f"Codemod with id {wrapper.id} is already registered. Consider changing the codemod name or origin."
)

self._codemods_by_id[wrapper.id] = wrapper
self._default_include_paths.update(
chain(
Expand Down

0 comments on commit 88f293a

Please sign in to comment.