##// END OF EJS Templates
tests/filterpyflakes: use absolute_import
Gregory Szorc -
r27285:aef5b606 default
parent child Browse files
Show More
@@ -1,58 +1,61 b''
1 1 #!/usr/bin/env python
2 2
3 3 # Filter output by pyflakes to control which warnings we check
4 4
5 import sys, re
5 from __future__ import absolute_import
6
7 import re
8 import sys
6 9
7 10 def makekey(typeandline):
8 11 """
9 12 for sorting lines by: msgtype, path/to/file, lineno, message
10 13
11 14 typeandline is a sequence of a message type and the entire message line
12 15 the message line format is path/to/file:line: message
13 16
14 17 >>> makekey((3, 'example.py:36: any message'))
15 18 (3, 'example.py', 36, ' any message')
16 19 >>> makekey((7, 'path/to/file.py:68: dummy message'))
17 20 (7, 'path/to/file.py', 68, ' dummy message')
18 21 >>> makekey((2, 'fn:88: m')) > makekey((2, 'fn:9: m'))
19 22 True
20 23 """
21 24
22 25 msgtype, line = typeandline
23 26 fname, line, message = line.split(":", 2)
24 27 # line as int for ordering 9 before 88
25 28 return msgtype, fname, int(line), message
26 29
27 30
28 31 lines = []
29 32 for line in sys.stdin:
30 33 # We whitelist tests (see more messages in pyflakes.messages)
31 34 pats = [
32 35 (r"imported but unused", None),
33 36 (r"local variable '.*' is assigned to but never used", None),
34 37 (r"unable to detect undefined names", None),
35 38 (r"undefined name '.*'",
36 39 r"undefined name '(WindowsError|memoryview)'")
37 40 ]
38 41
39 42 for msgtype, (pat, excl) in enumerate(pats):
40 43 if re.search(pat, line) and (not excl or not re.search(excl, line)):
41 44 break # pattern matches
42 45 else:
43 46 continue # no pattern matched, next line
44 47 fn = line.split(':', 1)[0]
45 48 f = open(fn)
46 49 data = f.read()
47 50 f.close()
48 51 if 'no-' 'check-code' in data:
49 52 continue
50 53 lines.append((msgtype, line))
51 54
52 55 for msgtype, line in sorted(lines, key=makekey):
53 56 sys.stdout.write(line)
54 57 print
55 58
56 59 # self test of "undefined name" detection for other than 'memoryview'
57 60 if False:
58 61 print undefinedname
@@ -1,232 +1,231 b''
1 1 #require test-repo
2 2
3 3 $ cd "$TESTDIR"/..
4 4
5 5 $ hg files 'set:(**.py)' | xargs python contrib/check-py3-compat.py
6 6 contrib/casesmash.py not using absolute_import
7 7 contrib/check-code.py not using absolute_import
8 8 contrib/check-code.py requires print_function
9 9 contrib/check-config.py not using absolute_import
10 10 contrib/check-config.py requires print_function
11 11 contrib/debugcmdserver.py not using absolute_import
12 12 contrib/debugcmdserver.py requires print_function
13 13 contrib/debugshell.py not using absolute_import
14 14 contrib/fixpax.py not using absolute_import
15 15 contrib/fixpax.py requires print_function
16 16 contrib/hgclient.py not using absolute_import
17 17 contrib/hgclient.py requires print_function
18 18 contrib/hgfixes/__init__.py not using absolute_import
19 19 contrib/hgfixes/fix_bytes.py not using absolute_import
20 20 contrib/hgfixes/fix_bytesmod.py not using absolute_import
21 21 contrib/hgfixes/fix_leftover_imports.py not using absolute_import
22 22 contrib/import-checker.py not using absolute_import
23 23 contrib/import-checker.py requires print_function
24 24 contrib/memory.py not using absolute_import
25 25 contrib/perf.py not using absolute_import
26 26 contrib/python-hook-examples.py not using absolute_import
27 27 contrib/revsetbenchmarks.py not using absolute_import
28 28 contrib/revsetbenchmarks.py requires print_function
29 29 contrib/showstack.py not using absolute_import
30 30 contrib/synthrepo.py not using absolute_import
31 31 contrib/win32/hgwebdir_wsgi.py not using absolute_import
32 32 doc/check-seclevel.py not using absolute_import
33 33 doc/gendoc.py not using absolute_import
34 34 doc/hgmanpage.py not using absolute_import
35 35 hgext/__init__.py not using absolute_import
36 36 hgext/acl.py not using absolute_import
37 37 hgext/blackbox.py not using absolute_import
38 38 hgext/bugzilla.py not using absolute_import
39 39 hgext/censor.py not using absolute_import
40 40 hgext/children.py not using absolute_import
41 41 hgext/churn.py not using absolute_import
42 42 hgext/clonebundles.py not using absolute_import
43 43 hgext/color.py not using absolute_import
44 44 hgext/convert/__init__.py not using absolute_import
45 45 hgext/convert/bzr.py not using absolute_import
46 46 hgext/convert/common.py not using absolute_import
47 47 hgext/convert/convcmd.py not using absolute_import
48 48 hgext/convert/cvs.py not using absolute_import
49 49 hgext/convert/cvsps.py not using absolute_import
50 50 hgext/convert/darcs.py not using absolute_import
51 51 hgext/convert/filemap.py not using absolute_import
52 52 hgext/convert/git.py not using absolute_import
53 53 hgext/convert/gnuarch.py not using absolute_import
54 54 hgext/convert/hg.py not using absolute_import
55 55 hgext/convert/monotone.py not using absolute_import
56 56 hgext/convert/p4.py not using absolute_import
57 57 hgext/convert/subversion.py not using absolute_import
58 58 hgext/convert/transport.py not using absolute_import
59 59 hgext/eol.py not using absolute_import
60 60 hgext/extdiff.py not using absolute_import
61 61 hgext/factotum.py not using absolute_import
62 62 hgext/fetch.py not using absolute_import
63 63 hgext/gpg.py not using absolute_import
64 64 hgext/graphlog.py not using absolute_import
65 65 hgext/hgcia.py not using absolute_import
66 66 hgext/hgk.py not using absolute_import
67 67 hgext/highlight/__init__.py not using absolute_import
68 68 hgext/highlight/highlight.py not using absolute_import
69 69 hgext/histedit.py not using absolute_import
70 70 hgext/keyword.py not using absolute_import
71 71 hgext/largefiles/__init__.py not using absolute_import
72 72 hgext/largefiles/basestore.py not using absolute_import
73 73 hgext/largefiles/lfcommands.py not using absolute_import
74 74 hgext/largefiles/lfutil.py not using absolute_import
75 75 hgext/largefiles/localstore.py not using absolute_import
76 76 hgext/largefiles/overrides.py not using absolute_import
77 77 hgext/largefiles/proto.py not using absolute_import
78 78 hgext/largefiles/remotestore.py not using absolute_import
79 79 hgext/largefiles/reposetup.py not using absolute_import
80 80 hgext/largefiles/uisetup.py not using absolute_import
81 81 hgext/largefiles/wirestore.py not using absolute_import
82 82 hgext/mq.py not using absolute_import
83 83 hgext/notify.py not using absolute_import
84 84 hgext/pager.py not using absolute_import
85 85 hgext/patchbomb.py not using absolute_import
86 86 hgext/purge.py not using absolute_import
87 87 hgext/rebase.py not using absolute_import
88 88 hgext/record.py not using absolute_import
89 89 hgext/relink.py not using absolute_import
90 90 hgext/schemes.py not using absolute_import
91 91 hgext/share.py not using absolute_import
92 92 hgext/shelve.py not using absolute_import
93 93 hgext/strip.py not using absolute_import
94 94 hgext/transplant.py not using absolute_import
95 95 hgext/win32mbcs.py not using absolute_import
96 96 hgext/win32text.py not using absolute_import
97 97 hgext/zeroconf/Zeroconf.py not using absolute_import
98 98 hgext/zeroconf/Zeroconf.py requires print_function
99 99 hgext/zeroconf/__init__.py not using absolute_import
100 100 i18n/check-translation.py not using absolute_import
101 101 i18n/polib.py not using absolute_import
102 102 mercurial/byterange.py not using absolute_import
103 103 mercurial/cmdutil.py not using absolute_import
104 104 mercurial/commands.py not using absolute_import
105 105 mercurial/commandserver.py not using absolute_import
106 106 mercurial/context.py not using absolute_import
107 107 mercurial/destutil.py not using absolute_import
108 108 mercurial/dirstate.py not using absolute_import
109 109 mercurial/dispatch.py requires print_function
110 110 mercurial/encoding.py not using absolute_import
111 111 mercurial/exchange.py not using absolute_import
112 112 mercurial/help.py not using absolute_import
113 113 mercurial/httpclient/__init__.py not using absolute_import
114 114 mercurial/httpclient/_readers.py not using absolute_import
115 115 mercurial/httpclient/socketutil.py not using absolute_import
116 116 mercurial/httpconnection.py not using absolute_import
117 117 mercurial/keepalive.py not using absolute_import
118 118 mercurial/keepalive.py requires print_function
119 119 mercurial/localrepo.py not using absolute_import
120 120 mercurial/lsprof.py requires print_function
121 121 mercurial/lsprofcalltree.py not using absolute_import
122 122 mercurial/lsprofcalltree.py requires print_function
123 123 mercurial/mail.py requires print_function
124 124 mercurial/manifest.py not using absolute_import
125 125 mercurial/mdiff.py not using absolute_import
126 126 mercurial/obsolete.py not using absolute_import
127 127 mercurial/patch.py not using absolute_import
128 128 mercurial/pure/__init__.py not using absolute_import
129 129 mercurial/pure/base85.py not using absolute_import
130 130 mercurial/pure/bdiff.py not using absolute_import
131 131 mercurial/pure/diffhelpers.py not using absolute_import
132 132 mercurial/pure/mpatch.py not using absolute_import
133 133 mercurial/pure/osutil.py not using absolute_import
134 134 mercurial/pure/parsers.py not using absolute_import
135 135 mercurial/pvec.py not using absolute_import
136 136 mercurial/py3kcompat.py not using absolute_import
137 137 mercurial/revlog.py not using absolute_import
138 138 mercurial/scmposix.py not using absolute_import
139 139 mercurial/scmutil.py not using absolute_import
140 140 mercurial/scmwindows.py not using absolute_import
141 141 mercurial/similar.py not using absolute_import
142 142 mercurial/store.py not using absolute_import
143 143 mercurial/util.py not using absolute_import
144 144 mercurial/windows.py not using absolute_import
145 145 setup.py not using absolute_import
146 tests/filterpyflakes.py not using absolute_import
147 146 tests/filterpyflakes.py requires print_function
148 147 tests/generate-working-copy-states.py not using absolute_import
149 148 tests/generate-working-copy-states.py requires print_function
150 149 tests/get-with-headers.py not using absolute_import
151 150 tests/get-with-headers.py requires print_function
152 151 tests/heredoctest.py not using absolute_import
153 152 tests/heredoctest.py requires print_function
154 153 tests/hghave.py not using absolute_import
155 154 tests/hgweberror.py not using absolute_import
156 155 tests/hypothesishelpers.py not using absolute_import
157 156 tests/hypothesishelpers.py requires print_function
158 157 tests/killdaemons.py not using absolute_import
159 158 tests/md5sum.py not using absolute_import
160 159 tests/mockblackbox.py not using absolute_import
161 160 tests/printenv.py not using absolute_import
162 161 tests/readlink.py not using absolute_import
163 162 tests/readlink.py requires print_function
164 163 tests/revlog-formatv0.py not using absolute_import
165 164 tests/run-tests.py not using absolute_import
166 165 tests/seq.py not using absolute_import
167 166 tests/seq.py requires print_function
168 167 tests/silenttestrunner.py not using absolute_import
169 168 tests/silenttestrunner.py requires print_function
170 169 tests/sitecustomize.py not using absolute_import
171 170 tests/svn-safe-append.py not using absolute_import
172 171 tests/svnxml.py not using absolute_import
173 172 tests/test-ancestor.py requires print_function
174 173 tests/test-atomictempfile.py not using absolute_import
175 174 tests/test-batching.py not using absolute_import
176 175 tests/test-batching.py requires print_function
177 176 tests/test-bdiff.py not using absolute_import
178 177 tests/test-bdiff.py requires print_function
179 178 tests/test-context.py not using absolute_import
180 179 tests/test-context.py requires print_function
181 180 tests/test-demandimport.py not using absolute_import
182 181 tests/test-demandimport.py requires print_function
183 182 tests/test-dispatch.py not using absolute_import
184 183 tests/test-dispatch.py requires print_function
185 184 tests/test-doctest.py not using absolute_import
186 185 tests/test-duplicateoptions.py not using absolute_import
187 186 tests/test-duplicateoptions.py requires print_function
188 187 tests/test-filecache.py not using absolute_import
189 188 tests/test-filecache.py requires print_function
190 189 tests/test-filelog.py not using absolute_import
191 190 tests/test-filelog.py requires print_function
192 191 tests/test-hg-parseurl.py not using absolute_import
193 192 tests/test-hg-parseurl.py requires print_function
194 193 tests/test-hgweb-auth.py not using absolute_import
195 194 tests/test-hgweb-auth.py requires print_function
196 195 tests/test-hgwebdir-paths.py not using absolute_import
197 196 tests/test-hybridencode.py not using absolute_import
198 197 tests/test-hybridencode.py requires print_function
199 198 tests/test-lrucachedict.py not using absolute_import
200 199 tests/test-lrucachedict.py requires print_function
201 200 tests/test-manifest.py not using absolute_import
202 201 tests/test-minirst.py not using absolute_import
203 202 tests/test-minirst.py requires print_function
204 203 tests/test-parseindex2.py not using absolute_import
205 204 tests/test-parseindex2.py requires print_function
206 205 tests/test-pathencode.py not using absolute_import
207 206 tests/test-pathencode.py requires print_function
208 207 tests/test-propertycache.py not using absolute_import
209 208 tests/test-propertycache.py requires print_function
210 209 tests/test-revlog-ancestry.py not using absolute_import
211 210 tests/test-revlog-ancestry.py requires print_function
212 211 tests/test-run-tests.py not using absolute_import
213 212 tests/test-simplemerge.py not using absolute_import
214 213 tests/test-status-inprocess.py not using absolute_import
215 214 tests/test-status-inprocess.py requires print_function
216 215 tests/test-symlink-os-yes-fs-no.py not using absolute_import
217 216 tests/test-trusted.py not using absolute_import
218 217 tests/test-trusted.py requires print_function
219 218 tests/test-ui-color.py not using absolute_import
220 219 tests/test-ui-color.py requires print_function
221 220 tests/test-ui-config.py not using absolute_import
222 221 tests/test-ui-config.py requires print_function
223 222 tests/test-ui-verbosity.py not using absolute_import
224 223 tests/test-ui-verbosity.py requires print_function
225 224 tests/test-url.py not using absolute_import
226 225 tests/test-url.py requires print_function
227 226 tests/test-walkrepo.py not using absolute_import
228 227 tests/test-walkrepo.py requires print_function
229 228 tests/test-wireproto.py not using absolute_import
230 229 tests/test-wireproto.py requires print_function
231 230 tests/tinyproxy.py not using absolute_import
232 231 tests/tinyproxy.py requires print_function
@@ -1,12 +1,12 b''
1 1 #require test-repo pyflakes
2 2
3 3 $ cd "`dirname "$TESTDIR"`"
4 4
5 5 run pyflakes on all tracked files ending in .py or without a file ending
6 6 (skipping binary file random-seed)
7 7
8 8 $ hg locate 'set:**.py or grep("^!#.*python")' 2>/dev/null \
9 9 > | xargs pyflakes 2>/dev/null | "$TESTDIR/filterpyflakes.py"
10 tests/filterpyflakes.py:58: undefined name 'undefinedname'
10 tests/filterpyflakes.py:61: undefined name 'undefinedname'
11 11
12 12
General Comments 0
You need to be logged in to leave comments. Login now