@@ -198,6 +198,7 @@ def index(self, sub, start=0, end=sys.maxsize) -> int:
198198 return self .unmask ().index (sub .unmask (), start , end )
199199 return super ().index (sub , start , end )
200200
201+ # Not sure if this should return the unmasked result or the masked result
201202 # @override
202203 # def isalpha(self) -> bool:
203204 # return self.unmask().isalpha()
@@ -265,13 +266,14 @@ def lower(self) -> "MaskString":
265266
266267 @override
267268 def lstrip (self , chars = None ) -> "MaskString" :
268- s_chars = chars
269+ chars_s = chars
269270 if isinstance (chars , MaskString ):
270- s_chars = chars . unmask ()
271- # explicitly set chars to the empty string as we want the resulting masked string to stay the same
272- chars = ""
273- return MaskString (self .unmask ().lstrip (s_chars ), masked_value = super ().lstrip (chars ))
271+ # we want the resulting masked string to stay the same as otherwise it would most likely just strip all the characters
272+ chars_s = chars . unmask ()
273+ return MaskString ( self . unmask (). lstrip ( chars_s ), masked_value = str ( self ))
274+ return MaskString (self .unmask ().lstrip (chars ), masked_value = super ().lstrip (chars ))
274275
276+ # I don't know how maketrans works... default to using the masked value
275277 # maketrans = str.maketrans
276278
277279 @override
@@ -337,11 +339,12 @@ def rpartition(self, sep) -> tuple["MaskString", "MaskString", "MaskString"]:
337339 def rstrip (self , chars = None ) -> "MaskString" :
338340 chars_s = chars
339341 if isinstance (chars , MaskString ):
340- chars = chars . unmask ()
341- # explicitly set chars to the empty string as we want the resulting masked string to stay the same
342- chars = ""
342+ # we want the resulting masked string to stay the same as otherwise it would most likely just strip all the characters
343+ chars_s = chars . unmask ()
344+ return MaskString ( self . unmask (). rstrip ( chars_s ), masked_value = str ( self ))
343345 return MaskString (self .unmask ().rstrip (chars_s ), masked_value = super ().rstrip (chars ))
344346
347+ # There is no way to keep the split functions "in-sync" with the masked string and the raw_value
345348 # @override
346349 # def split(self, sep=None, maxsplit=-1) -> list[MaskString]:
347350 # if isinstance(sep, MaskString):
@@ -371,9 +374,9 @@ def startswith(self, prefix, start=0, end=sys.maxsize) -> bool:
371374 def strip (self , chars = None ) -> "MaskString" :
372375 chars_s = chars
373376 if isinstance (chars , MaskString ):
377+ # we want the resulting masked string to stay the same as otherwise it would most likely just strip all the characters
374378 chars_s = chars .unmask ()
375- # explicitly set chars to the empty string as we want the resulting masked string to stay the same
376- chars = ""
379+ return MaskString (self .unmask ().strip (chars_s ), masked_value = str (self ))
377380 return MaskString (self .unmask ().strip (chars_s ), masked_value = super ().strip (chars ))
378381
379382 @override
@@ -384,6 +387,7 @@ def swapcase(self) -> "MaskString":
384387 def title (self ) -> "MaskString" :
385388 return MaskString (self .unmask ().title (), masked_value = super ().title ())
386389
390+ # I don't know how translate works... default to using the masked value
387391 # @override
388392 # def translate(self, *args) -> 'MaskString':
389393 # return MaskString(self.unmask().translate(*args))
0 commit comments