From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id QKCGLyGvDWIqbQAAgWs5BA (envelope-from ) for ; Thu, 17 Feb 2022 03:12:49 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id UNXpLCGvDWIrgQEA9RJhRA (envelope-from ) for ; Thu, 17 Feb 2022 03:12:49 +0100 Received: from mail.notmuchmail.org (yantan.tethera.net [IPv6:2a01:4f9:c011:7a79::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 5CEDFB366 for ; Thu, 17 Feb 2022 03:12:49 +0100 (CET) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 8CD115F709; Thu, 17 Feb 2022 02:12:47 +0000 (UTC) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by mail.notmuchmail.org (Postfix) with ESMTP id 161435F5E3 for ; Thu, 17 Feb 2022 02:08:42 +0000 (UTC) Received: by fethera.tethera.net (Postfix, from userid 1001) id 72DCB5FBD2; Wed, 16 Feb 2022 21:08:41 -0500 (EST) Received: (nullmailer pid 181057 invoked by uid 1000); Thu, 17 Feb 2022 02:08:39 -0000 From: David Bremner To: Floris Bruynooghe , David Bremner , notmuch@notmuchmail.org Subject: Date: Wed, 16 Feb 2022 22:08:33 -0400 Message-Id: <20220217020835.180940-1-david@tethera.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <8735kipm9j.fsf@powell.devork.be> References: <8735kipm9j.fsf@powell.devork.be> MIME-Version: 1.0 X-MailFrom: bremner@tethera.net X-Mailman-Rule-Hits: no-subject X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; digests; suspicious-header Message-ID-Hash: L3T6FS7AWVL54THC6KDMF3QBY4IPJ4T6 X-Message-ID-Hash: L3T6FS7AWVL54THC6KDMF3QBY4IPJ4T6 X-Mailman-Approved-At: Thu, 17 Feb 2022 02:12:46 +0000 X-Mailman-Version: 3.3.3 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN X-Migadu-Country: DE ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1645063969; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-owner:list-unsubscribe:list-subscribe:list-post; bh=mWJ82gDZ6XGQz9/OmorN3b4PqBODAWICkctkT2BxBXM=; b=AIlZiM3coBpVCC3s5uHX05mvPNMC4+HScuroNBPqLm0D673C6UtPLuXIiIV1iK4TcIgs0V LAZj7FHIiqtDMgbRQC8wpdX1Hxgyr5adOUeHyJ4pFPvWWfB/Jpu6aROOGm7OYCG8SbM4KH e9i2gUxo7M/A3MgGY8szvFpl/kNxIISvK4tXG0SlN+IjIOyxP20eXNWPjz/MF3Vr35yr7b GOdF3ynfRak03zK54W9gmKJfLkVIET/+gVVDkJ40ckrVc1Isvg3gMzPqSoVJ//5ZcDv81e tCJ7PmFXLKyU2C5kTKsZv3r4Fq0a18FnjXZwS43u00FvIBJAyqAgP2dwaa8c5w== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1645063969; a=rsa-sha256; cv=none; b=aaP8Vucfoz9rt9yjWytqQGXD89XWi4n2qYpwuZMnPoUkD3f0x3QwjX2ZgY2tBjWsRzcpIi bwd3/YNkPfBdnUB847OCnqT/1xKY6tT8YOMqc69y1ZdAslowUOSDLTEusjZ6+iX8538mAy VE/rJWk+XGdr9rCYuuAzU1qm0YPPwQJWXS3mj/HnLKn68P73AgTkScataL9ldL9kkwkBFY qq7MGKFtnVI6fjvhMU5Nwlci29sXPzFhCULSe3BoMxeuQYnim6ouBuCymivYzhJHBVzUKc HmlnVLrw99fIYAfWUToUwROKUXxT8yqR8y9HfsRH9orE8qdKQrBQZRdS7Qx9aw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2a01:4f9:c011:7a79::1 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -0.85 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2a01:4f9:c011:7a79::1 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 5CEDFB366 X-Spam-Score: -0.85 X-Migadu-Scanner: scn0.migadu.com X-TUID: bZccTUGTwEi5 Floris wrote: > FWIW having spaces between the function name and parentheses is rather >uncommon for python style. Though of course complaining about style >without using an auto-formatter is pretty meh these days :) > Yeah fair enough, it's the default in the C code, but we pretty clearly have different styles going on in different languages. >> + val_p = capi.lib.notmuch_config_pairs_value (super()._iter_p) >> + key_p = capi.lib.notmuch_config_pairs_key (super()._iter_p) >> + key = base.BinString.from_cffi(key_p) > >does key_p need a NULL check first or can it never be NULL? I think it can never be NULL, but if it is, better to raise an exception I think. >> def test_iter(self, db): >> - assert list(db.config) == [] >> - db.config['spam'] = 'ham' >> - db.config['eggs'] = 'bacon' >> - assert set(db.config) == {'spam', 'eggs'} >> - assert set(db.config.keys()) == {'spam', 'eggs'} >> - assert set(db.config.values()) == {'ham', 'bacon'} >> - assert set(db.config.items()) == {('spam', 'ham'), ('eggs', 'bacon')} >> + import re >> + prefix = re.compile(r"^TEST[.]") >> + assert [ x for x in list(db.config) if prefix.match(x) ] == [] > >`x.startswith('TEST.')` is probably lighter weight here, maybe easier to >read too that's subjective i guess > >You can even try something like this to further make it more readable: > >has_prefix = lambda x: x.startswith('TEST.') I did variation on this, defining an inner function instead of using a lambda. > >> + db.config['TEST.spam'] = 'TEST.ham' >> + db.config['TEST.eggs'] = 'TEST.bacon' >> + assert { x for x in set(db.config) if prefix.match(x) } == {'TEST.spam', 'TEST.eggs'} >> + assert { x for x in set(db.config.keys()) if prefix.match (x) } == {'TEST.spam', 'TEST.eggs'} > >I'm not sure why you need to wrap `db.config.keys()` in `set()`? This >explicitly creates a set out of things before turning it back into an >interator while you're fine with the original iterator I think? Good question. That seems to apply to list(db.config) above also?