-
Notifications
You must be signed in to change notification settings - Fork 122
Raise exception on attempt to extend object not implementing that extension #370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I think I could use some input on how to implement this for |
I haven't seen |
My preference would be for an exception not to be thrown if the Asset doesn't have an owner, and perhaps give a warning in the documentation. This way users can build up assets before attaching them to items legitimately if that is better for their workflow. I'd rather be trusted by the library to do the right thing than to be blocked by an exception for a legitimate usage. If we do want to raise, I would say an argument to avoid raising that the user could explicitly state to work around this issue would be ideal if possible. |
@lossyrob how should the attachment work in this case? Would you want the |
The latter case - if you use an |
The other option I considered was to make the I haven't thought through the implementation in detail, but one possibility would be to extract the |
I can start by having the call succeed for un-owned and then we can always add a feature/fix to update the owning Item when adding an Asset. The breaking change is really raising the exception, so I wanted to make sure we had that ironed out for 1.0. |
Raise exception when extending object that does not have schema URI
Calling, for instance,
pystac.extensions.eo.EOExtension.ext
on anItem
that does not have the EO schema URI in itsstac_extensions
list will succeed and return anItemEOExtension
instance. You can then read and write fields likeeo:cloud_cover
even though theItem
doesn't actually implement that extension.It seems like the desired behavior here would be to raise an exception when using
ext
on an object that does not implement that extension for 2 reasons:Originally raised as part of this PR comment in stac-utils/stactools
The text was updated successfully, but these errors were encountered: