Skip to content

Commit de81abb

Browse files
authored
Annotate env in os.posix_spawn as optional (#15110)
1 parent fcc9ebc commit de81abb

File tree

1 file changed

+60
-28
lines changed

1 file changed

+60
-28
lines changed

stdlib/os/__init__.pyi

Lines changed: 60 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,34 +1477,66 @@ else:
14771477
def WEXITSTATUS(status: int) -> int: ...
14781478
def WSTOPSIG(status: int) -> int: ...
14791479
def WTERMSIG(status: int) -> int: ...
1480-
def posix_spawn(
1481-
path: StrOrBytesPath,
1482-
argv: _ExecVArgs,
1483-
env: _ExecEnv,
1484-
/,
1485-
*,
1486-
file_actions: Sequence[tuple[Any, ...]] | None = ...,
1487-
setpgroup: int | None = ...,
1488-
resetids: bool = ...,
1489-
setsid: bool = ...,
1490-
setsigmask: Iterable[int] = ...,
1491-
setsigdef: Iterable[int] = ...,
1492-
scheduler: tuple[Any, sched_param] | None = ...,
1493-
) -> int: ...
1494-
def posix_spawnp(
1495-
path: StrOrBytesPath,
1496-
argv: _ExecVArgs,
1497-
env: _ExecEnv,
1498-
/,
1499-
*,
1500-
file_actions: Sequence[tuple[Any, ...]] | None = ...,
1501-
setpgroup: int | None = ...,
1502-
resetids: bool = ...,
1503-
setsid: bool = ...,
1504-
setsigmask: Iterable[int] = ...,
1505-
setsigdef: Iterable[int] = ...,
1506-
scheduler: tuple[Any, sched_param] | None = ...,
1507-
) -> int: ...
1480+
1481+
if sys.version_info >= (3, 13):
1482+
def posix_spawn(
1483+
path: StrOrBytesPath,
1484+
argv: _ExecVArgs,
1485+
env: _ExecEnv | None, # None allowed starting in 3.13
1486+
/,
1487+
*,
1488+
file_actions: Sequence[tuple[Any, ...]] | None = ...,
1489+
setpgroup: int | None = ...,
1490+
resetids: bool = ...,
1491+
setsid: bool = ...,
1492+
setsigmask: Iterable[int] = ...,
1493+
setsigdef: Iterable[int] = ...,
1494+
scheduler: tuple[Any, sched_param] | None = ...,
1495+
) -> int: ...
1496+
def posix_spawnp(
1497+
path: StrOrBytesPath,
1498+
argv: _ExecVArgs,
1499+
env: _ExecEnv | None, # None allowed starting in 3.13
1500+
/,
1501+
*,
1502+
file_actions: Sequence[tuple[Any, ...]] | None = ...,
1503+
setpgroup: int | None = ...,
1504+
resetids: bool = ...,
1505+
setsid: bool = ...,
1506+
setsigmask: Iterable[int] = ...,
1507+
setsigdef: Iterable[int] = ...,
1508+
scheduler: tuple[Any, sched_param] | None = ...,
1509+
) -> int: ...
1510+
else:
1511+
def posix_spawn(
1512+
path: StrOrBytesPath,
1513+
argv: _ExecVArgs,
1514+
env: _ExecEnv,
1515+
/,
1516+
*,
1517+
file_actions: Sequence[tuple[Any, ...]] | None = ...,
1518+
setpgroup: int | None = ...,
1519+
resetids: bool = ...,
1520+
setsid: bool = ...,
1521+
setsigmask: Iterable[int] = ...,
1522+
setsigdef: Iterable[int] = ...,
1523+
scheduler: tuple[Any, sched_param] | None = ...,
1524+
) -> int: ...
1525+
def posix_spawnp(
1526+
path: StrOrBytesPath,
1527+
argv: _ExecVArgs,
1528+
env: _ExecEnv,
1529+
/,
1530+
*,
1531+
file_actions: Sequence[tuple[Any, ...]] | None = ...,
1532+
setpgroup: int | None = ...,
1533+
resetids: bool = ...,
1534+
setsid: bool = ...,
1535+
setsigmask: Iterable[int] = ...,
1536+
setsigdef: Iterable[int] = ...,
1537+
scheduler: tuple[Any, sched_param] | None = ...,
1538+
) -> int: ...
1539+
15081540
POSIX_SPAWN_OPEN: Final = 0
15091541
POSIX_SPAWN_CLOSE: Final = 1
15101542
POSIX_SPAWN_DUP2: Final = 2

0 commit comments

Comments
 (0)