From 2bb09ddc995f2ebc5151eaad7ba4a2d6474b92cf Mon Sep 17 00:00:00 2001 From: MstrPikachu <31784486+MstrPikachu@users.noreply.github.com> Date: Mon, 13 Dec 2021 20:45:44 -0500 Subject: [PATCH] Add python_ta check to collect_others.py Add exception, fix variable shadowing --- src/report.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/report.py b/src/report.py index d64aaca..e7af496 100644 --- a/src/report.py +++ b/src/report.py @@ -12,6 +12,9 @@ from pathlib import Path from flask import Flask, send_from_directory, Response +import python_ta +import python_ta.contracts + from constants import REPORT_DIR, DEBUG, RES_DIR from utils import read, write @@ -35,6 +38,7 @@ def generate_report() -> str: continue # Process @include statements + # noinspection PyBroadException try: path = line[line.index('`') + 1:] path = path[:path.index('`')] @@ -43,7 +47,7 @@ def generate_report() -> str: # Cut lines # Format: @include-cut `path` [end, not inclusive] if line.startswith('@include-cut'): - args = [int(i) for i in line.split()[2:]] + args = [int(j) for j in line.split()[2:]] if len(args) == 1: md[i] = '\n'.join(md[i].split('\n')[args[0]:]) if len(args) == 2: @@ -53,7 +57,7 @@ def generate_report() -> str: # Format: @include-lines `path` <...lines> # Example: @include-lines `path` 1 2 5 if line.startswith('@include-lines'): - args = [int(i) for i in line.split()[2:]] + args = [int(j) for j in line.split()[2:]] lines = md[i].split('\n') lines = [lines[ln] for ln in range(len(lines)) if ln in args] md[i] = '\n'.join(lines) @@ -145,5 +149,12 @@ def serve_report() -> None: if __name__ == '__main__': - write_html() - serve_report() + python_ta.contracts.check_all_contracts() + python_ta.check_all(config={ + 'extra-imports': ['json', 'os.path', 'shutil', 'traceback', 'webbrowser', + 'distutils.dir_util', 'pathlib', 'flask', 'constants', 'utils' + ], # the names (strs) of imported modules + 'allowed-io': [], # the names (strs) of functions that call print/open/input + 'max-line-length': 100, + 'disable': ['R1705', 'C0200', 'R1702', 'W0703'] + })