From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id uG3/NK8EuF9gPgAA0tVLHw (envelope-from ) for ; Fri, 20 Nov 2020 18:02:23 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id eA74MK8EuF8gGwAAbx9fmQ (envelope-from ) for ; Fri, 20 Nov 2020 18:02:23 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [144.217.243.247]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (2048 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id DE9879404C7 for ; Fri, 20 Nov 2020 18:02:20 +0000 (UTC) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 5E3FA28C64; Fri, 20 Nov 2020 13:02:12 -0500 (EST) Received: from fethera.tethera.net (fethera.tethera.net [IPv6:2607:5300:60:c5::1]) by mail.notmuchmail.org (Postfix) with ESMTP id 86FA62710B for ; Fri, 20 Nov 2020 13:02:10 -0500 (EST) Received: by fethera.tethera.net (Postfix, from userid 1001) id 3BE2C5FB8B; Fri, 20 Nov 2020 13:02:08 -0500 (EST) Received: (nullmailer pid 332355 invoked by uid 1000); Fri, 20 Nov 2020 18:02:06 -0000 From: David Bremner To: "Jorge P. de Morais Neto" , notmuch@notmuchmail.org Cc: Floris Bruynooghe Subject: Re: New Python bindings (notmuch2 module) fail to exclude tags In-Reply-To: <87r1oohvm0.fsf@disroot.org> References: <87r1oohvm0.fsf@disroot.org> X-List-To: notmuch Date: Fri, 20 Nov 2020 14:02:06 -0400 Message-ID: <87k0ufykip.fsf@tethera.net> MIME-Version: 1.0 Message-ID-Hash: EKISOOWESJILC2P3QOSTE42ZB3ZOL7N6 X-Message-ID-Hash: EKISOOWESJILC2P3QOSTE42ZB3ZOL7N6 X-MailFrom: david@tethera.net 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; no-subject; suspicious-header X-Mailman-Version: 3.2.1 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Scanner: ns3122888.ip-94-23-21.eu Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Spam-Score: -1.01 X-TUID: KP4rMzizMWoU "Jorge P. de Morais Neto" writes: > Hi. I am trying to migrate my Python3 script to the new Python bindings > (notmuch2 module). However, I cannot obtain a count of messages > matching a query excluding messages that have an exclude tag. From the > command line: > $ notmuch count 'is:.bf_spam' > 0 > > The CLI command correctly counts zero messages having '.bf_spam' tag, > because all such messages also have the excluded 'spam' tag. But from > Python: > > $ python3 > Python 3.7.3 (default, Jul 25 2020, 13:03:44) > [GCC 8.3.0] on linux > Type "help", "copyright", "credits" or "license" for more information. >>>> import notmuch2 >>>> nm_db=notmuch2.Database() >>>> nm_db.count_messages('is:.bf_spam', exclude_tags=('spam',)) > 379 >>>> nm_db.count_messages('is:.bf_spam', exclude_tags=('spam',), omit_excluded=nm_db.EXCLUDE.FALSE) > 379 >>>> nm_db.count_messages('is:.bf_spam', exclude_tags=('spam',), omit_excluded=nm_db.EXCLUDE.TRUE) > 379 >>>> nm_db.count_messages('is:.bf_spam', exclude_tags=('spam',), omit_excluded=nm_db.EXCLUDE.ALL) > 379 >>>> nm_db.count_messages('is:.bf_spam', exclude_tags=('spam',), omit_excluded=nm_db.EXCLUDE.FLAG) > 379 > It looks like a bug, but I'm not very expert with the python bindings, so I've CCed the author of the new bindings. It would be great if you could make a small test case that does not rely on your mail store. d