[PATCH 2/2] python: annotate all calls into libnotmuch with types
[notmuch-archives.git] / ab / b8eb6f1aea7ac9fd054b4f597a32046c9dba61
1 Return-Path: <Sebastian@SSpaeth.de>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id DE9EA431FD0\r
6         for <notmuch@notmuchmail.org>; Thu, 29 Sep 2011 09:06:47 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.1\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.1 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         RCVD_IN_DNSWL_NONE=-0.0001] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id JP2AvSU86yiM for <notmuch@notmuchmail.org>;\r
17         Thu, 29 Sep 2011 09:06:47 -0700 (PDT)\r
18 Received: from homiemail-a23.g.dreamhost.com (caiajhbdcaib.dreamhost.com\r
19         [208.97.132.81])\r
20         by olra.theworths.org (Postfix) with ESMTP id 27ABD431FB6\r
21         for <notmuch@notmuchmail.org>; Thu, 29 Sep 2011 09:06:47 -0700 (PDT)\r
22 Received: from homiemail-a23.g.dreamhost.com (localhost [127.0.0.1])\r
23         by homiemail-a23.g.dreamhost.com (Postfix) with ESMTP id 42BED4B0091\r
24         for <notmuch@notmuchmail.org>; Thu, 29 Sep 2011 09:06:46 -0700 (PDT)\r
25 DomainKey-Signature: a=rsa-sha1; c=nofws; d=SSpaeth.de; h=from:to:subject\r
26         :date:message-id:mime-version:content-type; q=dns; s=sspaeth.de;\r
27         b=ODT/HFg+ysVXlPeA/yiL+TcTHbqr2o6lnGXaSbVqLOTiGIlAKVU/eKWauX52i\r
28         wwHo8M31fIRGHyAg0L39agpKHx/VKg35rxI7qr4bhezZfAX3HhmFVaEcXQ18iVbY\r
29         1qMzEcoZaW3lXhZzLsmjCpY8MhamKv98SOoEqHwwCWuZtA=\r
30 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=SSpaeth.de; h=from:to\r
31         :subject:date:message-id:mime-version:content-type; s=sspaeth.de\r
32         ; bh=dwhRoTeTwswrlh48kIj4pKxEOMk=; b=A4SJPwzwByqYI8CKhQQh0qDnAC7\r
33         rvON6u1pYgi1bDFetml1l7kBgt7AZjP2C2g4Hp/o1SsXr5xje+VpmlF0aLopbRpR\r
34         NippLLUUpFS/OUrY9Nu0SHQyBlDYtxfyJTMKbHQHmoMYHEbgiBG6xDCefNneJuQf\r
35         4VkilMKSmplUq+0A=\r
36 Received: from spaetzbook.sspaeth.de (unknown [84.55.203.213])\r
37         (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))\r
38         (No client certificate requested)\r
39         (Authenticated sender: fax@sspaeth.de)\r
40         by homiemail-a23.g.dreamhost.com (Postfix) with ESMTPSA id 74C5A4B008F\r
41         for <notmuch@notmuchmail.org>; Thu, 29 Sep 2011 09:06:44 -0700 (PDT)\r
42 Received: by spaetzbook.sspaeth.de (sSMTP sendmail emulation);\r
43         Thu, 29 Sep 2011 18:06:42 +0200\r
44 From: Sebastian Spaeth <Sebastian@SSpaeth.de>\r
45 To: Notmuch developer list <notmuch@notmuchmail.org>\r
46 Subject: [Justus Winter] Re: [PATCH 1/9] python: add a .gitignore file and\r
47         refine the toplevel one\r
48 User-Agent: Notmuch/0.7-19-gee4579a (http://notmuchmail.org) Emacs/23.2.1\r
49         (x86_64-pc-linux-gnu)\r
50 Date: Thu, 29 Sep 2011 18:06:42 +0200\r
51 Message-ID: <87r52z49kd.fsf@SSpaeth.de>\r
52 MIME-Version: 1.0\r
53 Content-Type: multipart/mixed; boundary="=-=-="\r
54 X-BeenThere: notmuch@notmuchmail.org\r
55 X-Mailman-Version: 2.1.13\r
56 Precedence: list\r
57 List-Id: "Use and development of the notmuch mail system."\r
58         <notmuch.notmuchmail.org>\r
59 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
60         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
61 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
62 List-Post: <mailto:notmuch@notmuchmail.org>\r
63 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
64 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
65         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
66 X-List-Received-Date: Thu, 29 Sep 2011 16:06:48 -0000\r
67 \r
68 --=-=-=\r
69 \r
70 Here goes Justus's reply which he accidentally sent to me only.\r
71 \r
72 \r
73 --=-=-=\r
74 Content-Type: message/rfc822\r
75 Content-Disposition: inline\r
76 \r
77 Return-Path: <teythoon@jade-hamburg.de>\r
78 X-Original-To: Sebastian@SSpaeth.de\r
79 Delivered-To: sebastian--sspaeth.de@homiemail-mx7.g.dreamhost.com\r
80 Received: from diehard.dreamhost.com (caiajhbdcaib.dreamhost.com\r
81  [208.97.132.81])       by homiemail-mx7.g.dreamhost.com (Postfix) with ESMTP id\r
82  B9CF2CF6CD     for <Sebastian@SSpaeth.de>; Thu, 29 Sep 2011 03:37:59 -0700 (PDT)\r
83 Received: from localhost (localhost [127.0.0.1])\r
84         by diehard.dreamhost.com (Postfix) with ESMTP id B5BEF17BC062\r
85         for <Sebastian@SSpaeth.de>; Thu, 29 Sep 2011 03:37:59 -0700 (PDT)\r
86 X-DH-Virus-Scanned: Debian amavisd-new at diehard.dreamhost.com\r
87 X-Spam-Flag: NO\r
88 X-Spam-Score: 1.1\r
89 X-Spam-Level: *\r
90 X-Spam-Status: No, score=1.1 tagged_above=-999 required=3\r
91         tests=[SUBJECT_FUZZY_TION=1.1] autolearn=disabled\r
92 Received: from godfather.dreamhost.com ([208.97.132.5]) by localhost\r
93  (diehard.dreamhost.com [208.97.132.157]) (amavisd-new, port 10024)     with ESMTP\r
94  id 0B1H6zbuimbD for <Sebastian@SSpaeth.de>;    Thu, 29 Sep 2011 03:37:59 -0700\r
95  (PDT)\r
96 Received: from mail.cryptobitch.de (cryptobitch.de [88.198.7.68])\r
97         by godfather.dreamhost.com (Postfix) with ESMTP id 951FC1B0014\r
98         for <Sebastian@SSpaeth.de>; Thu, 29 Sep 2011 03:37:44 -0700 (PDT)\r
99 Received: from mail.jade-hamburg.de (unknown [85.183.11.228])\r
100         (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))\r
101         (No client certificate requested)\r
102         by mail.cryptobitch.de (Postfix) with ESMTPSA id 6F34F505C8B\r
103         for <Sebastian@SSpaeth.de>; Thu, 29 Sep 2011 12:37:57 +0200 (CEST)\r
104 Received: by mail.jade-hamburg.de (Postfix, from userid 401)\r
105         id C0CA5DF2A0; Thu, 29 Sep 2011 12:37:56 +0200 (CEST)\r
106 Received: from thinkbox.jade-hamburg.de (unknown [85.183.11.228])\r
107         (using TLSv1 with cipher AES256-SHA (256/256 bits))\r
108         (No client certificate requested)\r
109         (Authenticated sender: teythoon)\r
110         by mail.jade-hamburg.de (Postfix) with ESMTPSA id B6AB6DF28B\r
111         for <Sebastian@SSpaeth.de>; Thu, 29 Sep 2011 12:37:55 +0200 (CEST)\r
112 Received: from teythoon by thinkbox.jade-hamburg.de with local (Exim 4.76)\r
113         (envelope-from <teythoon@thinkbox.jade-hamburg.de>)\r
114         id 1R9E01-0005VB-5e\r
115         for Sebastian@SSpaeth.de; Thu, 29 Sep 2011 12:37:53 +0200\r
116 In-Reply-To: <871uuzlrkt.fsf@SSpaeth.de>\r
117 References:\r
118  <1316999137-28257-1-git-send-email-4winter@informatik.uni-hamburg.de>\r
119  <871uuzlrkt.fsf@SSpaeth.de>\r
120 Subject: Re: [PATCH 1/9] python: add a .gitignore file and refine the toplevel\r
121  one\r
122 To: Sebastian Spaeth <Sebastian@SSpaeth.de>\r
123 From: Justus Winter <4winter@informatik.uni-hamburg.de>\r
124 Date: Thu, 29 Sep 2011 12:37:53 +0200\r
125 Message-Id: <E1R9E01-0005VB-5e@thinkbox.jade-hamburg.de>\r
126 MIME-Version: 1.0\r
127 Content-Type: multipart/mixed; boundary="===-=-="\r
128 \r
129 --===-=-=\r
130 Content-Type: text/plain; charset=utf-8\r
131 \r
132 \r
133 Hey Sebastian,\r
134 \r
135 Quoting Sebastian Spaeth (2011-09-29 09:45:38)\r
136 >On Mon, 26 Sep 2011 03:05:29 +0200, Justus Winter wrote:\r
137 >\r
138 >#1) APPLIED\r
139 >#2) APPLIED\r
140 >#4) APPLIED\r
141 >#5&#6) APPLIED\r
142 >#9) APPLIED\r
143 >Thanks for the patches, most of them are quite nice. For 7&8, I'd like\r
144 >to hear more opinions.\r
145 \r
146 Thanks :)\r
147 \r
148 >#3) reorder the arguments of NotmuchError.__init__(): NOT APPLIED\r
149 >\r
150 >The python tutorial gives an example of custom TransitionError with\r
151 >three arguments, a custom message as the third. In addition, a STATUS\r
152 >value is always expected to be given, while the additional explanatory\r
153 >msg is optional, so STATUS makes for a more logical 1st parameter IMHO.\r
154 >Even if it were the case, it makes for lots of code churn, longer code\r
155 >(status=foo) to all Exceptions, and existing third party code would be\r
156 >broken. Overall, I think there is more potential for trouble than\r
157 >cleanup.\r
158 \r
159 Well, #3 wasn't meant to be used standalone, I just wanted an intermediate\r
160 step in the refactoring process.\r
161 \r
162 To address your concern wrt status being optional: I do consider code\r
163 doing 'raise NotmuchError(status=...)' to be wrong, one should raise\r
164 a more specific error in the first case.\r
165 \r
166 >#7) NOT APPLIED, INPUT SOUGHT :)\r
167 >I do see the value of more fine grained exceptions, but I am not sure,\r
168 >we need this level of fine-grainedness. It would also make things more\r
169 >tricky (the API is still actively evolving, and e.g. 4 days ago, a new\r
170 >error status was added), so users of the bindings would now have\r
171 > +    NotmuchError,\r
172 > +    OutOfMemoryError,\r
173 > +    ReadOnlyDatabaseError,\r
174 > +    XapianError,\r
175 > +    FileError,\r
176 > +    FileNotEmailError,\r
177 > +    DuplicateMessageIdError,\r
178 > +    NullPointerError,\r
179 > +    TagTooLongError,\r
180 > +    UnbalancedFreezeThawError,\r
181 > +    UnbalancedAtomicError,\r
182 > +    NotInitializedError\r
183 >\r
184 > [...]\r
185 >\r
186 >to check where e.g. Xapian could also hide an Out of Memory.\r
187 Well, if the underlying API changes, the bindings will have to be\r
188 updated as well. What's wrong with that?\r
189 \r
190 > Do people\r
191 >really want to catch, say UnbalancedAtomic errors specifically, rather\r
192 >than testing whether an operation succeeded, and check the status code\r
193 >if not? I could see the case for NotInitializedError, as that is a bit\r
194 >specific to the python bindings and users might want to catch it separately.\r
195 \r
196 Well, those not interested in the exact nature of the failure can\r
197 still except NotmuchError as before. I also added the status code to\r
198 each class so that legacy style exception handling won't break.\r
199 \r
200 (On second thought, we could also provide a .args property that issues\r
201 a deprecation warning when used to make the transition  even smoother.)\r
202 \r
203 >Also, not all "status" are an error, e.g. DuplicateMessageId denotes\r
204 >success rather than failure, it just communicates a status.\r
205 Hm, I didn't knew that. This feels somewhat strange though.\r
206 \r
207 If I were to design an API that uses an integer to indicate both\r
208 success and error, I'd reserve one bit indicating error so testing\r
209 for errors can be easily done by anding with a bitmask.\r
210 \r
211 Cheers,\r
212 Justus\r
213 --===-=-=\r
214 Content-Type: application/octet-stream\r
215 Content-Disposition: attachment; filename=.signature\r
216 Content-Transfer-Encoding: base64\r
217 \r
218 bG92ZSB1IGFsb3QgQCxACgo=\r
219 --===-=-=--\r
220 \r
221 --=-=-=\r
222 Content-Type: multipart/signed; boundary="===-=-=";\r
223         micalg=pgp-sha1; protocol="application/pgp-signature"\r
224 \r
225 --===-=-=\r
226 \r
227 \r
228 --===-=-=\r
229 Content-Type: application/pgp-signature\r
230 \r
231 -----BEGIN PGP SIGNATURE-----\r
232 Version: GnuPG v1.4.11 (GNU/Linux)\r
233 \r
234 iEUEARECAAYFAk6El5IACgkQVYX1jMgnoGJFygCY/edvrzAuYWYK0cuZBtacEtHX\r
235 LQCgha7pei3FoAc7FxAR0Uf3iiu8/U0=\r
236 =xsCn\r
237 -----END PGP SIGNATURE-----\r
238 --===-=-=--\r
239 \r
240 --=-=-=--\r