spawn.runv(command, env=env) def _cargo_command(args: argparse.Namespace, subcommand: str) -> list[str]: command = ["cargo"] if args.channel: command += [args.channel] command += [subcommand] if args.release: command += ["--release"] if args.timings: command += ["--timings"] if args.no_default_features: command += ["--no-default-features"] return command def _run_sql(url: str, sql: str) -> None: try: spawn.runv(["psql", "-At", url, "-c", sql]) except Exception as e: raise UIError( f"unable to execute postgres statement: {e}", hint="Have you installed and configured PostgreSQL for passwordless authentication?", ) if __name__ == "__main__": with ui.error_handler("run"): main()
please create an access token at https://github.com/settings/tokens""" ) def get(pr: str) -> Any: return requests.get( f"https://{username}:{token}@api.github.com/repos/MaterializeInc/materialize/pulls/{pr}", headers={ "Accept": "application/vnd.github.v3+json", }, ).json() collected = [] with concurrent.futures.ThreadPoolExecutor(max_workers=10) as pool: futures = {pool.submit(get, pr): pr for pr in prs} for future in concurrent.futures.as_completed(futures): pr = futures[future] contents = future.result() try: url = contents["html_url"] title = contents["title"] collected.append((url, title)) except KeyError: raise UIError(contents) for url, title in sorted(collected): print(url, title) if __name__ == "__main__": with ui.error_handler("mkrelease"): cli()
# `argparse.REMAINDER` seems like it'd be useful here, but it doesn't maintain # the above distinction, plus was deprecated in Python 3.9 due to unfixable # bugs: https://bugs.python.org/issue17050. class ArgumentParser(argparse.ArgumentParser): def parse_known_args( self, args: Optional[Sequence[Text]] = None, namespace: Optional[argparse.Namespace] = None, ) -> Tuple[argparse.Namespace, List[str]]: namespace, unknown_args = super().parse_known_args(args, namespace) setattr(namespace, "unknown_args", unknown_args) return namespace, [] class ArgumentSubparser(argparse.ArgumentParser): def parse_known_args( self, args: Optional[Sequence[Text]] = None, namespace: Optional[argparse.Namespace] = None, ) -> Tuple[argparse.Namespace, List[str]]: namespace, unknown_args = super().parse_known_args(args, namespace) setattr(namespace, "unknown_subargs", unknown_args) return namespace, [] if __name__ == "__main__": with ui.error_handler("mzcompose"): main(sys.argv[1:])