-
Notifications
You must be signed in to change notification settings - Fork 2k
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
make json viewer more clear (reopen) #2350
base: master
Are you sure you want to change the base?
Conversation
I propose:
And then, we can add some JSON_FORMATTED = FALSE or something like this to types. @Badiboy need your opinion. This way, users will be able to see a CLEAR response from Telegram. |
Debug mode have full and clear responces of the Telegram.
I have no willing to waste my and others server resources for storing json strings that I never used before and will never use in future for the only purpose that one guy after several years of library existence occasionally decided to have pretty output. Except you will make it SO OPTIONAL that it will affect NOBODY except they obviously decided to use it. |
Makes sense We still need changes to the output of the types though; Then, we can stick to the current implementation, but with pretty-printing optional. |
I have nothing against pretty output as I said from the very beginning which is:
Intermediate version that was discussed that allowed:
Looked fine for me. |
Is disabling Nones by default fine with you? |
Mmm... Let's be like that as far as Nones are really useless and it should be more or less clear that if you do not see property - it's empty. |
Well I don't see any use case for seeing Nones. They are useless as API does not provide them. |
Allright! Create 2 variables:
Use these to pretty print and output None values if necessary. |
@coder2020official Done Aslo, what about adding |
@Badiboy do you think parse indent is this necessary |
What's that? |
telebot/types.py
Outdated
} | ||
) | ||
return ( | ||
json.dumps(self, default=default, indent=2, ensure_ascii=False) |
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.
indent number here
@2ei just implement it, won't hurt |
Thanks for the PR. Will test it out ASAP |
telebot/types.py
Outdated
} | ||
return str(d) | ||
def __str__(self) -> str: | ||
default = ( |
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.
Frankly speaking, I do not understand anything in this pigeon talk. It takes too much time to decode.
Can this code be rewriten in adequate if / then / else mode? So ANYBODY who see it can understand what will be returned in what case?
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.
OK
@2ei Thank you. |
LGTM. Just one more think: @Badiboy do you think it would be better if this PR also removes json field in the output? or do you think it will be necessary? It is just a repetition of the whole dict. |
Romoving json looks reasonable: no need to duplicate the same data. |
what should i do in your opinion?, convert Also i just noticed that there is no type hint for json parameter, on my way to add it too. |
LGTM. What did we agree on json? |
idk, i have 2 suggestions here, what is the best one for you @coder2020official ? |
@Badiboy this has been on for a long time. do you think we should convert json to property? |
reopened #2334