Currently, the JsonPointer.join() method always returns a JsonPointer instance, even when called from a subclass:
classPointer(jsonpointer.JsonPointer):
...
base=Pointer("/some/object")
end=Pointer("/actual/value")
full=base.join(end)
print(type(full))
# <class 'jsonpointer.JsonPointer'>If join() (and probably other methods) instead returned instances of self.__class__ instead of JsonPointer normal behavior would stay the same while allowing subclasses to work as expected.
E.g. with join() as:
defjoin(self, suffix):
""" Returns a new JsonPointer with the given suffix append to this ptr """ifisinstance(suffix, self.__class__):
suffix_parts=suffix.partselifisinstance(suffix, str):
suffix_parts=self.__class__(suffix).partselse:
suffix_parts=suffixtry:
returnself.__class__.from_parts(chain(self.parts, suffix_parts))
except: # noqa E722raiseJsonPointerException("Invalid suffix")You'd get:
print(type(JsonPointer("/some/object") /JsonPointer("/actual/value")))
# <class 'jsonpointer.JsonPointer'>print(type(Pointer("/some/object") /Pointer("/actual/value")))
# <class '__main__.Pointer'>
Currently, the
JsonPointer.join()method always returns aJsonPointerinstance, even when called from a subclass:If
join()(and probably other methods) instead returned instances ofself.__class__instead ofJsonPointernormal behavior would stay the same while allowing subclasses to work as expected.E.g. with
join()as:You'd get: