-
Notifications
You must be signed in to change notification settings - Fork 27
Closed
Description
I wonder whether they should all accept tags: ToTagSetConvertible instead of the current mix of tags: ToTagSetConvertible and tags: FrozenSet[Tag].
Lines 253 to 284 in ea121e1
| def __init__(self, tags: FrozenSet[Tag] = frozenset()): | |
| """ | |
| Constructor for all objects that possess a `tags` attribute. | |
| :arg tags: a :class:`frozenset` of :class:`~pytools.tag.Tag` objects. | |
| Tags can be modified via the :meth:`~pytools.tag.Taggable.tagged` and | |
| :meth:`~pytools.tag.Taggable.without_tags` routines. Input checking | |
| of *tags* should be performed before creating a | |
| :class:`~pytools.tag.Taggable` instance, using | |
| :func:`~pytools.tag.check_tag_uniqueness`. | |
| """ | |
| self.tags = tags | |
| def _with_new_tags(self, tags: FrozenSet[Tag]) -> Self: | |
| """ | |
| Returns a copy of *self* with the specified tags. This method | |
| should be overridden by subclasses. | |
| """ | |
| from warnings import warn | |
| warn(f"_with_new_tags() for {self.__class__} fell back " | |
| "to using copy(). This is deprecated and will stop working in " | |
| "July of 2022. Instead, override _with_new_tags to specify " | |
| "how tags should be applied to an instance.", | |
| DeprecationWarning, stacklevel=2) | |
| # mypy is right: we're not promising this attribute is defined. | |
| # Once this deprecation expires, this will go back to being an | |
| # abstract method. | |
| return self.copy(tags=tags) # type: ignore[attr-defined] # pylint: disable=no-member # noqa: E501 | |
| def tagged(self, tags: ToTagSetConvertible) -> Self: | |
| """ |
Metadata
Metadata
Assignees
Labels
No labels