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

Update to_json Indent Type Annotation #262

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jdmoldenhauer
Copy link

Updated the to_json methods indent type annotation on the AWSObject, and AWSHelperFn to allow for None. Added unit tests to ensure the string representation is as expected.

Sending an integer, or string to json.dumps indent parameter results in a pretty printed json string with new lines in it. Sending in None results in the most compact representation.

For example:

>>> import json
>>> json.dumps({'a': 'b'}, indent=0)
'{\n"a": "b"\n}'
>>> json.dumps({'a': 'b'}, indent=-1)
'{\n"a": "b"\n}'
>>> json.dumps({'a': 'b'}, indent='')
'{\n"a": "b"\n}'
>>> json.dumps({'a': 'b'}, indent=4)
'{\n    "a": "b"\n}'
>>> json.dumps({'a': 'b'}, indent=None)
'{"a": "b"}'

This change allows for the last option, sending in None to get the most compact representation.

I have no idea if this is a desired change, and I apologize if I should have opened an issue first. The change was so small though I figured why not just open a PR, and if this change isn't desired we can talk about it here. No worries if this isn't something desired for the code base.

Thank you!

Updated the to_json methods indent type annotation on the AWSObject, and
AWSHelperFn to allow for None. Added unit tests to ensure the string
representation is correct.

Sending an integer, or string to 'json.dumps' indent parameter results in a
pretty printed json string with new lines in it. Sending in None results in
the most compact representation.
Copy link
Contributor

@michael-k michael-k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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

Successfully merging this pull request may close these issues.

2 participants