summaryrefslogtreecommitdiff
path: root/linuxnamespaces
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2024-06-11 22:40:29 +0200
committerHelmut Grohne <helmut@subdivi.de>2024-06-11 22:40:29 +0200
commite2f359f814805285e7ece3c9edba2cc93c958540 (patch)
tree9357a253df4b5009b058dae4dedee4828eaa8f9d /linuxnamespaces
parente7f8500644717d3e4049cb981472e376c8984055 (diff)
downloadpython-linuxnamespaces-e2f359f814805285e7ece3c9edba2cc93c958540.tar.gz
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.
Diffstat (limited to 'linuxnamespaces')
-rw-r--r--linuxnamespaces/__init__.py2
-rw-r--r--linuxnamespaces/atlocation.py2
-rw-r--r--linuxnamespaces/tarutils.py6
3 files changed, 7 insertions, 3 deletions
diff --git a/linuxnamespaces/__init__.py b/linuxnamespaces/__init__.py
index 65dfc8d..5a9ef39 100644
--- a/linuxnamespaces/__init__.py
+++ b/linuxnamespaces/__init__.py
@@ -16,7 +16,7 @@ import stat
import subprocess
import typing
-from .filedescriptor import FileDescriptor
+from .filedescriptor import *
from .atlocation import *
from .syscalls import *
diff --git a/linuxnamespaces/atlocation.py b/linuxnamespaces/atlocation.py
index 8a38650..20d402a 100644
--- a/linuxnamespaces/atlocation.py
+++ b/linuxnamespaces/atlocation.py
@@ -21,7 +21,7 @@ from .filedescriptor import FileDescriptor
AT_FDCWD = FileDescriptor(-100)
-PathConvertible = typing.Union[str, os.PathLike]
+PathConvertible = typing.Union[str, os.PathLike[str]]
class AtFlags(enum.IntFlag):
diff --git a/linuxnamespaces/tarutils.py b/linuxnamespaces/tarutils.py
index facb537..6285d5a 100644
--- a/linuxnamespaces/tarutils.py
+++ b/linuxnamespaces/tarutils.py
@@ -19,7 +19,11 @@ TarPath = str | bytes | os.PathLike[str] | os.PathLike[bytes]
class ZstdTarFile(tarfile.TarFile):
"""Subclass of tarfile.TarFile that can read zstd compressed archives."""
- OPEN_METH = {"zst": "zstopen"} | tarfile.TarFile.OPEN_METH
+ # mypy types OPEN_METH as Mapping rather than dict while it really is a
+ # dict. Hence, it complains that there is no __or__ for dict and Mapping.
+ OPEN_METH = {
+ "zst": "zstopen",
+ } | tarfile.TarFile.OPEN_METH # type: ignore[operator]
@classmethod
def zstopen(