pystac
pystac copied to clipboard
`clone` shouldn't hard-code return type
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.