pystac icon indicating copy to clipboard operation
pystac copied to clipboard

`clone` shouldn't hard-code return type

Open TomAugspurger opened this issue 3 years ago • 0 comments

In methods like https://github.com/stac-utils/pystac/blob/2e76a877b02eccf4d8e8ec6ad7b4aa7cf09aa268/pystac/collection.py#L100-L102, .clone() uses the class itself.

class Extent:
    def clone(self):
        return Extent(...)

Instead of hard-coding Extent(...) in the return there, we should use type(self)(...) to ensure that a subclass is returned.

xref https://github.com/stac-utils/pystac/issues/862, which also relates to subclasses.

TomAugspurger avatar Jul 29 '22 14:07 TomAugspurger