only mutable variant should have rename_top

This commit is contained in:
jan 2023-04-07 22:29:47 -07:00
parent 372deaca09
commit ed77e389af

View File

@ -336,14 +336,6 @@ class ILibraryView(Mapping[str, 'Pattern'], metaclass=ABCMeta):
""" """
return self[self.top()] return self[self.top()]
def rename_top(self, name: str) -> Self:
"""
Rename the (single) top pattern
"""
self.rename(self.top(), name, move_references=True)
return self
def dfs( def dfs(
self, self,
pattern: 'Pattern', pattern: 'Pattern',
@ -497,6 +489,14 @@ class ILibrary(ILibraryView, MutableMapping[str, 'Pattern'], metaclass=ABCMeta):
self.move_references(old_name, new_name) self.move_references(old_name, new_name)
return self return self
def rename_top(self, name: str) -> Self:
"""
Rename the (single) top pattern
"""
self.rename(self.top(), name, move_references=True)
return self
def move_references(self, old_target: str, new_target: str) -> Self: def move_references(self, old_target: str, new_target: str) -> Self:
""" """
Change all references pointing at `old_target` into references pointing at `new_target`. Change all references pointing at `old_target` into references pointing at `new_target`.