From 846c152082118cb098d532ef152b93836c8be986 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner <inform@tiker.net> Date: Wed, 17 Jul 2024 12:34:10 -0500 Subject: [PATCH] Revive Taggable constructor, in deprecated form --- pytools/tag.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pytools/tag.py b/pytools/tag.py index 3fa3294..916293d 100644 --- a/pytools/tag.py +++ b/pytools/tag.py @@ -37,6 +37,7 @@ from typing import ( TypeVar, Union, ) +from warnings import warn from typing_extensions import Self, dataclass_transform @@ -244,8 +245,6 @@ class Taggable: .. autoattribute:: tags - .. automethod:: __init__ - .. automethod:: _with_new_tags .. automethod:: tagged .. automethod:: without_tags @@ -255,6 +254,15 @@ class Taggable: .. versionadded:: 2021.1 """ + if not TYPE_CHECKING: + def __init__(self, tags: FrozenSet[Tag] = frozenset()): + warn("The Taggable constructor is deprecated. " + "Subclasses must declare their onwn storage for .tags. " + "The constructor will disappear in 2025.x.", + DeprecationWarning, stacklevel=2) + + self.tags = tags + # ReST references in docstrings must be fully qualified, as docstrings may # be inherited and appear in different contexts. -- GitLab