From patchwork Fri Oct 25 20:16:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tamir Duberstein X-Patchwork-Id: 13851507 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AF4EA148FF3 for ; Fri, 25 Oct 2024 20:16:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729887384; cv=none; b=Fd+AFN2/dv1+F16M5wigV8maoNFlLFad/zEbrof+1X8y/WNS4RoQDjhqBPVWHs0GEQg7dtqEm44EWAvwv0ledBkUU0L5vonx/IsN2sjUJu0iVCapavr2q3Fw3ngy5gEVoCXDdM6Y1N9D+jgm4i9yxg3uxEkQnwQUMVhTANZ05zw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729887384; c=relaxed/simple; bh=TiOmfjWkD9eZWure12ije876wWJquasB4D9SrLpkFJo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=dtK3t1h8k11bUbg33eX373Vp4QgcTlnZZ/dCompo2PYni983LO84ucEtmv47rgSA5Y4ohExwFgPhEejC+JFnntZsU5E9qUqnUJ4dNeRtVWOPciCipjXxU7HeGhQFFoGtHdyilnOLJrotEwteHgs/vsttF/R98Cm80SDL1dbfdUM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Mj+/nJe9; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Mj+/nJe9" Received: by smtp.kernel.org (Postfix) id 4D64CC4CEE5; Fri, 25 Oct 2024 20:16:24 +0000 (UTC) Received: from mail-ot1-f41.google.com (mail-ot1-f41.google.com [209.85.210.41]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp.kernel.org (Postfix) with ESMTPS id 623DFC4CECC for ; Fri, 25 Oct 2024 20:16:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 smtp.kernel.org 623DFC4CECC Authentication-Results: smtp.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ot1-f41.google.com with SMTP id 46e09a7af769-7181c0730ddso1088930a34.2 for ; Fri, 25 Oct 2024 13:16:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729887382; x=1730492182; darn=kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=W/XeZdsSRz+OxEf9GE2OFP7ZbIH3O55iQETRJ/i/gpc=; b=Mj+/nJe9vJo+s1cb9XKfv4FcbTVHH2IT/EMUda0xIFDBmXW/fccq52sT3lEZQQ5N72 Ij3/bM0o61F/O53e0SijN9b1u0QTyjDtb987VOYf+XgRfwwv3z2v2WxMaJm+WwuPEegT vstkzK3AAGiIxf30HbhhvOJwLGHCdcL8g9HAAPaPifiop3/jTCbyO2Rs+j2xQA3XjzKn qWQyrvrUhCl7wyh1dyY+wEd/mJ9N127KYZ6xHvZoU05fHEHbcN2+6+whMCh41EBQSVre MbPqtmY8u7TOG1mfYC7SMuWRzSJeoNTSY7i2PGYM4EVejVwOlsAifkD7UCuVmHvbfsZI X/Ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729887382; x=1730492182; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=W/XeZdsSRz+OxEf9GE2OFP7ZbIH3O55iQETRJ/i/gpc=; b=dkgvymtNdcE9HOdNgZsLvHw7q9ry2KVprWdrBrrQp7AJV4L+axi00pq4LqNQ46+Uwj WlX2GxagGcInSTDPwrgGdbOujIwQYb6KzOTkGJW63G4TivRr6fXd2iNz3vEMQ6qu7x5L 980NVqQq8dY4C15TODLWbKuqBB5+T2pr3W5dX3VtEOvmBellA8FuM3A2l2d2Rnu4TEbk HtL3h4PGNNVIU0CjDNLs9KmY1EJAKVbBZcYVWlikqaaKFTVG41wCxz7Itm5gHyHqXAJ3 JXy5DcQQ0B2MNO3ovl37YEYkJJSQ/DH/+QzwkLHf7/7EHrIiHl7ru6zVSYg/sn1hW+ZH nZlw== X-Gm-Message-State: AOJu0YzlfOKKfQfMMnbU34MEWWl462lAnj9ADRj4EIbU1GOmetU4it2w AqvWGHI2t9V4lUGwovERPScpeEzBM+LQ9WwIkkT6/tXQneGcMIZN X-Google-Smtp-Source: AGHT+IGi/NbM51FlOEe2Pawo3vbuZAybzLwZ7Vwvjq0yoFRuhwBaSAwmJ1Ow7OGunZzMsv52su0ceQ== X-Received: by 2002:a05:6358:7e0f:b0:1c3:7d12:708d with SMTP id e5c5f4694b2df-1c3f9e064e0mr90127455d.11.1729887382435; Fri, 25 Oct 2024 13:16:22 -0700 (PDT) Received: from 156.1.168.192.in-addr.arpa (pool-100-37-170-231.nycmny.fios.verizon.net. [100.37.170.231]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-4613237f394sm9124491cf.65.2024.10.25.13.16.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 13:16:21 -0700 (PDT) From: Tamir Duberstein Date: Fri, 25 Oct 2024 16:16:03 -0400 Subject: [PATCH b4 1/5] Add development dependencies Precedence: bulk X-Mailing-List: tools@linux.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241025-better-type-annotations-v1-1-9d7a00a8d754@gmail.com> References: <20241025-better-type-annotations-v1-0-9d7a00a8d754@gmail.com> In-Reply-To: <20241025-better-type-annotations-v1-0-9d7a00a8d754@gmail.com> To: "Kernel.org Tools" Cc: Konstantin Ryabitsev , Tamir Duberstein X-Mailer: b4 0.15-dev Signed-off-by: Tamir Duberstein --- pyproject.toml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 31bfe3033650b2b251fcdcbab0456f4a67e914df..7c65c30efdb95fa40cc1f22933bcd62073db4f26 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,7 +22,13 @@ classifiers = [ "Topic :: Software Development", "Topic :: Utilities", ] -dynamic = ["dependencies", "optional-dependencies"] +dynamic = ["dependencies"] + +[project.optional-dependencies] +dev = [ + "pytest", + "types-requests", +] [tool.setuptools.dynamic] dependencies = { file = ["requirements.in"] } From patchwork Fri Oct 25 20:16:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tamir Duberstein X-Patchwork-Id: 13851508 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0444D139CFA for ; Fri, 25 Oct 2024 20:16:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729887386; cv=none; b=nL/gUlZzDTkPqrROcTjuGsIkvQzMD02+kPS+zk8KAMs/ApKuvlYDOJDZ7pZBSTj4126Pw5K+Tntx4dAMXKemMcpUlJ1CIBMCXGfy3qjIlo/RzxiZfvX/b/1j7ui5BOfmedXV+QHMiP9A13/Sd3cSI3Jnx1EJDvJ17HGIUxINJU4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729887386; c=relaxed/simple; bh=0awfLOppbvGuE+SGvpO55DBynubQv/bhicz7ZPCvabI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mfBhfh9PpbntcPJi5rQIsvVBVDxU9Jm/bSLnOBjeTQQFaaSFVKms5d+DIQ+DKHqhUs+aHE5DdYUoMLBMpDLVMmC2cCar7yeEaY7gUa78x26EVtB9nsRSF8y//DV1TB36AofGGEKPoL0JtRq7EmhG+g6TrUKoBEhdGeqi50C2BbE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=AICoHay4; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AICoHay4" Received: by smtp.kernel.org (Postfix) id 9DAD5C4CECC; Fri, 25 Oct 2024 20:16:25 +0000 (UTC) Received: from mail-ot1-f42.google.com (mail-ot1-f42.google.com [209.85.210.42]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp.kernel.org (Postfix) with ESMTPS id C701BC4CEC3 for ; Fri, 25 Oct 2024 20:16:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 smtp.kernel.org C701BC4CEC3 Authentication-Results: smtp.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ot1-f42.google.com with SMTP id 46e09a7af769-7180a5ba498so1273750a34.2 for ; Fri, 25 Oct 2024 13:16:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729887384; x=1730492184; darn=kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=B4umdQaNw/jPh7Bv7a/9BIO1YLuzyeQcqvgA2Fg0Q7A=; b=AICoHay44FONcs0D0zowZcN/9WTytkqZjkcNMGrkFv7fhO0XO1UFYcDjJpR6jwNlkw UU0v1DD1DZHBokcoplGsoOqqeJR/kT94HNcylLh9xoA3syedSFwjmKUuG05cFr68DvnG EviinqT8OaJjVtJRWwl3kMXsPby3X87dshMpnEHs3vfgqEBxn1N0rej3qS48tmf/v5qo xLetkapdjpuGY6tMB6wzELF14t3393Tc2KAR3lNZTUg8+dppgkM2ix3rBKQjSHvhoN3S h7GeBOrsnIdmyLD44pxFmUuef4F8eTgq9bBzb8a2chTCsz1ipbEBV/Ykhp+WYH3FZQZR DLMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729887384; x=1730492184; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=B4umdQaNw/jPh7Bv7a/9BIO1YLuzyeQcqvgA2Fg0Q7A=; b=TZxPP/F+KXVvNYPNZQlU17DQ6eHHeImt4MgnNdjjJ/kHa8WqD7yaS1alocYZZfOYm8 SuPkUKiwk3M/je7IF1d4U/rmy6Tk1kQ1H+3aZM8loX8cnjlEXbKAZtC9U+jPtMYz4Dkk S3cmQ3mYKn8DEqRYW0fUG0upK4ISK5jdI/1uRVYjmUIwpIFzkyVtZc+j4pAXu/oBvkp6 6TVWBm3Vefvh1lfSOI0NTUwi3x2c0KjZ+dZWFNZM/JHESj8mbvYA8Rzv4SqN9E30G91m eyezmhO3AFi4fIaYIej6QGi7YQvW5yJl5uRKiulTP/7w/ocOHhTTJU2cHY7TI938+cs9 6B5g== X-Gm-Message-State: AOJu0YxpCAF+hQ8L/yiPCtD/7fyXWxlvE3qJngFa6sPQ3ysdA4GjYAKG A27BgCw3GjxPxAr6q66BGU8XmAUjag3UWraHKjjMviP90RZyHi1P X-Google-Smtp-Source: AGHT+IE1Y9nc2eJVaIcQm4mg+9JZexY+pD7mOSs1xvqB6tH/viDJY2LzPCM4qh+y7QIZ8ZNoN9toNA== X-Received: by 2002:a05:6830:264a:b0:713:7415:3c61 with SMTP id 46e09a7af769-718681173ccmr644087a34.9.1729887384037; Fri, 25 Oct 2024 13:16:24 -0700 (PDT) Received: from 156.1.168.192.in-addr.arpa (pool-100-37-170-231.nycmny.fios.verizon.net. [100.37.170.231]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-4613237f394sm9124491cf.65.2024.10.25.13.16.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 13:16:23 -0700 (PDT) From: Tamir Duberstein Date: Fri, 25 Oct 2024 16:16:04 -0400 Subject: [PATCH b4 2/5] Avoid file descriptor leak Precedence: bulk X-Mailing-List: tools@linux.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241025-better-type-annotations-v1-2-9d7a00a8d754@gmail.com> References: <20241025-better-type-annotations-v1-0-9d7a00a8d754@gmail.com> In-Reply-To: <20241025-better-type-annotations-v1-0-9d7a00a8d754@gmail.com> To: "Kernel.org Tools" Cc: Konstantin Ryabitsev , Tamir Duberstein X-Mailer: b4 0.15-dev Signed-off-by: Tamir Duberstein --- src/b4/diff.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/b4/diff.py b/src/b4/diff.py index 63e60f2fc82c95145a897c2dd319283996ed5a8a..743127ef0a1922eace81686e27cd0366f8e42f9c 100644 --- a/src/b4/diff.py +++ b/src/b4/diff.py @@ -174,8 +174,8 @@ def main(cmdargs: argparse.Namespace) -> None: sys.exit(1) if cmdargs.outdiff is not None: logger.info('Writing %s', cmdargs.outdiff) - fh = open(cmdargs.outdiff, 'w') + with open(cmdargs.outdiff, 'w') as fh: + fh.write(rdiff) else: logger.info('---') - fh = sys.stdout - fh.write(rdiff) + sys.stdout.write(rdiff) From patchwork Fri Oct 25 20:16:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tamir Duberstein X-Patchwork-Id: 13851509 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 25EFB18D64C for ; Fri, 25 Oct 2024 20:16:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729887388; cv=none; b=psk61Osn8zDIc3wSVVNwFLppFmMGOE3bGsZ8+3buqHp9ud7ALD1oemWvYfAbcOctqEWeRoVqlhPynOzW5eqMY3y9disahy+Sy3Z6tdlBMTsoE0Sa9J+FIpFCbi6RsBbCYnGsuqWZbWu4tTBLJDlYHMTtkbHqW96eJmbRSsWRd9g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729887388; c=relaxed/simple; bh=UB6+NU0zjWNy22qO17xSh0+R5N6XJGd0dqy7BjoW/jo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=GHD0nMul8duMo6/dlIKAzsKmysa2AVERYXBDcAkb7o1TawbKJ5u6EmlpmsMtu1TTX9pVFEFSS4LYTD1csXNX7aNQz4L2IsaqK148WT8KyPwXRr6kSAeEfk0AIDKg3MwVItp57tMUwuhOh2qXOsnUp+CPnFQAp3hginLP30knzzI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=BXnzrcYB; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BXnzrcYB" Received: by smtp.kernel.org (Postfix) id DCD80C4CEE4; Fri, 25 Oct 2024 20:16:27 +0000 (UTC) Received: from mail-qt1-f182.google.com (mail-qt1-f182.google.com [209.85.160.182]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp.kernel.org (Postfix) with ESMTPS id E876AC4CEC3 for ; Fri, 25 Oct 2024 20:16:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 smtp.kernel.org E876AC4CEC3 Authentication-Results: smtp.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-qt1-f182.google.com with SMTP id d75a77b69052e-4609beb631aso15802501cf.2 for ; Fri, 25 Oct 2024 13:16:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729887386; x=1730492186; darn=kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=/xIC8jetZuQkib4/cH2P0adTxMOjpEaikUwAnzYKLPA=; b=BXnzrcYBrNeOi1rKWLQwmnsB/rO1qeGWXuW2ypxW8mUFx6k2do539usweAUoASdeR+ CtDSyEcnzvE1Tw/ZuxczNStUmdNbOHeiKw3v6IHMAXF6aDK59+8ZmddTSX/ztkc2P8mH 401Lj+gjMu3DZ51juUHfpfSXgm/4SPxiLBdfLV7TLlAEQyqspMhJ4l+u3eVHrWqcLEW3 H1Jge5ifJoRoJteCzMadAzqTDq6j8qx0yhju3bFOfeJLJoxFutJcTOODcQYFxivwtiGq cKBxULIYRykZynwGeAvVJoufKx87a4HtCVYl4i0Sa9HPnqjuzqimhfmp/O4Ym5vyA8MK ssJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729887386; x=1730492186; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/xIC8jetZuQkib4/cH2P0adTxMOjpEaikUwAnzYKLPA=; b=slaHNPvnU1SRfEwCecy9wV6yzlwuPYnu6W2uCxflLIEJyaKXc1iXafJWbMBkqbQ3zX M51dbvP/RSt3cY7zHCsDgOpfHVfgSTRTohXZvvG4ptRzRw8zTnEd/YxRnnHjZ23xNUPu wUuMowEBuO/AZ6Ov3CmDvusoZIAWefxGqU+NRsIL4hIo5GWQgo6YVWCYFaOAoqCQcYxp qFCIBjsDWnZ/7wDCPDImQ8jhXi2RdAe2wIxx3BJT9oagKuxzNPMtsKQrHKCyi83xcDyf uvb8/4nKfJGYYtk/1RXH/43roSvMidTzSPgUJ/Era28rcBMwsc3uqb6rXwsnuZ8L2EpB 8qYQ== X-Gm-Message-State: AOJu0YyQkKUQA3s1SiFs7yQ6qF8PiB2u5WynWpDWysUibem8RAeXrYiX ji06oNGLxRAjldhzLEY0bv8Vj2UPvp90gjQc6tJpeHpEDOj3dFb7jdytkw== X-Google-Smtp-Source: AGHT+IE+Km20S1oOMdLUF5PNPS2Fr+sLaCrrlIGC6k0MwrZrkv8PvXacFQ5LI9D4AenvrMSBRpnEFg== X-Received: by 2002:a05:622a:246:b0:460:913d:cf25 with SMTP id d75a77b69052e-4613c176f5cmr5251061cf.50.1729887385736; Fri, 25 Oct 2024 13:16:25 -0700 (PDT) Received: from 156.1.168.192.in-addr.arpa (pool-100-37-170-231.nycmny.fios.verizon.net. [100.37.170.231]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-4613237f394sm9124491cf.65.2024.10.25.13.16.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 13:16:24 -0700 (PDT) From: Tamir Duberstein Date: Fri, 25 Oct 2024 16:16:05 -0400 Subject: [PATCH b4 3/5] Correctly type annotate generators Precedence: bulk X-Mailing-List: tools@linux.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241025-better-type-annotations-v1-3-9d7a00a8d754@gmail.com> References: <20241025-better-type-annotations-v1-0-9d7a00a8d754@gmail.com> In-Reply-To: <20241025-better-type-annotations-v1-0-9d7a00a8d754@gmail.com> To: "Kernel.org Tools" Cc: Konstantin Ryabitsev , Tamir Duberstein X-Mailer: b4 0.15-dev Signed-off-by: Tamir Duberstein --- src/b4/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/b4/__init__.py b/src/b4/__init__.py index 5115a9cd9b8746f84eb104a2be69fe121724167e..d1f0fc5b56693d7d234bc4aced65166244928728 100644 --- a/src/b4/__init__.py +++ b/src/b4/__init__.py @@ -36,7 +36,7 @@ import requests from pathlib import Path from contextlib import contextmanager -from typing import Optional, Tuple, Set, List, BinaryIO, Union, Sequence, Literal, Iterator, Dict +from typing import Optional, Tuple, Set, List, BinaryIO, Union, Sequence, Literal, Iterator, Dict, overload from email import charset @@ -2758,7 +2758,7 @@ def git_get_repo_status(gitdir: Optional[str] = None, untracked: bool = False) - @contextmanager -def git_temp_worktree(gitdir: Optional[str] = None, commitish: Optional[str] = None) -> Optional[Iterator[Path]]: +def git_temp_worktree(gitdir: Optional[str] = None, commitish: Optional[str] = None) -> Generator[str]: """Context manager that creates a temporary work tree and chdirs into it. The worktree is deleted when the contex manager is closed. Taken from gj_tools.""" dfn = None @@ -2776,7 +2776,7 @@ def git_temp_worktree(gitdir: Optional[str] = None, commitish: Optional[str] = N @contextmanager -def git_temp_clone(gitdir: Optional[str] = None) -> Optional[Iterator[Path]]: +def git_temp_clone(gitdir: Optional[str] = None) -> Generator[str]: """Context manager that creates a temporary shared clone.""" if gitdir is None: topdir = git_get_toplevel() @@ -2794,7 +2794,7 @@ def git_temp_clone(gitdir: Optional[str] = None) -> Optional[Iterator[Path]]: @contextmanager -def in_directory(dirname: str) -> Iterator[bool]: +def in_directory(dirname: str) -> Generator[bool]: """Context manager that chdirs into a directory and restores the original directory when closed. Taken from gj_tools.""" cdir = os.getcwd() From patchwork Fri Oct 25 20:16:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tamir Duberstein X-Patchwork-Id: 13851510 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 14B8920C337 for ; Fri, 25 Oct 2024 20:16:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729887390; cv=none; b=ukLo4nrp6ioaIMTW2ZSvprFI+vXNKO1cixE4PCrIeqJZ23Cw6ZcofGckEcgT8+gP9bE2Efz2wNvQHOuD4aNGQYQypXRF8vWCchMfVL6aiqMVt+OiH31w/AwkItKhLRQp02hbGX+uBrxOpUxtYBTCDbVgsysfkKP+I2wYy3xYMNE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729887390; c=relaxed/simple; bh=kJvsm9GhomDMOHJhodWW1GdnmVBa5bLPi5a48iHuxOA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IPLOnNZVsaJal9dPnYUQdiuTe05u6y9BTUtnziIlZqIyICnYF8YlekaX6D/ZxYMOY7JG7CZ2AeLja2O17Uyww28/0bAoP5rJ2ZAoxiRBtXclTBy21iWspYhKqQpkuV3gWHevCSwJymnV7edLXCrIHEcVOfmP5pkTApTm4JrleZU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=VwGqDl6x; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VwGqDl6x" Received: by smtp.kernel.org (Postfix) id 86587C4CECC; Fri, 25 Oct 2024 20:16:29 +0000 (UTC) Received: from mail-qt1-f179.google.com (mail-qt1-f179.google.com [209.85.160.179]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp.kernel.org (Postfix) with ESMTPS id 7A3C0C4CEE7 for ; Fri, 25 Oct 2024 20:16:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 smtp.kernel.org 7A3C0C4CEE7 Authentication-Results: smtp.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-qt1-f179.google.com with SMTP id d75a77b69052e-460ace055d8so15195071cf.1 for ; Fri, 25 Oct 2024 13:16:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729887387; x=1730492187; darn=kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=wa6y9lNuzG8GTdrhCtWflcNFL1t1dxkimURS0BadncY=; b=VwGqDl6xM/CQXfI6bENJMOcrRBcdnq6vlRI/5V7IimmyZEHG/v5jeb2HrPYsVnK3MU LGMc0As6FSHQLo8/oTnQKYf9Sa4GqzG+B5Tk0ABw1vDPZIjS5vKoaOypZOTjHGHiXSmM aWzT57wJhcWiiYs+NRqlQsvjxkdo68S5ddTiLQw7Pp0PZxcmgaDJ48QpH8p+4XCBU/IT qvLjmTjGNLsx+4geDVZ/zHi99AUxtkCtOC1gNsbL1H0pla6Ih7X/kC6U9cJG8CqJJJeP /veGOCQDYnAxSOzyo8szbvESHahShOyWfCLuSANPkZEUO20LG9dZWPrl4ByfXNDbNCfQ GvfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729887387; x=1730492187; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wa6y9lNuzG8GTdrhCtWflcNFL1t1dxkimURS0BadncY=; b=iyv/Hymxsl2oyUGQloI5/tlZBndjJWU5BgPi9S7PmEcZ8aL9Hv6EP1UEQ9t2gruwPm Aj2UPEEmRgCy6ICogvJMIH/5qgm6T6oiq6HgGs2SKNz+8kn/yb53FR+iWVZ8u9yqu6HK Ber2RYjRXjnPUJyIqvL8vq0Y00g0yuIGO5mfLgN4gCuZJn5uvwaohPBWIlJA9oPePOl7 3sXK1ONWiw16svuqn7hZoxTkkZmOgBa/0c5sVnRkWv3puk9uhqfV6oQxSfWHOvk/C5/b 42qxyl+mR0vUGvDlrsO4GBbG5+rc3HWo5bcqQYHnbJFmW6FY5goA1ZI7lUeXxg5pTSBN leOQ== X-Gm-Message-State: AOJu0YweLwgWiMkzCFu5jVcTxgBsgPX+Ays2N6iP5B8MB43uvC924Z3a yalDDezo2AlINl2R9E/okDpwEQdd3CPz5OQo3eqiKdXEouY4vpZUbbEx2w== X-Google-Smtp-Source: AGHT+IHfYQAbNK0sxhVUedH0/3D2IAADCrMtmmLEBvyaVF64Ig0VU/y0qu/Blv9mkEu4UejY7e6YTA== X-Received: by 2002:a05:622a:1a28:b0:460:ab29:e6b1 with SMTP id d75a77b69052e-4613c184d4bmr5547721cf.44.1729887387144; Fri, 25 Oct 2024 13:16:27 -0700 (PDT) Received: from 156.1.168.192.in-addr.arpa (pool-100-37-170-231.nycmny.fios.verizon.net. [100.37.170.231]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-4613237f394sm9124491cf.65.2024.10.25.13.16.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 13:16:26 -0700 (PDT) From: Tamir Duberstein Date: Fri, 25 Oct 2024 16:16:06 -0400 Subject: [PATCH b4 4/5] Provide overloads for git_run_command Precedence: bulk X-Mailing-List: tools@linux.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241025-better-type-annotations-v1-4-9d7a00a8d754@gmail.com> References: <20241025-better-type-annotations-v1-0-9d7a00a8d754@gmail.com> In-Reply-To: <20241025-better-type-annotations-v1-0-9d7a00a8d754@gmail.com> To: "Kernel.org Tools" Cc: Konstantin Ryabitsev , Tamir Duberstein X-Mailer: b4 0.15-dev This requires explicit use of kwargs to allow decode to be a required parameter in the negative case (which is necessary to disambiguate the overloads). Callers now know for certain whether they get str or bytes. Signed-off-by: Tamir Duberstein --- src/b4/__init__.py | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/src/b4/__init__.py b/src/b4/__init__.py index d1f0fc5b56693d7d234bc4aced65166244928728..e71fbe7d8ea8d4ca19228690ce7c186cc91b81ad 100644 --- a/src/b4/__init__.py +++ b/src/b4/__init__.py @@ -36,7 +36,7 @@ import requests from pathlib import Path from contextlib import contextmanager -from typing import Optional, Tuple, Set, List, BinaryIO, Union, Sequence, Literal, Iterator, Dict, overload +from typing import Optional, Tuple, Set, List, BinaryIO, Union, Sequence, Literal, Iterator, Dict, TypeVar, overload from email import charset @@ -2697,14 +2697,27 @@ def gpg_run_command(args: List[str], stdin: Optional[bytes] = None) -> Tuple[int return _run_command(cmdargs, stdin=stdin) +@overload +def git_run_command(gitdir: Optional[Union[str, Path]], args: List[str], stdin: Optional[bytes] = ..., + *, logstderr: bool = ..., decode: Literal[False], + rundir: Optional[str] = ...) -> Tuple[int, bytes]: + ... + + +@overload +def git_run_command(gitdir: Optional[Union[str, Path]], args: List[str], stdin: Optional[bytes] = ..., + *, logstderr: bool = ..., decode: Literal[True] = ..., + rundir: Optional[str] = ...) -> Tuple[int, str]: + ... + def git_run_command(gitdir: Optional[Union[str, Path]], args: List[str], stdin: Optional[bytes] = None, - logstderr: bool = False, decode: bool = True, + *, logstderr: bool = False, decode: bool = True, rundir: Optional[str] = None) -> Tuple[int, Union[str, bytes]]: cmdargs = ['git', '--no-pager'] if gitdir: if os.path.exists(os.path.join(gitdir, '.git')): gitdir = os.path.join(gitdir, '.git') - cmdargs += ['--git-dir', gitdir] + cmdargs += ['--git-dir', str(gitdir)] # counteract some potential local settings if args[0] == 'log': @@ -2714,16 +2727,18 @@ def git_run_command(gitdir: Optional[Union[str, Path]], args: List[str], stdin: ecode, out, err = _run_command(cmdargs, stdin=stdin, rundir=rundir) - if decode: - out = out.decode(errors='replace') + U = TypeVar('U', str, bytes) + + def _handle(out: U, err: U) -> Tuple[int, Union[str, bytes]]: + if logstderr and len(err.strip()): + logger.debug('Stderr: %s', err) + out += err - if logstderr and len(err.strip()): - if decode: - err = err.decode(errors='replace') - logger.debug('Stderr: %s', err) - out += err + return ecode, out - return ecode, out + if decode: + return _handle(out.decode(errors='replace'), err.decode(errors='replace')) + return _handle(out, err) def git_credential_fill(gitdir: Optional[str], protocol: str, host: str, username: str) -> Optional[str]: From patchwork Fri Oct 25 20:16:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tamir Duberstein X-Patchwork-Id: 13851511 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 198601FB8BF for ; Fri, 25 Oct 2024 20:16:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729887391; cv=none; b=LTzJZIqxDu0SspCFzY9oZPr1FsfMbnjpbEGXIzyL0mBcgcX4UHp1HP9FiaWN+UYS5orZp6oKWrGgID0VQOamkMD8ZdJinPM1RQQ+s+7ZtQawSjcOh+GsfqdSCu6o3UdDEheB6e2+1gfATW7oixqNIWUpuMrRmrvzOCf1TioOCVc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729887391; c=relaxed/simple; bh=ecBBbS2r8kD9WOsPe4beqtgZGSk6w/nGpThSSF4MMpc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZrnJ+8C9DQno0eBMEYNo2y0j9VW8TA8wpNX8WvjvA/5ozgyjKu9NXcchv++fBDFU6mlD8ySvE4eVaTgNYIH1sf9LOrjNlyVOEenmTc2tdQTVhH+6R+TwKAAS4StMuIOQ2lZzx4U5aPQFtAybgMRY4EVpFDUbEMtM9B3Vg7SK394= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=cG9/lV69; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cG9/lV69" Received: by smtp.kernel.org (Postfix) id 0F810C4CECC; Fri, 25 Oct 2024 20:16:31 +0000 (UTC) Received: from mail-qt1-f178.google.com (mail-qt1-f178.google.com [209.85.160.178]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp.kernel.org (Postfix) with ESMTPS id 2040FC4CEC3 for ; Fri, 25 Oct 2024 20:16:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 smtp.kernel.org 2040FC4CEC3 Authentication-Results: smtp.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-qt1-f178.google.com with SMTP id d75a77b69052e-4608da1bea5so19324831cf.1 for ; Fri, 25 Oct 2024 13:16:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729887389; x=1730492189; darn=kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=0L9oFF0+WXBfuPTzvFfgUZLcEhkaBrfpsLlCG+qdW94=; b=cG9/lV69Yb0+zKv6a3CboJwYs4yuFoApD3LD/zUqPCCHa3sg4FioT0ccUTGpEo2zbk fwGJkwb3EzK2hbHgdU5GyV6DQVOf78O6SGT5e7lthrVGq+s+knIMZwf32hi6rF71r2N3 h8ffpgkg4pMh2dIhu35xbW8jZobEZfH5jRel8QoIpwJjoqWYBSXXpfTeruvmf1Ea7RFm ata5Nbezy/DUiossz4Ge88NpE9CoRkiImH5UZv49yIR0YQb9XJdlEzjcVx9pJ1TnVeOz hWavu/xCIxxsIbjngZomoIFgiaBEt7MsJaD5ncynlAvvd1BfNo20S/eiELwyYnMTumQn l8WA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729887389; x=1730492189; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0L9oFF0+WXBfuPTzvFfgUZLcEhkaBrfpsLlCG+qdW94=; b=vq9or5/45haC0+XRtzS1+UDxzVbboIoFn108Hmcbf/YqZbGLWpqCTA9j548TZCfrM4 KU84xXDTiTSHUIlSzK6WnJ3Dhdq+Kh9GJ3KyP7GZpLCMbfvjE1Gx1g71bbQpNEKqwmo0 k665R7U4GSLJMinYDh0+9oAJfMAFMKYfIHcwU1oGwHsWU3/evyOvhaOGQXzgSW8TpAMX ImCwMEiyYM+SrsoHHxRTOzD/wqAkBYlx6AZNzbXafT+KOnkb5Pym+S+Gfqjm6K7WC8lC lBRrfy1S6yELJI7FdlzfSeSpwoKQYTOxmZGTWxp34IPz7R8fdNqARdBgCQYOKawuK90x iUZg== X-Gm-Message-State: AOJu0YwlNwjSZ41rMn65MvXIK1KaGGoEC8KbO6YXQFgmbguCjUV8Rk8f nBujeMLqqi3+BmdSQKE5esKFFHlIr6ccg86ocUxQwu9HMWcF8EAY X-Google-Smtp-Source: AGHT+IHZaa/L731PsAy+B6UmX/9ytg4gKoKYThDuN2FiVTIMWGe88QjRwJ8ZVZs2fb+KVNNrG1uDAg== X-Received: by 2002:a05:622a:15cf:b0:45d:9357:1cca with SMTP id d75a77b69052e-4613c00ed2bmr5978421cf.14.1729887389035; Fri, 25 Oct 2024 13:16:29 -0700 (PDT) Received: from 156.1.168.192.in-addr.arpa (pool-100-37-170-231.nycmny.fios.verizon.net. [100.37.170.231]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-4613237f394sm9124491cf.65.2024.10.25.13.16.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 13:16:27 -0700 (PDT) From: Tamir Duberstein Date: Fri, 25 Oct 2024 16:16:07 -0400 Subject: [PATCH b4 5/5] Add missing imports Precedence: bulk X-Mailing-List: tools@linux.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241025-better-type-annotations-v1-5-9d7a00a8d754@gmail.com> References: <20241025-better-type-annotations-v1-0-9d7a00a8d754@gmail.com> In-Reply-To: <20241025-better-type-annotations-v1-0-9d7a00a8d754@gmail.com> To: "Kernel.org Tools" Cc: Konstantin Ryabitsev , Tamir Duberstein X-Mailer: b4 0.15-dev Signed-off-by: Tamir Duberstein --- src/b4/__init__.py | 9 +++++---- src/b4/diff.py | 1 + src/b4/ez.py | 2 ++ src/b4/pr.py | 2 ++ src/b4/ty.py | 1 + src/tests/test___init__.py | 1 + 6 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/b4/__init__.py b/src/b4/__init__.py index e71fbe7d8ea8d4ca19228690ce7c186cc91b81ad..7b1925da93e1b3feadf669cc188ab6fb030f67f4 100644 --- a/src/b4/__init__.py +++ b/src/b4/__init__.py @@ -8,12 +8,13 @@ import sys import gzip import os import fnmatch -import email.utils -import email.policy -import email.parser -import email.header import email.generator +import email.header +import email.message +import email.parser +import email.policy import email.quoprimime +import email.utils import tempfile import pathlib import argparse diff --git a/src/b4/diff.py b/src/b4/diff.py index 743127ef0a1922eace81686e27cd0366f8e42f9c..1de3063ea0b3c73e4e3d8bfd4ec91b4c6f90cce6 100644 --- a/src/b4/diff.py +++ b/src/b4/diff.py @@ -11,6 +11,7 @@ import b4 import b4.mbox import mailbox import email +import email.message import email.parser import shutil import pathlib diff --git a/src/b4/ez.py b/src/b4/ez.py index 970631592d2139b12ee4a6a9a112081eee1de721..9494b005a4f47a7be9cb053cc6075dede29d4cb0 100644 --- a/src/b4/ez.py +++ b/src/b4/ez.py @@ -17,6 +17,8 @@ import datetime import json import shlex import email +import email.policy +import email.utils import pathlib import base64 import textwrap diff --git a/src/b4/pr.py b/src/b4/pr.py index b6eb5d3933d7e0bb1224877f071bb19facd8dbd8..60f46f1e3fa96a52a9d667bffb43c2a75b89cc4e 100644 --- a/src/b4/pr.py +++ b/src/b4/pr.py @@ -13,7 +13,9 @@ import b4 import re import json import email +import email.message import email.parser +import email.utils import argparse import urllib.parse diff --git a/src/b4/ty.py b/src/b4/ty.py index e1afb61280d2161a054d40ae78df0d4b33dbb41d..021588ff9e559cfd8aa7c6818cdeba750931e8f6 100644 --- a/src/b4/ty.py +++ b/src/b4/ty.py @@ -13,6 +13,7 @@ import re import email import email.message import email.policy +import email.utils import json import argparse diff --git a/src/tests/test___init__.py b/src/tests/test___init__.py index 297e5120a8c8adf241660f06e9a83c1ff4a0fd3a..3e01c2f5e127cd1123d0fb8503493e396148ee73 100644 --- a/src/tests/test___init__.py +++ b/src/tests/test___init__.py @@ -35,6 +35,7 @@ def test_save_git_am_mbox(sampledir, tmp_path, source, regex, flags, ismbox): msgs = list(mbx) else: import email + import email.parser with open(f'{sampledir}/{source}.txt', 'rb') as fh: msg = email.parser.BytesParser(policy=b4.emlpolicy, _class=email.message.EmailMessage).parse(fh) msgs = [msg]