Skip to content

Commit 5081d1e

Browse files
rchen152JelleZijlstra
authored andcommitted
Switch pytype_test from a whitelist to a blacklist for third_party. (#2956)
During the PyCon sprints, I'm planning to bash the pytype pyi parser into shape so we can handle all of third_party. As a first step, create an explicit blacklist of everything pytype chokes on.
1 parent bf2d517 commit 5081d1e

File tree

2 files changed

+120
-22
lines changed

2 files changed

+120
-22
lines changed

tests/pytype_blacklist.txt

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,113 @@ stdlib/2/__builtin__.pyi
66
stdlib/2/typing.pyi
77
stdlib/2and3/builtins.pyi
88
stdlib/3/typing.pyi
9+
10+
# third_party stubs with constructs that pytype doesn't yet support:
11+
third_party/2/fb303/FacebookService.pyi
12+
third_party/2/gflags.pyi
13+
third_party/2/scribe/scribe.pyi
14+
third_party/2/tornado/gen.pyi
15+
third_party/2/tornado/httpserver.pyi
16+
third_party/2/tornado/httputil.pyi
17+
third_party/2/tornado/web.pyi
18+
third_party/2and3/Crypto/Protocol/KDF.pyi
19+
third_party/2and3/attr/__init__.pyi
20+
third_party/2and3/attr/converters.pyi
21+
third_party/2and3/attr/filters.pyi
22+
third_party/2and3/attr/validators.pyi
23+
third_party/2and3/boto/__init__.pyi
24+
third_party/2and3/boto/compat.pyi
25+
third_party/2and3/boto/exception.pyi
26+
third_party/2and3/boto/kms/exceptions.pyi
27+
third_party/2and3/boto/s3/__init__.pyi
28+
third_party/2and3/boto/s3/acl.pyi
29+
third_party/2and3/boto/s3/bucket.pyi
30+
third_party/2and3/boto/s3/bucketlistresultset.pyi
31+
third_party/2and3/boto/s3/connection.pyi
32+
third_party/2and3/boto/utils.pyi
33+
third_party/2and3/click/README.md
34+
third_party/2and3/click/__init__.pyi
35+
third_party/2and3/click/core.pyi
36+
third_party/2and3/click/decorators.pyi
37+
third_party/2and3/click/exceptions.pyi
38+
third_party/2and3/click/formatting.pyi
39+
third_party/2and3/click/globals.pyi
40+
third_party/2and3/click/parser.pyi
41+
third_party/2and3/click/termui.pyi
42+
third_party/2and3/click/testing.pyi
43+
third_party/2and3/click/types.pyi
44+
third_party/2and3/dateutil/rrule.pyi
45+
third_party/2and3/flask/__init__.pyi
46+
third_party/2and3/flask/app.pyi
47+
third_party/2and3/flask/blueprints.pyi
48+
third_party/2and3/flask/cli.pyi
49+
third_party/2and3/flask/ctx.pyi
50+
third_party/2and3/flask/debughelpers.pyi
51+
third_party/2and3/flask/globals.pyi
52+
third_party/2and3/flask/helpers.pyi
53+
third_party/2and3/flask/logging.pyi
54+
third_party/2and3/flask/templating.pyi
55+
third_party/2and3/flask/testing.pyi
56+
third_party/2and3/flask/views.pyi
57+
third_party/2and3/google/protobuf/any_pb2.pyi
58+
third_party/2and3/google/protobuf/any_test_pb2.pyi
59+
third_party/2and3/google/protobuf/api_pb2.pyi
60+
third_party/2and3/google/protobuf/compiler/plugin_pb2.pyi
61+
third_party/2and3/google/protobuf/descriptor.pyi
62+
third_party/2and3/google/protobuf/descriptor_pb2.pyi
63+
third_party/2and3/google/protobuf/duration_pb2.pyi
64+
third_party/2and3/google/protobuf/empty_pb2.pyi
65+
third_party/2and3/google/protobuf/field_mask_pb2.pyi
66+
third_party/2and3/google/protobuf/internal/containers.pyi
67+
third_party/2and3/google/protobuf/json_format.pyi
68+
third_party/2and3/google/protobuf/map_proto2_unittest_pb2.pyi
69+
third_party/2and3/google/protobuf/map_unittest_pb2.pyi
70+
third_party/2and3/google/protobuf/message.pyi
71+
third_party/2and3/google/protobuf/message_factory.pyi
72+
third_party/2and3/google/protobuf/service.pyi
73+
third_party/2and3/google/protobuf/source_context_pb2.pyi
74+
third_party/2and3/google/protobuf/struct_pb2.pyi
75+
third_party/2and3/google/protobuf/symbol_database.pyi
76+
third_party/2and3/google/protobuf/test_messages_proto2_pb2.pyi
77+
third_party/2and3/google/protobuf/test_messages_proto3_pb2.pyi
78+
third_party/2and3/google/protobuf/timestamp_pb2.pyi
79+
third_party/2and3/google/protobuf/type_pb2.pyi
80+
third_party/2and3/google/protobuf/unittest_arena_pb2.pyi
81+
third_party/2and3/google/protobuf/unittest_custom_options_pb2.pyi
82+
third_party/2and3/google/protobuf/unittest_import_pb2.pyi
83+
third_party/2and3/google/protobuf/unittest_import_public_pb2.pyi
84+
third_party/2and3/google/protobuf/unittest_mset_pb2.pyi
85+
third_party/2and3/google/protobuf/unittest_mset_wire_format_pb2.pyi
86+
third_party/2and3/google/protobuf/unittest_no_arena_import_pb2.pyi
87+
third_party/2and3/google/protobuf/unittest_no_arena_pb2.pyi
88+
third_party/2and3/google/protobuf/unittest_no_generic_services_pb2.pyi
89+
third_party/2and3/google/protobuf/unittest_pb2.pyi
90+
third_party/2and3/google/protobuf/unittest_proto3_arena_pb2.pyi
91+
third_party/2and3/google/protobuf/util/json_format_proto3_pb2.pyi
92+
third_party/2and3/google/protobuf/wrappers_pb2.pyi
93+
third_party/2and3/jinja2/__init__.pyi
94+
third_party/2and3/jinja2/environment.pyi
95+
third_party/2and3/jinja2/loaders.pyi
96+
third_party/2and3/jinja2/runtime.pyi
97+
third_party/2and3/jinja2/sandbox.pyi
98+
third_party/2and3/jinja2/utils.pyi
99+
third_party/2and3/markupsafe/__init__.pyi
100+
third_party/2and3/markupsafe/_compat.pyi
101+
third_party/2and3/markupsafe/_native.pyi
102+
third_party/2and3/markupsafe/_speedups.pyi
103+
third_party/2and3/pymysql/__init__.pyi
104+
third_party/2and3/pymysql/connections.pyi
105+
third_party/2and3/pymysql/converters.pyi
106+
third_party/2and3/pymysql/cursors.pyi
107+
third_party/2and3/pymysql/err.pyi
108+
third_party/2and3/pynamodb/models.pyi
109+
third_party/2and3/requests/__init__.pyi
110+
third_party/2and3/requests/adapters.pyi
111+
third_party/2and3/requests/api.pyi
112+
third_party/2and3/requests/auth.pyi
113+
third_party/2and3/requests/models.pyi
114+
third_party/2and3/requests/packages/urllib3/__init__.pyi
115+
third_party/2and3/requests/packages/urllib3/connectionpool.pyi
116+
third_party/2and3/requests/sessions.pyi
117+
third_party/2and3/werkzeug/__init__.pyi
118+
third_party/2and3/werkzeug/urls.pyi

tests/pytype_test.py

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -149,18 +149,7 @@ def pytype_test(args):
149149
'via {arg})'.format(version=version, arg=arg))
150150
return 1
151151

152-
# TODO(rchen152): Keep expanding our third_party/ coverage so we can move
153-
# to a small blacklist rather than an ever-growing whitelist.
154-
wanted = [
155-
'stdlib/',
156-
'third_party/.*/mypy_extensions',
157-
'third_party/.*/pkg_resources',
158-
'third_party/.*/six/',
159-
'third_party/.*/yaml/',
160-
]
161-
wanted_re = re.compile(r'(?:%s).*\.pyi$' % '|'.join(wanted))
162152
skipped = PathMatcher(load_blacklist(typeshed_location))
163-
164153
files = []
165154
bad = []
166155

@@ -186,17 +175,16 @@ def _parse(filename, major_version):
186175
for f in sorted(filenames):
187176
f = os.path.join(root, f)
188177
rel = _get_relative(f)
189-
if wanted_re.search(rel):
190-
if not skipped.search(rel):
191-
if _is_version(f, '2and3'):
192-
files.append((f, 2))
193-
files.append((f, 3))
194-
elif _is_version(f, '2'):
195-
files.append((f, 2))
196-
elif _is_version(f, '3'):
197-
files.append((f, 3))
198-
else:
199-
print('Unrecognized path: %s' % f)
178+
if not skipped.search(rel):
179+
if _is_version(f, '2and3'):
180+
files.append((f, 2))
181+
files.append((f, 3))
182+
elif _is_version(f, '2'):
183+
files.append((f, 2))
184+
elif _is_version(f, '3'):
185+
files.append((f, 3))
186+
else:
187+
print('Unrecognized path: %s' % f)
200188

201189
errors = 0
202190
total_tests = len(files)

0 commit comments

Comments
 (0)