[libcamera-devel] [PATCH 06/14] py: unittests: make typechecker happy
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Tue May 17 10:19:54 CEST 2022
Hi Tomi,
Thank you for the patch.
On Mon, May 16, 2022 at 05:10:14PM +0300, Tomi Valkeinen wrote:
> Add some annotations to reduce the typechecker warnings.
>
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen at ideasonboard.com>
> ---
> test/py/unittests.py | 17 +++++++++++------
> 1 file changed, 11 insertions(+), 6 deletions(-)
>
> diff --git a/test/py/unittests.py b/test/py/unittests.py
> index 288dcd48..e5591f3f 100755
> --- a/test/py/unittests.py
> +++ b/test/py/unittests.py
> @@ -10,6 +10,7 @@ import libcamera as libcam
> import os
> import selectors
> import time
> +import typing
> import unittest
> import weakref
>
> @@ -70,6 +71,9 @@ class SimpleTestMethods(BaseTestCase):
>
>
> class CameraTesterBase(BaseTestCase):
> + cm: typing.Any
> + cam: typing.Any
> +
> def setUp(self):
> self.cm = libcam.CameraManager.singleton()
> self.cam = next((cam for cam in self.cm.cameras if 'platform/vimc' in cam.id), None)
> @@ -131,8 +135,8 @@ class AllocatorTestMethods(CameraTesterBase):
> self.assertTrue(ret > 0)
> wr_allocator = weakref.ref(allocator)
>
> - buffers = allocator.buffers(stream)
> - buffers = None
> + buffers = allocator.buffers(stream) # type: ignore
> + buffers = None # type: ignore
>
> buffer = allocator.buffers(stream)[0]
> self.assertIsNotNone(buffer)
> @@ -166,7 +170,8 @@ class SimpleCaptureMethods(CameraTesterBase):
> self.assertTrue(camconfig.size == 1)
>
> streamconfig = camconfig.at(0)
> - fmts = streamconfig.formats
> + fmts = streamconfig.formats # type: ignore
> + fmts = None # type: ignore
Was this intended ? Actually, fmts doesn't seem to be used at all.
>
> ret = cam.configure(camconfig)
> self.assertZero(ret)
> @@ -225,7 +230,7 @@ class SimpleCaptureMethods(CameraTesterBase):
> self.assertTrue(camconfig.size == 1)
>
> streamconfig = camconfig.at(0)
> - fmts = streamconfig.formats
> + fmts = streamconfig.formats # type: ignore
>
> ret = cam.configure(camconfig)
> self.assertZero(ret)
> @@ -349,9 +354,9 @@ if __name__ == '__main__':
> gc.unfreeze()
> gc.collect()
>
> - obs_after = get_all_objects([obs_before])
> + obs_after = get_all_objects([obs_before]) # type: ignore
>
> - before = create_type_count_map(obs_before)
> + before = create_type_count_map(obs_before) # type: ignore
> after = create_type_count_map(obs_after)
>
> leaks = diff_type_count_maps(before, after)
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list