lint: Add a lint check for bare `type: ignore`s.

This commit is contained in:
Tim Abbott 2017-07-27 15:59:36 -07:00
parent e6e3bbb780
commit 53e4d8562b
6 changed files with 10 additions and 5 deletions

View File

@ -61,7 +61,7 @@ def get_old_conf(output_filename):
secrets_file = six.moves.configparser.RawConfigParser()
secrets_file.read(output_filename)
return dict(secrets_file.items("secrets")) # type: ignore
return dict(secrets_file.items("secrets")) # type: ignore # likely typeshed issue
def generate_secrets(development=False):
# type: (bool) -> None

View File

@ -205,6 +205,11 @@ def build_custom_checkers(by_lang):
'description': 'Use `is None` to check whether something is None'},
{'pattern': "type:[(]",
'description': 'Missing whitespace after ":" in type annotation'},
{'pattern': "type: ignore$",
'exclude': set(['tools/tests',
'zerver/lib/test_runner.py',
'zerver/tests']),
'description': '"type: ignore" should always end with "# type: ignore # explanation for why"'},
{'pattern': "# type [(]",
'description': 'Missing : after type in type annotation'},
{'pattern': "#type",

View File

@ -76,5 +76,5 @@ class EmbeddedBotHandler(object):
our_dir, '..', 'bots', bot_name, bot_name + '.conf'))
section = section or bot_name
config = configparser.ConfigParser()
config.readfp(open(conf_file_path)) # type: ignore
config.readfp(open(conf_file_path)) # type: ignore # likely typeshed issue
return dict(config.items(section))

View File

@ -171,7 +171,7 @@ def stdout_suppressed():
"""Redirect stdout to /dev/null."""
with open(os.devnull, 'a') as devnull:
stdout, sys.stdout = sys.stdout, devnull # type: ignore
stdout, sys.stdout = sys.stdout, devnull # type: ignore # monkey-patching
yield stdout
sys.stdout = stdout

View File

@ -97,7 +97,7 @@ class LocalUploader(Uploader):
def write_local_file(self, path, file_data):
# type: (Text, binary_type) -> None
self.mkdirs(path)
with open(path, 'wb') as f: # type: ignore
with open(path, 'wb') as f: # type: ignore # likely mypy bug
f.write(file_data)
def upload_files(self, response, resized_image, dst_path_id):

View File

@ -244,7 +244,7 @@ class SocialAuthMixin(ZulipAuthMixin):
"""
try:
# Call the auth_complete method of BaseOAuth2 is Python Social Auth
return super(SocialAuthMixin, self).auth_complete(*args, **kwargs) # type: ignore
return super(SocialAuthMixin, self).auth_complete(*args, **kwargs) # type: ignore # monkey-patching
except AuthFailed:
return None
except SocialAuthBaseException as e: