Skip to content

Commit 0f5f7bd

Browse files
committed
Improve representation of sentinel object for "newline" argument in paths.py
1 parent 4dbbf35 commit 0f5f7bd

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

domdf_python_tools/paths.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
"compare_dirs",
105105
]
106106

107-
newline_default = object()
107+
NEWLINE_DEFAULT = type("NEWLINE_DEFAULT", (object, ), {"__repr__": lambda self: "NEWLINE_DEFAULT"})()
108108

109109
_P = TypeVar("_P", bound=pathlib.Path)
110110
"""
@@ -554,7 +554,7 @@ def open( # type: ignore # noqa A003
554554
buffering: int = -1,
555555
encoding: Optional[str] = "UTF-8",
556556
errors: Optional[str] = None,
557-
newline: Optional[str] = newline_default, # type: ignore
557+
newline: Optional[str] = NEWLINE_DEFAULT,
558558
) -> IO[Any]:
559559
"""
560560
Open the file pointed by this path and return a file object, as
@@ -581,7 +581,7 @@ def open( # type: ignore # noqa A003
581581
encoding = None
582582
newline = None
583583

584-
if newline is newline_default:
584+
if newline is NEWLINE_DEFAULT:
585585
if 'r' in mode:
586586
newline = None
587587
else:

0 commit comments

Comments
 (0)