Skip to content
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

Better handling of optional extras #17

Closed
kalekundert opened this issue Feb 1, 2021 · 0 comments
Closed

Better handling of optional extras #17

kalekundert opened this issue Feb 1, 2021 · 0 comments

Comments

@kalekundert
Copy link
Owner

kalekundert commented Feb 1, 2021

Right now, if a requested extra key isn't present in the file, wellmap just pretends like that key wasn't requested. This is pretty bad behavior, because it makes the return signature depend on the input file.

The question is how to better handle missing extra keys. Some options:

  1. Return None or {} for missing keys. This isn't great, though, because these won't be sensible defaults in all cases.
  2. Allow the extras argument to be a {key: default} dictionary, and error out if we find a missing key without a default. This is backwards compatible, but adds a lot of complexity to the API (including the need to deal with mutable default values).
  3. Always return the extras as a dictionary. Missing values would simply not be present, and the user would have to deal with that. This is simpler than #2, but breaks backwards compatibility and complicates the case where only a single extra is requested.
  4. Make the extras argument a simple boolean, where True just means to return a dictionary of all the non-wellmap fields. Or I could even include the wellmap fields; maybe there's some use for that. This avoids forcing the user to specify the same key twice (a smell with #3), but also breaks backwards compatibility.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant