Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions pytools/tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,12 @@ def tagged(self, tags: ToTagSetConvertible) -> Self:
:arg tags: An instance of :class:`~pytools.tag.Tag` or
an iterable with instances therein.
"""
return self._with_new_tags(
tags=check_tag_uniqueness(normalize_tags(tags) | self.tags))
normalized = normalize_tags(tags)
new_tags = check_tag_uniqueness(normalized | self.tags)
if normalized <= self.tags:
return self
else:
return self._with_new_tags(tags=new_tags)

def without_tags(self,
tags: ToTagSetConvertible, verify_existence: bool = True
Expand All @@ -297,7 +301,10 @@ def without_tags(self,
if verify_existence and len(new_tags) > len(self.tags) - len(to_remove):
raise ValueError("A tag specified for removal was not present.")

return self._with_new_tags(tags=check_tag_uniqueness(new_tags))
if to_remove & self.tags:
return self._with_new_tags(tags=check_tag_uniqueness(new_tags))
else:
return self

@memoize_method
def tags_of_type(self, tag_t: type[TagT]) -> frozenset[TagT]:
Expand Down
Loading