From cd9bc3c28419b530a228bb4270502c8c5eda90c7 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Sun, 29 Jun 2025 07:50:58 +0300 Subject: [PATCH 1/3] `os.linesep` can only be `\n` or `\r\n` See: - https://github.com/python/cpython/blob/5334732f9c8a44722e4b339f4bb837b5b0226991/Lib/os.py#L52-L54 for POSIX - https://github.com/python/cpython/blob/5334732f9c8a44722e4b339f4bb837b5b0226991/Lib/os.py#L76-L78 on Windows --- stdlib/os/__init__.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/os/__init__.pyi b/stdlib/os/__init__.pyi index 5286c76d1b06..dd4479f9030a 100644 --- a/stdlib/os/__init__.pyi +++ b/stdlib/os/__init__.pyi @@ -683,7 +683,7 @@ else: extsep: str pathsep: str defpath: str -linesep: str +linesep: Literal["\n", "\r\n"] devnull: str name: str From 7a73c6a7e73d0af9addfbbf440d8b29ddb863046 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Mon, 30 Jun 2025 12:04:04 +0300 Subject: [PATCH 2/3] Address review --- stdlib/os/__init__.pyi | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/stdlib/os/__init__.pyi b/stdlib/os/__init__.pyi index dd4479f9030a..b85c43123e78 100644 --- a/stdlib/os/__init__.pyi +++ b/stdlib/os/__init__.pyi @@ -683,7 +683,10 @@ else: extsep: str pathsep: str defpath: str -linesep: Literal["\n", "\r\n"] +if sys.platform == "win32": + linesep: Literal["\r\n"] +else: + linesep: Literal["\n"] devnull: str name: str From 1a2729b0767f64db9bed7b76df3cd03818ceeeb4 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Mon, 30 Jun 2025 12:50:26 +0300 Subject: [PATCH 3/3] Update __init__.pyi --- stdlib/os/__init__.pyi | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/stdlib/os/__init__.pyi b/stdlib/os/__init__.pyi index b85c43123e78..dd4479f9030a 100644 --- a/stdlib/os/__init__.pyi +++ b/stdlib/os/__init__.pyi @@ -683,10 +683,7 @@ else: extsep: str pathsep: str defpath: str -if sys.platform == "win32": - linesep: Literal["\r\n"] -else: - linesep: Literal["\n"] +linesep: Literal["\n", "\r\n"] devnull: str name: str