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.
This commit is contained in:
Rebecca Chen
2019-05-05 22:02:53 -04:00
committed by Jelle Zijlstra
parent bf2d51742b
commit 5081d1e132
2 changed files with 120 additions and 22 deletions

View File

@@ -6,3 +6,113 @@ stdlib/2/__builtin__.pyi
stdlib/2/typing.pyi
stdlib/2and3/builtins.pyi
stdlib/3/typing.pyi
# third_party stubs with constructs that pytype doesn't yet support:
third_party/2/fb303/FacebookService.pyi
third_party/2/gflags.pyi
third_party/2/scribe/scribe.pyi
third_party/2/tornado/gen.pyi
third_party/2/tornado/httpserver.pyi
third_party/2/tornado/httputil.pyi
third_party/2/tornado/web.pyi
third_party/2and3/Crypto/Protocol/KDF.pyi
third_party/2and3/attr/__init__.pyi
third_party/2and3/attr/converters.pyi
third_party/2and3/attr/filters.pyi
third_party/2and3/attr/validators.pyi
third_party/2and3/boto/__init__.pyi
third_party/2and3/boto/compat.pyi
third_party/2and3/boto/exception.pyi
third_party/2and3/boto/kms/exceptions.pyi
third_party/2and3/boto/s3/__init__.pyi
third_party/2and3/boto/s3/acl.pyi
third_party/2and3/boto/s3/bucket.pyi
third_party/2and3/boto/s3/bucketlistresultset.pyi
third_party/2and3/boto/s3/connection.pyi
third_party/2and3/boto/utils.pyi
third_party/2and3/click/README.md
third_party/2and3/click/__init__.pyi
third_party/2and3/click/core.pyi
third_party/2and3/click/decorators.pyi
third_party/2and3/click/exceptions.pyi
third_party/2and3/click/formatting.pyi
third_party/2and3/click/globals.pyi
third_party/2and3/click/parser.pyi
third_party/2and3/click/termui.pyi
third_party/2and3/click/testing.pyi
third_party/2and3/click/types.pyi
third_party/2and3/dateutil/rrule.pyi
third_party/2and3/flask/__init__.pyi
third_party/2and3/flask/app.pyi
third_party/2and3/flask/blueprints.pyi
third_party/2and3/flask/cli.pyi
third_party/2and3/flask/ctx.pyi
third_party/2and3/flask/debughelpers.pyi
third_party/2and3/flask/globals.pyi
third_party/2and3/flask/helpers.pyi
third_party/2and3/flask/logging.pyi
third_party/2and3/flask/templating.pyi
third_party/2and3/flask/testing.pyi
third_party/2and3/flask/views.pyi
third_party/2and3/google/protobuf/any_pb2.pyi
third_party/2and3/google/protobuf/any_test_pb2.pyi
third_party/2and3/google/protobuf/api_pb2.pyi
third_party/2and3/google/protobuf/compiler/plugin_pb2.pyi
third_party/2and3/google/protobuf/descriptor.pyi
third_party/2and3/google/protobuf/descriptor_pb2.pyi
third_party/2and3/google/protobuf/duration_pb2.pyi
third_party/2and3/google/protobuf/empty_pb2.pyi
third_party/2and3/google/protobuf/field_mask_pb2.pyi
third_party/2and3/google/protobuf/internal/containers.pyi
third_party/2and3/google/protobuf/json_format.pyi
third_party/2and3/google/protobuf/map_proto2_unittest_pb2.pyi
third_party/2and3/google/protobuf/map_unittest_pb2.pyi
third_party/2and3/google/protobuf/message.pyi
third_party/2and3/google/protobuf/message_factory.pyi
third_party/2and3/google/protobuf/service.pyi
third_party/2and3/google/protobuf/source_context_pb2.pyi
third_party/2and3/google/protobuf/struct_pb2.pyi
third_party/2and3/google/protobuf/symbol_database.pyi
third_party/2and3/google/protobuf/test_messages_proto2_pb2.pyi
third_party/2and3/google/protobuf/test_messages_proto3_pb2.pyi
third_party/2and3/google/protobuf/timestamp_pb2.pyi
third_party/2and3/google/protobuf/type_pb2.pyi
third_party/2and3/google/protobuf/unittest_arena_pb2.pyi
third_party/2and3/google/protobuf/unittest_custom_options_pb2.pyi
third_party/2and3/google/protobuf/unittest_import_pb2.pyi
third_party/2and3/google/protobuf/unittest_import_public_pb2.pyi
third_party/2and3/google/protobuf/unittest_mset_pb2.pyi
third_party/2and3/google/protobuf/unittest_mset_wire_format_pb2.pyi
third_party/2and3/google/protobuf/unittest_no_arena_import_pb2.pyi
third_party/2and3/google/protobuf/unittest_no_arena_pb2.pyi
third_party/2and3/google/protobuf/unittest_no_generic_services_pb2.pyi
third_party/2and3/google/protobuf/unittest_pb2.pyi
third_party/2and3/google/protobuf/unittest_proto3_arena_pb2.pyi
third_party/2and3/google/protobuf/util/json_format_proto3_pb2.pyi
third_party/2and3/google/protobuf/wrappers_pb2.pyi
third_party/2and3/jinja2/__init__.pyi
third_party/2and3/jinja2/environment.pyi
third_party/2and3/jinja2/loaders.pyi
third_party/2and3/jinja2/runtime.pyi
third_party/2and3/jinja2/sandbox.pyi
third_party/2and3/jinja2/utils.pyi
third_party/2and3/markupsafe/__init__.pyi
third_party/2and3/markupsafe/_compat.pyi
third_party/2and3/markupsafe/_native.pyi
third_party/2and3/markupsafe/_speedups.pyi
third_party/2and3/pymysql/__init__.pyi
third_party/2and3/pymysql/connections.pyi
third_party/2and3/pymysql/converters.pyi
third_party/2and3/pymysql/cursors.pyi
third_party/2and3/pymysql/err.pyi
third_party/2and3/pynamodb/models.pyi
third_party/2and3/requests/__init__.pyi
third_party/2and3/requests/adapters.pyi
third_party/2and3/requests/api.pyi
third_party/2and3/requests/auth.pyi
third_party/2and3/requests/models.pyi
third_party/2and3/requests/packages/urllib3/__init__.pyi
third_party/2and3/requests/packages/urllib3/connectionpool.pyi
third_party/2and3/requests/sessions.pyi
third_party/2and3/werkzeug/__init__.pyi
third_party/2and3/werkzeug/urls.pyi

View File

@@ -149,18 +149,7 @@ def pytype_test(args):
'via {arg})'.format(version=version, arg=arg))
return 1
# TODO(rchen152): Keep expanding our third_party/ coverage so we can move
# to a small blacklist rather than an ever-growing whitelist.
wanted = [
'stdlib/',
'third_party/.*/mypy_extensions',
'third_party/.*/pkg_resources',
'third_party/.*/six/',
'third_party/.*/yaml/',
]
wanted_re = re.compile(r'(?:%s).*\.pyi$' % '|'.join(wanted))
skipped = PathMatcher(load_blacklist(typeshed_location))
files = []
bad = []
@@ -186,17 +175,16 @@ def pytype_test(args):
for f in sorted(filenames):
f = os.path.join(root, f)
rel = _get_relative(f)
if wanted_re.search(rel):
if not skipped.search(rel):
if _is_version(f, '2and3'):
files.append((f, 2))
files.append((f, 3))
elif _is_version(f, '2'):
files.append((f, 2))
elif _is_version(f, '3'):
files.append((f, 3))
else:
print('Unrecognized path: %s' % f)
if not skipped.search(rel):
if _is_version(f, '2and3'):
files.append((f, 2))
files.append((f, 3))
elif _is_version(f, '2'):
files.append((f, 2))
elif _is_version(f, '3'):
files.append((f, 3))
else:
print('Unrecognized path: %s' % f)
errors = 0
total_tests = len(files)