def testPrecondition(self): class MyNode(node.Node("s: str")): pass MyNode("a") # OK. try: node.SetCheckPreconditions(False) MyNode(1) # Preconditions are ignored. finally: # Restore preconditions (not part of the public API, but ensures the # test doesn't have a surprising side effect). node.SetCheckPreconditions(True)
def main(): try: args, kythe_args, options = parse_args.parse_args(sys.argv[1:]) except utils.UsageError as e: print(str(e), file=sys.stderr) sys.exit(1) node.SetCheckPreconditions(options.check_preconditions) if options.timeout is not None: signal.alarm(options.timeout) try: ix, _ = indexer.process_file(options, kythe_args=kythe_args, keep_pytype_data=args.debug) except indexer.PytypeError as e: print(e.args[0], file=sys.stderr) if args.debug: traceback.print_exc() else: print("Run with --debug to see a traceback.") sys.exit(1) if args.debug: debug.show_index(ix, keep_pytype_data=True) else: output.output_kythe_graph(ix)
def main(): try: options = config.Options(sys.argv[1:], command_line=True) except utils.UsageError as e: print(str(e), file=sys.stderr) sys.exit(1) if options.show_config: print(options) sys.exit(0) if options.version: print(io.get_pytype_version()) sys.exit(0) node.SetCheckPreconditions(options.check_preconditions) if options.timeout is not None: signal.alarm(options.timeout) with _ProfileContext(options.profile): with metrics.MetricsContext(options.metrics, options.open_function): with metrics.StopWatch("total_time"): with metrics.Snapshot("memory", enabled=options.memory_snapshots): return _run_pytype(options)
def main(): try: options = config.Options(sys.argv[1:]) except utils.UsageError as e: print(str(e), file=sys.stderr) sys.exit(1) node.SetCheckPreconditions(options.check_preconditions) if options.timeout is not None: signal.alarm(options.timeout) return process_file(options)
def main(): try: args, kythe_args, options = parse_args.parse_args(sys.argv[1:]) except utils.UsageError as e: print(str(e), file=sys.stderr) sys.exit(1) node.SetCheckPreconditions(options.check_preconditions) if options.timeout is not None: signal.alarm(options.timeout) ix = indexer.process_file(options, kythe_args=kythe_args) if args.debug: debug.show_index(ix) else: output.output_kythe_graph(ix)
def main(): try: options = config.Options(sys.argv[1:]) except utils.UsageError as e: print(str(e), file=sys.stderr) sys.exit(1) node.SetCheckPreconditions(options.check_preconditions) if options.timeout is not None: signal.alarm(options.timeout) v = indexer.process_file(options) output.show_defs(v) print() print("--------------------") print() output.show_refs(v)