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

Do things right when obj is a tuple #4

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

Conversation

alexbarcelo
Copy link

@alexbarcelo alexbarcelo commented Dec 20, 2021

When obj is a tuple, this raise yields a TypeError given that the formatting is not resolved.

The proper way of doing this is by ensuring that a tuple is being used for string formatting (in particular, a single element tuple).

And, on the way there, it's much better to use %r in this context, just in case obj is a complex object and has a non-trivial __str__ method --while the __repr__ method should be simpler. In a lot of scenarios this change is imperceptible, in others improves log messages a lot.

When `obj` is a tuple, this raise yields a TypeError given that the formatting is not resolved.

The proper way of doing this is by ensuring that a tuple is being used for string formatting (in particular, a single element tuple).

And, on the way there, it's much better to use `%r` in this context, just in case `obj` is a complex object and has a non-trivial `__str__` method --while the `__repr__` method should be simpler. In a lot of scenarios this change is imperceptible, in others improves log messages a lot.
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.

1 participant