TIL in my #python#mypy adventures, the proper way to set up a class that returns itself is to use the Self typing annotation and return values by calling self.__class__ on the new value
from typing import Self
class ImActuallyAString(str):
def one_longer(self) -> Self:
return self.__class__(self + "one")
I'd call type(self)(...) on the new item. I prefer to avoid dunder attributes when there's a higher-level way to access the same thing.
This is not a universally agreed upon convention though, as there are parts of CPython's source code that use self.class and parts that use type(self). Most of the self.class parts are older and may have predated type(...) being usable (old-style classes didn't work well with type back in Python 2).