Skip to content

Commit 79a2b1e

Browse files
committed
Use repr() for value formatting in error messages and validation descriptions
Signed-off-by: Tsuyoshi Hombashi <[email protected]>
1 parent c6858fe commit 79a2b1e

File tree

4 files changed

+4
-6
lines changed

4 files changed

+4
-6
lines changed

pathvalidate/_const.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44

55
DEFAULT_MIN_LEN: Final = 1
6-
INVALID_CHAR_ERR_MSG_TMPL: Final = "invalids=({invalid}), value={value}"
6+
INVALID_CHAR_ERR_MSG_TMPL: Final = "invalids=({invalid}), value={value!r}"
77

88

99
_NTFS_RESERVED_FILE_NAMES: Final = (

pathvalidate/_filename.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ def validate(self, value: PathType) -> None:
212212

213213
def validate_abspath(self, value: str) -> None:
214214
err = ValidationError(
215-
description=f"found an absolute path ({value}), expected a filename",
215+
description=f"found an absolute path ({value!r}), expected a filename",
216216
platform=self.platform,
217217
reason=ErrorReason.FOUND_ABS_PATH,
218218
)

pathvalidate/_filepath.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,7 @@ def validate_abspath(self, value: PathType) -> None:
258258

259259
err_object = ValidationError(
260260
description=(
261-
"an invalid absolute file path ({}) for the platform ({}).".format(
262-
value, self.platform.value
263-
)
261+
f"an invalid absolute file path ({value!r}) for the platform ({self.platform.value})."
264262
+ " to avoid the error, specify an appropriate platform corresponding to"
265263
+ " the path format or 'auto'."
266264
),

pathvalidate/error.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ def __str__(self) -> str:
191191
if self.__byte_count is not None:
192192
item_list.append(f"{ErrorAttrKey.BYTE_COUNT}={self.__byte_count:,d}")
193193
if self.__value:
194-
item_list.append(f"{ErrorAttrKey.VALUE}={self.__value}")
194+
item_list.append(f"{ErrorAttrKey.VALUE}={self.__value!r}")
195195

196196
if item_list:
197197
header += ": "

0 commit comments

Comments
 (0)