def lint(argv: List[str]) -> None: """ Invoke Pylint with our preferred options """ print('>>>> Running pylint') args = [ '--rcfile=.pylintrc', # Load rcfile first. '--ignored-modules=alembic,MySQLdb,flask_sqlalchemy,distutils.dist', # override ignored-modules (codacy hack) '--load-plugins', 'pylint_quotes,pylint_monolith', # Plugins '-f', 'parseable', # Machine-readable output. '-j', str(configuration.get_int( 'pylint_threads')), # Use four cores for speed. ] args.extend(argv or find_files(file_extension='py')) # pylint: disable=import-outside-toplevel import pylint.lint try: linter = pylint.lint.Run(args, exit=False) except PicklingError: print('Error while running pylint with multiprocessing') configuration.write('pylint_threads', 1) lint(argv) return if linter.linter.msg_status: raise TestFailedException(linter.linter.msg_status)
def run_dangerously() -> None: try: cmd = sys.argv[1].lower() args = sys.argv[2:] except IndexError: raise InvalidArgumentException('Please supply an argument.') if cmd == 'unit': unit(args) elif cmd == 'functional': runtests(args, 'functional', True) elif cmd == 'perf': runtests(args, 'perf', True) elif cmd in ('test', 'tests'): runtests(args, '', False) elif cmd in ('lint', 'pylint'): lint(args) elif cmd in ('types', 'mypy'): mypy(args) elif cmd == 'mypy-strict': mypy(args, strict=True) elif cmd == 'typeshed': mypy(args, typeshedding=True) elif cmd == 'jslint': jslint() elif cmd == 'jsfix': jsfix() elif cmd in ('nuke_db', 'reset_db'): reset_db() elif cmd in ('imports', 'isort', 'sort'): sort() elif cmd in ('fix-sorts', 'fix-imports', 'fiximports'): sort(True) elif cmd in ('pr', 'pull-request'): pull_request(args) elif cmd == 'build': build() elif cmd == 'buildjs': buildjs() elif cmd == 'popclean': popclean() elif cmd == 'readme': generate_readme() elif cmd == 'coverage': coverage() elif cmd == 'watch': watch() elif cmd == 'branch': branch(args) elif cmd == 'push': push() elif cmd == 'check': check(args) elif cmd in ('safe_push', 'safepush'): safe_push(args) elif cmd == 'release': release(args) else: raise InvalidArgumentException('Unrecognised command {cmd}.'.format(cmd=cmd))
def push() -> None: print('> Rebasing branch on Master') subprocess.check_call(['git', 'pull', 'origin', 'master', '--rebase']) print('> Linting') lint([]) print('> Typechecking') mypy([], False) print('> Running Tests') tests([]) print('> Checking imports') sort(fix=False) print('> Pushing') branch = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD']).strip().decode() subprocess.check_call(['git', 'push', '--set-upstream', 'origin', branch])
def run() -> None: cmd = sys.argv[1].lower() if cmd in ('lint', 'pylint'): lint() elif cmd in ('types', 'mypy'): mypy() elif cmd in ('test', 'tests', 'pytest'): tests() else: print('Unrecognised command {cmd}.'.format(cmd=cmd)) exit(1)
def run() -> None: cmd = sys.argv[1].lower() if cmd in ('lint', 'pylint'): lint() elif cmd in ('types', 'mypy'): mypy() elif cmd == 'mypy-strict': mypy(True) elif cmd in ('test', 'tests', 'pytest'): tests() elif cmd in ('nuke_db', 'reset_db'): reset_db() else: print('Unrecognised command {cmd}.'.format(cmd=cmd)) exit(1)
def run() -> None: cmd = sys.argv[1].lower() args = sys.argv[2:] if cmd in ('lint', 'pylint'): lint(args) elif cmd in ('types', 'mypy'): mypy(args) elif cmd == 'mypy-strict': mypy(args, True) elif cmd in ('test', 'tests', 'pytest'): tests(args) elif cmd in ('nuke_db', 'reset_db'): reset_db() elif cmd == 'push': push() elif cmd in ('imports', 'isort', 'sort'): sort() elif cmd in ('fix-sorts', 'fix-imports', 'fiximports'): sort(True) elif cmd in ('pr', 'pull-request'): pull_request(args) elif cmd == 'release': push() pull_request(args) else: print('Unrecognised command {cmd}.'.format(cmd=cmd)) exit(1)
def test_platform(path): #dictionary to to collect filenames with the ocrrenspoding number of errors and warnings f = {} for root, dirs, files in os.walk(".", topdown=False): for name in files: try: x = name.split(".") except Exception, e: sys.stdout.write(e) sys.exit(100) if x[1] == 'py': print(bcolors.HEADER + str(name) + bcolors.ENDC) result = lint(name) sys.stdout.write(result[0]) if not result[1]: #Error or Warning detected by PyLint #Add to dict ==> 'File_name' : 'Warnings' f[os.path.join(root, name)] = ("Errors: " + str(result[2]), "Warnings: " + str(result[3]))
def check(args: List[str]) -> None: lint(args) jslint() mypy(args) sort()
def sanity_check(rootdir): """ Checks whether project passes pylint """ pyl.lint(rootdir)