@@ -611,60 +611,60 @@ def find(self) -> list[Tag]:
611611
612612 return tags
613613
614- def _to_tag_ids (self , tags : tuple [str | Tag , ...]) -> list [str ]:
615- tag_ids : list [str ] = []
616- for i , tag in enumerate (tags ):
617- tag_id = tag ["id" ] if isinstance (tag , Tag ) else tag
614+ def _to_tag_id (self , tag : str | Tag ) -> str :
615+ if isinstance (tag , Tag ):
616+ tag_id = tag ["id" ]
618617 if not isinstance (tag_id , str ):
619- raise TypeError (f"Expected 'tags[{ i } ]' to be a string. Received: { tag_id } " )
620- if tag_id == "" :
621- raise ValueError (f"Expected 'tags[{ i } ]' to be non-empty. Received: { tag_id } " )
618+ raise TypeError (f'Expected `tag=` `"id"` to be a string. Received: { tag } ' )
622619
623- tag_ids .append (tag_id )
620+ elif isinstance (tag , str ):
621+ tag_id = tag
622+ else :
623+ raise TypeError (f"Expected `tag=` to be a string or Tag object. Received: { tag } " )
624624
625- return tag_ids
625+ if tag_id == "" :
626+ raise ValueError (f"Expected 'tag=' ID to be non-empty. Received: { tag_id } " )
627+
628+ return tag_id
626629
627- def add (self , * tags : str | Tag ) -> None :
630+ def add (self , tag : str | Tag ) -> None :
628631 """
629- Add the specified tags to an individual content item.
632+ Add the specified tag to an individual content item.
630633
631634 When adding a tag, all tags above the specified tag in the tag tree are also added to the
632635 content item.
633636
634637 Parameters
635638 ----------
636- tags : str | Tag
637- The tags id or tag object to add to the content item.
639+ tag : str | Tag
640+ The tag id or tag object to add to the content item.
638641
639642 Returns
640643 -------
641644 None
642645 """
643- tag_ids = self ._to_tag_ids ( tags )
646+ tag_id = self ._to_tag_id ( tag )
644647
645648 url = self ._ctx .url + self ._path
646- for tag_id in tag_ids :
647- self ._ctx .session .post (url , json = {"tag_id" : tag_id })
649+ self ._ctx .session .post (url , json = {"tag_id" : tag_id })
648650
649- def delete (self , * tags : str | Tag ) -> None :
651+ def delete (self , tag : str | Tag ) -> None :
650652 """
651- Remove the specified tags from an individual content item.
653+ Remove the specified tag from an individual content item.
652654
653655 When removing a tag, all tags above the specified tag in the tag tree are also removed from
654656 the content item.
655657
656658 Parameters
657659 ----------
658- tags : str | Tag
659- The tags id or tag object to remove from the content item.
660+ tag : str | Tag
661+ The tag id or tag object to remove from the content item.
660662
661663 Returns
662664 -------
663665 None
664666 """
665- tag_ids = self ._to_tag_ids ( tags )
667+ tag_id = self ._to_tag_id ( tag )
666668
667- url = self ._ctx .url + self ._path
668- for tag_id in tag_ids :
669- tag_url = f"{ url } /{ tag_id } "
670- self ._ctx .session .delete (tag_url )
669+ url = self ._ctx .url + self ._path + tag_id
670+ self ._ctx .session .delete (url )
0 commit comments