Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(precompiler): give optimize/invalidation_mode flags default values #2180

Merged
merged 2 commits into from
Sep 4, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions tools/precompiler/precompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

def _create_parser() -> "argparse.Namespace":
parser = argparse.ArgumentParser(fromfile_prefix_chars="@")
parser.add_argument("--invalidation_mode")
parser.add_argument("--optimize", type=int)
parser.add_argument("--invalidation_mode", default="TIMESTAMP")
oprypin marked this conversation as resolved.
Show resolved Hide resolved
parser.add_argument("--optimize", type=int, default=-1)
parser.add_argument("--python_version")

parser.add_argument("--src", action="append", dest="srcs")
Expand All @@ -40,15 +40,15 @@ def _create_parser() -> "argparse.Namespace":

def _compile(options: "argparse.Namespace") -> None:
try:
invalidation_mode = getattr(
py_compile.PycInvalidationMode, options.invalidation_mode.upper()
)
except AttributeError as e:
invalidation_mode = py_compile.PycInvalidationMode[
options.invalidation_mode.upper()
]
except KeyError as e:
raise ValueError(
f"Unknown PycInvalidationMode: {options.invalidation_mode}"
) from e

if not (len(options.srcs) == len(options.src_names) == len(options.pycs)):
if len(options.srcs) != len(options.src_names) != len(options.pycs):
oprypin marked this conversation as resolved.
Show resolved Hide resolved
raise AssertionError(
"Mismatched number of --src, --src_name, and/or --pyc args"
)
Expand Down