Skip to content

Commit 0244ef7

Browse files
authored
[stdlib][os] Change some str types to LiteralString (#15018)
1 parent 79ac2bc commit 0244ef7

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

stdlib/os/__init__.pyi

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,22 @@ from typing import (
4141
runtime_checkable,
4242
type_check_only,
4343
)
44-
from typing_extensions import Self, TypeAlias, Unpack, deprecated
44+
from typing_extensions import LiteralString, Self, TypeAlias, Unpack, deprecated
4545

4646
from . import path as _path
4747

48+
# Re-export common definitions from os.path to reduce duplication
49+
from .path import (
50+
altsep as altsep,
51+
curdir as curdir,
52+
defpath as defpath,
53+
devnull as devnull,
54+
extsep as extsep,
55+
pardir as pardir,
56+
pathsep as pathsep,
57+
sep as sep,
58+
)
59+
4860
__all__ = [
4961
"F_OK",
5062
"O_APPEND",
@@ -674,19 +686,8 @@ if sys.platform != "win32":
674686
ST_NOSUID: Final[int]
675687
ST_RDONLY: Final[int]
676688

677-
curdir: str
678-
pardir: str
679-
sep: str
680-
if sys.platform == "win32":
681-
altsep: str
682-
else:
683-
altsep: str | None
684-
extsep: str
685-
pathsep: str
686-
defpath: str
687689
linesep: Literal["\n", "\r\n"]
688-
devnull: str
689-
name: str
690+
name: LiteralString
690691

691692
F_OK: Final = 0
692693
R_OK: Final = 4

0 commit comments

Comments
 (0)