From patchwork Mon May 16 14:10:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 15912 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id F16B7C326D for ; Mon, 16 May 2022 14:10:57 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D31CF6566C; Mon, 16 May 2022 16:10:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652710256; bh=0K2ROD8e2fMSSZhVgjcTx+alQj+rvakcSDAIWLV9tJ0=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=T6TNvMj9HRpei4ti2I1q4buoIb1X0YkhwyasSuRbb5tvCRRLHcA89f1QzdBbmOcqC V2LiVknUeTCYmsUWXMFf04YWampZIpTuIrksaLJND4lcUKXI5L+4yzqsIn8owH6FLI Vy9CBiL4HVLDU7itnQ3xWG8pe8pAxXOGB7rbIbcSjz6dlM9AwAJX8Hlnj1iC0rfcXM 0RWFMxtun6o+9Y+RijoC8QIj1pmQgGbF3OMwWHFQn5+OQY5idzXzhn5RaNCHlW4iDC Y5ctnYM7GYqAEqvZfBfqZ6XZMQle2nGAbo158Cy3hsPot31DUoewWALFcVWRcI4Srl olX7BOPssHEJg== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id F051865665 for ; Mon, 16 May 2022 16:10:50 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="iy/V0Ij6"; dkim-atps=neutral Received: from deskari.lan (91-156-85-209.elisa-laajakaista.fi [91.156.85.209]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 5BB6A48F; Mon, 16 May 2022 16:10:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652710250; bh=0K2ROD8e2fMSSZhVgjcTx+alQj+rvakcSDAIWLV9tJ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iy/V0Ij6WeQdV7LYiRfLF+cE3wvv+KKVS6Ic0zIVEAr+AdWSdUWMpl4y7gkeIvk5e 2/2Vs5DxJNbVFpyzvGIYUXo38SIXufGh4KT7/zGfs1Ts6dV8PApOTSSMkIaA4a4I8S 4IzC55bDUUepCPzlkE7q1ae52vskFoHi8PXvj/VM= To: libcamera-devel@lists.libcamera.org, David Plowman , Kieran Bingham , Laurent Pinchart , Jacopo Mondi Date: Mon, 16 May 2022 17:10:14 +0300 Message-Id: <20220516141022.96327-7-tomi.valkeinen@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220516141022.96327-1-tomi.valkeinen@ideasonboard.com> References: <20220516141022.96327-1-tomi.valkeinen@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 06/14] py: unittests: make typechecker happy X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Tomi Valkeinen via libcamera-devel From: Tomi Valkeinen Reply-To: Tomi Valkeinen Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add some annotations to reduce the typechecker warnings. Signed-off-by: Tomi Valkeinen --- 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 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)