Changeset - 755b2c66b462
[Not reviewed]
default
0 4 0
Mads Kiilerich (mads) - 6 years ago 2020-08-18 22:25:45
mads@kiilerich.com
Grafted from: 322508f5a0ba
pytype: mute errors from import of optional or platform specific modules

Mute pytype warnings:

File "kallithea/bin/kallithea_cli_iis.py", line 69, in iis_install: Can't find module 'isapi_wsgi'. [import-error]
File "kallithea/config/post_receive_tmpl.py", line 24, in <module>: No attribute 'setmode' on module 'msvcrt' [module-attr]
File "kallithea/config/pre_receive_tmpl.py", line 24, in <module>: No attribute 'setmode' on module 'msvcrt' [module-attr]
File "kallithea/lib/compat.py", line 59, in kill: No attribute 'windll' on module 'ctypes' [module-attr]
File "kallithea/lib/utils.py", line 242, in is_valid_repo_uri: Can't find module 'hgsubversion.svnrepo'. [import-error]
File "kallithea/tests/scripts/manual_test_concurrency.py", line 203, in <module>: No attribute '_RandomNameSequence' on module 'tempfile' [module-attr]
4 files changed with 4 insertions and 4 deletions:
0 comments (0 inline, 0 general)
kallithea/bin/kallithea_cli_iis.py
Show inline comments
 
@@ -56,25 +56,25 @@ if __name__=='__main__':
 
    HandleCommandLine(params)
 
'''
 

	
 
@cli_base.register_command(needs_config_file=True)
 
@click.option('--virtualdir', default='/',
 
        help='The virtual folder to install into on IIS.')
 
def iis_install(virtualdir, config):
 
    """Install into IIS using isapi-wsgi."""
 

	
 
    config_file_abs = config['__file__']
 

	
 
    try:
 
        import isapi_wsgi
 
        import isapi_wsgi  # pytype: disable=import-error
 
        assert isapi_wsgi
 
    except ImportError:
 
        sys.stderr.write('missing requirement: isapi-wsgi not installed\n')
 
        sys.exit(1)
 

	
 
    dispatchfile = os.path.join(os.getcwd(), 'dispatch.py')
 
    click.echo('Writing %s' % dispatchfile)
 
    with open(dispatchfile, 'w') as f:
 
        f.write(dispath_py_template % {
 
            'inifile': config_file_abs.replace('\\', '\\\\'),
 
            'inifiledir': os.path.dirname(config_file_abs).replace('\\', '\\\\'),
 
            'virtualdir': virtualdir,
kallithea/lib/compat.py
Show inline comments
 
@@ -47,23 +47,23 @@ from kallithea.lib import ext_json
 

	
 
formatted_json = functools.partial(ext_json.dumps, indent=4, sort_keys=True)
 

	
 

	
 
#==============================================================================
 
# kill
 
#==============================================================================
 
if os.name == 'nt': # Windows
 
    import ctypes
 

	
 
    def kill(pid, sig):
 
        """kill function for Win32"""
 
        kernel32 = ctypes.windll.kernel32
 
        kernel32 = ctypes.windll.kernel32  # pytype: disable=module-attr
 
        handle = kernel32.OpenProcess(1, 0, pid)
 
        return (0 != kernel32.TerminateProcess(handle, 0))
 

	
 
else:
 
    kill = os.kill
 

	
 

	
 
# mute pyflakes "imported but unused"
 
assert hybrid_property
 
assert OrderedSet
kallithea/templates/py/git_post_receive_hook.py
Show inline comments
 
@@ -13,25 +13,25 @@ import subprocess
 
import sys
 

	
 
import kallithea.bin.vcs_hooks
 

	
 

	
 
# Set output mode on windows to binary for stderr.
 
# This prevents python (or the windows console) from replacing \n with \r\n.
 
# Git doesn't display remote output lines that contain \r,
 
# and therefore without this modification git would display empty lines
 
# instead of the exception output.
 
if sys.platform == "win32":
 
    import msvcrt
 
    msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY)
 
    msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY)  # pytype: disable=module-attr
 

	
 
KALLITHEA_HOOK_VER = '_TMPL_'
 
os.environ['KALLITHEA_HOOK_VER'] = KALLITHEA_HOOK_VER
 

	
 

	
 
def main():
 
    repo_path = os.path.abspath('.')
 
    git_stdin_lines = sys.stdin.readlines()
 
    status = kallithea.bin.vcs_hooks.post_receive(repo_path, git_stdin_lines)
 

	
 
    custom_hook = os.path.join(repo_path, 'hooks', 'post-receive-custom')
 
    custom_status = None
kallithea/tests/scripts/manual_test_concurrency.py
Show inline comments
 
@@ -190,23 +190,23 @@ if __name__ == '__main__':
 

	
 
        try:
 
            METHOD = sys.argv[3]
 
        except IndexError:
 
            pass
 

	
 
        try:
 
            backend = sys.argv[4]
 
        except IndexError:
 
            backend = 'hg'
 

	
 
        if METHOD == 'pull':
 
            seq = next(tempfile._RandomNameSequence())
 
            seq = next(tempfile._RandomNameSequence())  # pytype: disable=module-attr
 
            test_clone_with_credentials(repo=sys.argv[1], method='clone',
 
                                        backend=backend)
 
        s = time.time()
 
        for i in range(1, int(sys.argv[2]) + 1):
 
            print('take', i)
 
            test_clone_with_credentials(repo=sys.argv[1], method=METHOD,
 
                                        backend=backend)
 
        print('time taken %.3f' % (time.time() - s))
 
    except Exception as e:
 
        sys.exit('stop on %s' % e)
0 comments (0 inline, 0 general)