From e2f359f814805285e7ece3c9edba2cc93c958540 Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Tue, 11 Jun 2024 22:40:29 +0200 Subject: improve typing linuxnamespaces/__init__.py: * linuxnamespaces.filedescriptor only exports FileDescriptor. By importing *, we re-export it implicitly. linuxnamespaces/atlocation.py: * PathLike should be parameterized and we no longer allow bytes there. linuxnamespaces/tarutils.py: * Resolve dict vs Mapping. tests/test_simple.py: * Establish expected type to mypy. examples/unschroot.py: * pidfd is first an int and later a FileDescriptor, but we always use it as int. * Also tell mypy that we cannot get NULL from waitid. --- examples/unschroot.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/unschroot.py b/examples/unschroot.py index 682b5b0..5f644fc 100755 --- a/examples/unschroot.py +++ b/examples/unschroot.py @@ -207,6 +207,7 @@ def do_run_session(args: argparse.Namespace) -> None: gidmap = linuxnamespaces.IDAllocation.loadsubid("gid").allocatemap(65536) mainsock, childsock = socket.socketpair() pid = os.fork() + pidfd: int if pid == 0: mainsock.close() os.chdir(session.path) @@ -281,7 +282,9 @@ def do_run_session(args: argparse.Namespace) -> None: os.waitpid(pid, 0) linuxnamespaces.prctl_set_child_subreaper(False) mainsock.send(b"\0") - sys.exit(os.waitid(os.P_PIDFD, pidfd, os.WEXITED).si_status) + wres = os.waitid(os.P_PIDFD, pidfd, os.WEXITED) + assert wres is not None + sys.exit(wres.si_status) def do_end_session(args: argparse.Namespace) -> None: -- cgit v1.2.3