-
Notifications
You must be signed in to change notification settings - Fork 123
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
chore: Remove unused parameters recursively #542
chore: Remove unused parameters recursively #542
Conversation
Codecov Report
@@ Coverage Diff @@
## main #542 +/- ##
=======================================
Coverage 94.35% 94.35%
=======================================
Files 71 71
Lines 10409 10409
Branches 1089 1089
=======================================
Hits 9821 9821
Misses 419 419
Partials 169 169
Continue to review full report at Codecov.
|
3c626fa
to
1ea4a8d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for moving this into a separate issue, I think it warrants its own discussion.
The reason we had these in the first place is to enable developers to customize json_dumps
and then be able to pass arguments through save_json
without also having to overwrite that method. I created a branch off of this one with a failing test to illustrate an example usage. That failing test is based on using ujson
, but another example might be a case where someone wants to customize json_dumps
to use the indent
argument in certain cases.
I think an argument could be made that it is not that much extra effort to also overwrite save_json
in this case and that maybe it's actually preferable to explicitly overwrite any method signatures that need customizing rather than rely on automatically passing arbitrary arguments. We're passing these arbitrary arguments from StacIO.save_json
to StacIO.json_dumps
, but not to StacIO.write_text
, which is also called by that method. If someone adds arguments in a custom StacIO.write_text
implementation they would also need to overwrite StacIO.save_json
to include those arguments. Why is this required for write_text
but not json_dumps
?
It would be good to get comments from maintainers of other downstream libraries to see if/how they use this feature.
@matthewhanson @gadomski Are there examples of where this kind of customization is used?
@lossyrob Are there other examples of usages that would require these arbitrary args/kwargs
?
Not in core stactools. In the main method override, |
Why not just always forward def json_dumps(self, json_dict: Dict[str, Any], *args: Any, **kwargs: Any) -> str:
if orjson is not None:
return orjson.dumps(json_dict, *args, option=orjson.OPT_INDENT_2, **kwargs).decode("utf-8")
else:
return json.dumps(json_dict, *args, indent=2, **kwargs) |
Yes, that totally makes sense! Not sure why we didn't do that in the first place... |
1ea4a8d
to
86d9f19
Compare
@duckontheweb I've changed the code to take the optional arguments where applicable. For example, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks for helping us iron this out.
Since
orjson.dumps
andjson.dumps
don't support the same options, weprobably don't want to forward arbitrary arguments to them in any case.
Related Issue(s): #331
Description:
PR Checklist:
pre-commit run --all-files
)scripts/test
)