summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xexamples/unschroot.py2
-rw-r--r--linuxnamespaces/__init__.py26
-rw-r--r--linuxnamespaces/filedescriptor.py2
-rw-r--r--tests/test_simple.py19
4 files changed, 22 insertions, 27 deletions
diff --git a/examples/unschroot.py b/examples/unschroot.py
index 5f644fc..b9d4923 100755
--- a/examples/unschroot.py
+++ b/examples/unschroot.py
@@ -184,7 +184,7 @@ def do_begin_session(args: argparse.Namespace) -> None:
def exec_perl_dumb_init(pid: int) -> typing.NoReturn:
- """Roughly impement dumb-init in perl: Wait for all children until we
+ """Roughly implement dumb-init in perl: Wait for all children until we
receive an exit from the given pid and forward its status.
"""
os.execlp(
diff --git a/linuxnamespaces/__init__.py b/linuxnamespaces/__init__.py
index 5a9ef39..df40dea 100644
--- a/linuxnamespaces/__init__.py
+++ b/linuxnamespaces/__init__.py
@@ -142,7 +142,7 @@ class IDAllocation:
raised.
"""
if count < 0:
- raise ValueError("nagative count")
+ raise ValueError("negative count")
index = bisect.bisect_right(self.ranges, (start, float("inf"))) - 1
if index < 0:
raise ValueError("range to reserve not found")
@@ -165,7 +165,7 @@ class IDAllocation:
# Requested range punches a hole into a matched range
self.ranges.insert(
index + 1,
- (start + count, cur_start + cur_count - (start + count))
+ (start + count, cur_start + cur_count - (start + count)),
)
# else: Requested range is a tail of a matched range
else:
@@ -238,6 +238,7 @@ def newidmaps(
class run_in_fork:
"""Decorator for running the decorated function once in a separate process.
"""
+
def __init__(self, function: typing.Callable[[], None]):
"""Fork a new process that will eventually run the given function and
then exit.
@@ -277,6 +278,7 @@ class async_run_in_fork:
uses the running event loop. The decorated function instead must be
synchronous and it must not access the event loop of the main process.
"""
+
def __init__(self, function: typing.Callable[[], None]):
"""Fork a new process that will eventually run the given function and
then exit.
@@ -363,12 +365,13 @@ class _ExceptionExitCallback:
"""Helper class that invokes a callback when a context manager exists with
a failure.
"""
+
def __init__(
- self,
- callback: typing.Callable[_P, typing.Any],
- *args: _P.args,
- **kwargs: _P.kwargs,
- ) -> None:
+ self,
+ callback: typing.Callable[_P, typing.Any],
+ *args: _P.args,
+ **kwargs: _P.kwargs,
+ ) -> None:
self.callback = callback
self.args = args
self.kwargs = kwargs
@@ -376,10 +379,11 @@ class _ExceptionExitCallback:
def __enter__(self) -> None:
pass
- def __exit__(self,
- exc_type: type[BaseException] | None,
- exc_value: BaseException | None,
- traceback: typing.Any,
+ def __exit__(
+ self,
+ exc_type: type[BaseException] | None,
+ exc_value: BaseException | None,
+ traceback: typing.Any,
) -> None:
if exc_type is not None:
self.callback(*self.args, **self.kwargs)
diff --git a/linuxnamespaces/filedescriptor.py b/linuxnamespaces/filedescriptor.py
index 4395a54..e4eff9b 100644
--- a/linuxnamespaces/filedescriptor.py
+++ b/linuxnamespaces/filedescriptor.py
@@ -27,7 +27,7 @@ class FileDescriptor(int):
def close(self) -> None:
"""Close the file descriptor. Since int is immutable, the caller is
- responsibe for not closing twice.
+ responsible for not closing twice.
"""
os.close(self)
diff --git a/tests/test_simple.py b/tests/test_simple.py
index e971e22..eb03384 100644
--- a/tests/test_simple.py
+++ b/tests/test_simple.py
@@ -26,8 +26,7 @@ class MountFlagsTest(unittest.TestCase):
except ValueError:
continue
self.assertEqual(
- linuxnamespaces.MountFlags.fromstr(text),
- flag
+ linuxnamespaces.MountFlags.fromstr(text), flag
)
@@ -230,16 +229,12 @@ class UnshareIdmapTest(unittest.TestCase):
@pytest.mark.forked
def test_unshare_user_idmap(self) -> None:
uidmaps = [
- linuxnamespaces.IDMapping(
- 0, self.uidalloc.allocate(65536), 65536
- ),
+ linuxnamespaces.IDMapping(0, self.uidalloc.allocate(65536), 65536),
linuxnamespaces.IDMapping(65536, os.getuid(), 1),
]
self.assertNotEqual(os.getuid(), uidmaps[0].outerstart)
gidmaps = [
- linuxnamespaces.IDMapping(
- 0, self.gidalloc.allocate(65536), 65536
- ),
+ linuxnamespaces.IDMapping(0, self.gidalloc.allocate(65536), 65536),
linuxnamespaces.IDMapping(65536, os.getgid(), 1),
]
pid = os.getpid()
@@ -260,17 +255,13 @@ class UnshareIdmapTest(unittest.TestCase):
@pytest.mark.forked
def test_populate_dev(self) -> None:
uidmaps = [
- linuxnamespaces.IDMapping(
- 0, self.uidalloc.allocate(65536), 65536
- ),
+ linuxnamespaces.IDMapping(0, self.uidalloc.allocate(65536), 65536),
# Also map our own uid to make coverage testing work
linuxnamespaces.IDMapping(65536, os.getuid(), 1),
]
self.assertNotEqual(os.getuid(), uidmaps[0].outerstart)
gidmaps = [
- linuxnamespaces.IDMapping(
- 0, self.gidalloc.allocate(65536), 65536
- ),
+ linuxnamespaces.IDMapping(0, self.gidalloc.allocate(65536), 65536),
linuxnamespaces.IDMapping(65536, os.getgid(), 1),
]
pid = os.getpid()