mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 14:03:30 +00:00 
			
		
		
		
	lint: Add a lint check for bare type: ignores.
				
					
				
			This commit is contained in:
		@@ -61,7 +61,7 @@ def get_old_conf(output_filename):
 | 
				
			|||||||
    secrets_file = six.moves.configparser.RawConfigParser()
 | 
					    secrets_file = six.moves.configparser.RawConfigParser()
 | 
				
			||||||
    secrets_file.read(output_filename)
 | 
					    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):
 | 
					def generate_secrets(development=False):
 | 
				
			||||||
    # type: (bool) -> None
 | 
					    # type: (bool) -> None
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -205,6 +205,11 @@ def build_custom_checkers(by_lang):
 | 
				
			|||||||
         'description': 'Use `is None` to check whether something is None'},
 | 
					         'description': 'Use `is None` to check whether something is None'},
 | 
				
			||||||
        {'pattern': "type:[(]",
 | 
					        {'pattern': "type:[(]",
 | 
				
			||||||
         'description': 'Missing whitespace after ":" in type annotation'},
 | 
					         '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 [(]",
 | 
					        {'pattern': "# type [(]",
 | 
				
			||||||
         'description': 'Missing : after type in type annotation'},
 | 
					         'description': 'Missing : after type in type annotation'},
 | 
				
			||||||
        {'pattern': "#type",
 | 
					        {'pattern': "#type",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -76,5 +76,5 @@ class EmbeddedBotHandler(object):
 | 
				
			|||||||
            our_dir, '..', 'bots', bot_name, bot_name + '.conf'))
 | 
					            our_dir, '..', 'bots', bot_name, bot_name + '.conf'))
 | 
				
			||||||
        section = section or bot_name
 | 
					        section = section or bot_name
 | 
				
			||||||
        config = configparser.ConfigParser()
 | 
					        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))
 | 
					        return dict(config.items(section))
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -171,7 +171,7 @@ def stdout_suppressed():
 | 
				
			|||||||
    """Redirect stdout to /dev/null."""
 | 
					    """Redirect stdout to /dev/null."""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    with open(os.devnull, 'a') as devnull:
 | 
					    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
 | 
					        yield stdout
 | 
				
			||||||
        sys.stdout = stdout
 | 
					        sys.stdout = stdout
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -97,7 +97,7 @@ class LocalUploader(Uploader):
 | 
				
			|||||||
    def write_local_file(self, path, file_data):
 | 
					    def write_local_file(self, path, file_data):
 | 
				
			||||||
        # type: (Text, binary_type) -> None
 | 
					        # type: (Text, binary_type) -> None
 | 
				
			||||||
        self.mkdirs(path)
 | 
					        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)
 | 
					            f.write(file_data)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def upload_files(self, response, resized_image, dst_path_id):
 | 
					    def upload_files(self, response, resized_image, dst_path_id):
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -244,7 +244,7 @@ class SocialAuthMixin(ZulipAuthMixin):
 | 
				
			|||||||
        """
 | 
					        """
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            # Call the auth_complete method of BaseOAuth2 is Python Social Auth
 | 
					            # 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:
 | 
					        except AuthFailed:
 | 
				
			||||||
            return None
 | 
					            return None
 | 
				
			||||||
        except SocialAuthBaseException as e:
 | 
					        except SocialAuthBaseException as e:
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user