-
Notifications
You must be signed in to change notification settings - Fork 229
Open
Labels
discussionsNeed more discussion before taking further actionsNeed more discussion before taking further actions
Description
Currently, the error messages are in the following style:
>>> arg = "invalid"
>>> msg = f"Invalid value: '{arg}'."
>>> print(msg)
Invalid value: 'invalid'.
>>> arg = 10
>>> msg = f"Invalid value: '{arg}'."
>>> print(msg)
Invalid value: '10'.
>>> arg = None
>>> msg = f"Invalid value: '{arg}'."
>>> print(msg)
Invalid value: 'None'.
The cons are:
- Extra single quotes in f-strings
- Values are always enclosed in single quotes, regardless of the types
I propose to use type conversion !r
in the new style:
>>> arg = "invalid"
>>> msg = f"Invalid value: {arg!r}."
>>> print(msg)
Invalid value: 'invalid'.
>>> arg = 10
>>> msg = f"Invalid value: {arg!r}."
>>> print(msg)
Invalid value: 10.
>>> arg = None
>>> msg = f"Invalid value: {arg!r}."
>>> print(msg)
Invalid value: None.
>>> arg = [10, 20, 30]
>>> msg = f"Invalid value: {arg!r}."
>>> print(msg)
Invalid value: [10, 20, 30].
👍 if you like new style; 👎 if you like the old style; or leave your comments.
Metadata
Metadata
Assignees
Labels
discussionsNeed more discussion before taking further actionsNeed more discussion before taking further actions