From ceb9f8477dc1a061c7cf769d09c7ec504cd95f93 Mon Sep 17 00:00:00 2001
From: Andreas Kloeckner <inform@tiker.net>
Date: Thu, 3 Nov 2022 16:57:08 +0100
Subject: [PATCH] Stop using Self type for the moment

---
 pytools/tag.py | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/pytools/tag.py b/pytools/tag.py
index dcc170c..d58cda5 100644
--- a/pytools/tag.py
+++ b/pytools/tag.py
@@ -22,6 +22,10 @@ Internal stuff that is only here because the documentation tool wants it
 .. class:: TagT
 
     A type variable with lower bound :class:`Tag`.
+
+.. class:: _Self_Taggable
+
+    A type variable with lower bound :class:`Taggable`.
 """
 
 import sys
@@ -31,12 +35,6 @@ from typing import (Tuple, Set, Any, FrozenSet, Union, Iterable,  # noqa: F401
 from pytools import memoize, memoize_method
 
 
-try:
-    from typing import Self  # type: ignore[attr-defined]
-except ImportError:
-    from typing_extensions import Self
-
-
 __copyright__ = """
 Copyright (C) 2020 Andreas Klöckner
 Copyright (C) 2020 Matt Wala
@@ -168,6 +166,8 @@ class UniqueTag(Tag):
 
 ToTagSetConvertible = Union[Iterable[Tag], Tag, None]
 TagT = TypeVar("TagT", bound="Tag")
+# FIXME: Replace by Self type
+_Self_Taggable = TypeVar("_Self_Taggable", bound="Taggable")
 
 
 # {{{ UniqueTag rules checking
@@ -265,7 +265,7 @@ class Taggable:
         """
         self.tags = tags
 
-    def _with_new_tags(self, tags: FrozenSet[Tag]) -> Self:
+    def _with_new_tags(self: _Self_Taggable, tags: FrozenSet[Tag]) -> _Self_Taggable:
         """
         Returns a copy of *self* with the specified tags. This method
         should be overridden by subclasses.
@@ -282,7 +282,7 @@ class Taggable:
         # abstract method.
         return self.copy(tags=tags)  # type: ignore[attr-defined]  # pylint: disable=no-member  # noqa: E501
 
-    def tagged(self, tags: ToTagSetConvertible) -> Self:
+    def tagged(self: _Self_Taggable, tags: ToTagSetConvertible) -> _Self_Taggable:
         """
         Return a copy of *self* with the specified
         tag or tags added to the set of tags. If the resulting set of
@@ -295,8 +295,9 @@ class Taggable:
         return self._with_new_tags(
                 tags=check_tag_uniqueness(normalize_tags(tags) | self.tags))
 
-    def without_tags(self,
-            tags: ToTagSetConvertible, verify_existence: bool = True) -> Self:
+    def without_tags(self: _Self_Taggable,
+                     tags: ToTagSetConvertible, verify_existence: bool = True
+                     ) -> _Self_Taggable:
         """
         Return a copy of *self* without the specified tags.
 
-- 
GitLab