From ce9bc04ae059e96633852f87d494f95fd52e8418 Mon Sep 17 00:00:00 2001 From: Greg Wilson Date: Tue, 29 Jul 2025 08:41:25 -0400 Subject: [PATCH 1/2] fix: add missing arguments to commands.py --- commands.py | 60 ++++++++++++++++++++++++----------------------------- 1 file changed, 27 insertions(+), 33 deletions(-) diff --git a/commands.py b/commands.py index 01f158380c..e4ab7b4e62 100644 --- a/commands.py +++ b/commands.py @@ -244,27 +244,10 @@ def update_plotlyjs(plotly_js_version, outdir): # FIXME: switch to argparse -def update_schema_bundle_from_master(): +def update_schema_bundle_from_master(args): """Update the plotly.js schema and bundle from master.""" - - if "--devrepo" in sys.argv: - devrepo = sys.argv[sys.argv.index("--devrepo") + 1] - else: - devrepo = "plotly/plotly.js" - - if "--devbranch" in sys.argv: - devbranch = sys.argv[sys.argv.index("--devbranch") + 1] - else: - devbranch = "master" - - if "--local" in sys.argv: - local = sys.argv[sys.argv.index("--local") + 1] - else: - local = None - - if local is None: - build_info = get_latest_publish_build_info(devrepo, devbranch) - + if args.local is None: + build_info = get_latest_publish_build_info(args.devrepo, args.devbranch) archive_url, bundle_url, schema_url = get_bundle_schema_urls( build_info["build_num"] ) @@ -275,14 +258,14 @@ def update_schema_bundle_from_master(): # Update schema in package data overwrite_schema(schema_url) else: - # this info could be more informative but - # it doesn't seem as useful in a local context - # and requires dependencies and programming. + # this info could be more informative but it doesn't seem as + # useful in a local context and requires dependencies and + # programming. build_info = {"vcs_revision": "local", "committer_date": str(time.time())} - devrepo = local - devbranch = "" + args.devrepo = args.local + args.devbranch = "" - archive_uri, bundle_uri, schema_uri = get_bundle_schema_local(local) + archive_uri, bundle_uri, schema_uri = get_bundle_schema_local(args.local) overwrite_bundle_local(bundle_uri) overwrite_schema_local(schema_uri) @@ -293,7 +276,7 @@ def update_schema_bundle_from_master(): # Replace version with bundle url package_json["dependencies"]["plotly.js"] = ( - archive_url if local is None else archive_uri + archive_url if args.local is None else archive_uri ) with open(package_json_path, "w") as f: json.dump(package_json, f, indent=2) @@ -301,15 +284,15 @@ def update_schema_bundle_from_master(): # update plotly.js version in _plotlyjs_version rev = build_info["vcs_revision"] date = str(build_info["committer_date"]) - version = "_".join([devrepo, devbranch, date[:10], rev[:8]]) + version = "_".join([args.devrepo, args.devbranch, date[:10], rev[:8]]) overwrite_plotlyjs_version_file(version) - install_js_deps(local) + install_js_deps(args.local) -def update_plotlyjs_dev(outdir): +def update_plotlyjs_dev(args, outdir): """Update project to a new development version of plotly.js.""" - update_schema_bundle_from_master() + update_schema_bundle_from_master(args) perform_codegen(outdir) @@ -328,7 +311,18 @@ def parse_args(): subparsers.add_parser("format", help="reformat code") - subparsers.add_parser("updateplotlyjsdev", help="update plotly.js for development") + p_update_dev = subparsers.add_parser( + "updateplotlyjsdev", help="update plotly.js for development" + ) + p_update_dev.add_argument( + "--devrepo", default="plotly/plotly.js", help="repository" + ) + p_update_dev.add_argument( + "--devbranch", default="master", help="branch" + ) + p_update_dev.add_argument( + "--local", default=None, help="local path" + ) subparsers.add_parser("updateplotlyjs", help="update plotly.js") @@ -353,7 +347,7 @@ def main(): lint_code(outdir) elif args.cmd == "updateplotlyjsdev": - update_plotlyjs_dev(outdir) + update_plotlyjs_dev(args, outdir) elif args.cmd == "updateplotlyjs": version = plotly_js_version() From 15ccb6bdaa93c2fccb9938c82e760982d48d92a4 Mon Sep 17 00:00:00 2001 From: Liam Connors Date: Wed, 30 Jul 2025 13:07:49 -0400 Subject: [PATCH 2/2] format code --- commands.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/commands.py b/commands.py index e4ab7b4e62..8fca244463 100644 --- a/commands.py +++ b/commands.py @@ -317,12 +317,8 @@ def parse_args(): p_update_dev.add_argument( "--devrepo", default="plotly/plotly.js", help="repository" ) - p_update_dev.add_argument( - "--devbranch", default="master", help="branch" - ) - p_update_dev.add_argument( - "--local", default=None, help="local path" - ) + p_update_dev.add_argument("--devbranch", default="master", help="branch") + p_update_dev.add_argument("--local", default=None, help="local path") subparsers.add_parser("updateplotlyjs", help="update plotly.js")