Message ID | 20220516141022.96327-7-tomi.valkeinen@ideasonboard.com |
---|---|
State | Superseded |
Headers | show |
Series |
|
Related | show |
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@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)
On 17/05/2022 11:19, Laurent Pinchart wrote: > 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@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. Yes. It's a test. I want to get formats and see that it gets released (or rather, the whole object chain gets released in the end, and we observe that camera & cam manager gets released). Tomi
On 17/05/2022 11:21, Tomi Valkeinen wrote: > On 17/05/2022 11:19, Laurent Pinchart wrote: >> 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@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. > > Yes. It's a test. I want to get formats and see that it gets released > (or rather, the whole object chain gets released in the end, and we > observe that camera & cam manager gets released). Actually, I should just assert that fmts != None. That both adds another test check, and should get rid of the typechecker warnings. Tomi
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 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)
Add some annotations to reduce the typechecker warnings. Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> --- test/py/unittests.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)