SERVER-123867: Disable Printing out Env Variables in Typer Exception Handler (#51608)

GitOrigin-RevId: 69bf0ec048d1048cdeefc3064570aba68d916aee
This commit is contained in:
Zack Winter 2026-04-10 12:56:08 -07:00 committed by MongoDB Bot
parent e40a87c89e
commit 8ec1538419
24 changed files with 71 additions and 23 deletions

View File

@ -28,5 +28,8 @@ def main(
yaml.dump(content, fh)
app = typer.Typer(pretty_exceptions_show_locals=False)
app.command()(main)
if __name__ == "__main__":
typer.run(main)
app()

View File

@ -62,5 +62,8 @@ def get_current_version():
return data["tool"]["poetry"]["version"]
app = typer.Typer(pretty_exceptions_show_locals=False)
app.command()(main)
if __name__ == "__main__":
typer.run(main)
app()

View File

@ -589,5 +589,8 @@ def main(
json.dump(check_result, f, indent=4)
app = typer.Typer(pretty_exceptions_show_locals=False)
app.command()(main)
if __name__ == "__main__":
typer.run(main)
app()

View File

@ -76,5 +76,8 @@ def main(testlog_dir: str):
print(f"No test.xml found within {testlog_dir}. Not creating a report.")
app = typer.Typer(pretty_exceptions_show_locals=False)
app.command()(main)
if __name__ == "__main__":
typer.run(main)
app()

View File

@ -92,5 +92,8 @@ def main(
write_file(output_file, shrub_project.json())
app = typer.Typer(pretty_exceptions_show_locals=False)
app.command()(main)
if __name__ == "__main__":
typer.run(main)
app()

View File

@ -273,5 +273,8 @@ def main(
print(json_output)
app = typer.Typer(pretty_exceptions_show_locals=False)
app.command()(main)
if __name__ == "__main__":
typer.run(main)
app()

View File

@ -121,5 +121,8 @@ def main(build_events: str = "build_events.json"):
_copy_bins_to_upload(upload_bin_dir, upload_lib_dir)
app = typer.Typer(pretty_exceptions_show_locals=False)
app.command()(main)
if __name__ == "__main__":
typer.run(main)
app()

View File

@ -94,7 +94,7 @@ def write_feature_flags_to_file(flags: list[str], filename: str):
print(f"Generated: {os.path.realpath(output_file.name)}")
cli = typer.Typer()
cli = typer.Typer(pretty_exceptions_show_locals=False)
@cli.command("turned-off-by-default")

View File

@ -202,7 +202,7 @@ if __name__ == "__main__":
import typer
from typing_extensions import Annotated
_app = typer.Typer(add_completion=False)
_app = typer.Typer(add_completion=False, pretty_exceptions_show_locals=False)
@_app.command()
def main(

View File

@ -336,5 +336,8 @@ def main(
orchestrator.evaluate_build_redness(notify)
app = typer.Typer(pretty_exceptions_show_locals=False)
app.command()(main)
if __name__ == "__main__":
typer.run(main)
app()

View File

@ -86,5 +86,8 @@ def main(local_source_directory: str, s3_destination_directory: str) -> None:
)
app = typer.Typer(pretty_exceptions_show_locals=False)
app.command()(main)
if __name__ == "__main__":
typer.run(main)
app()

View File

@ -56,7 +56,7 @@ def acquire_s3_lock(bucket, key, content="locked"):
raise
app = typer.Typer()
app = typer.Typer(pretty_exceptions_show_locals=False)
@app.command()

View File

@ -12,9 +12,11 @@ SCRIPT_PATH = Path(__file__).resolve().parents[2] / "evergreen" / "activate_task
def load_under_test():
fake_app = MagicMock()
fake_typer = types.ModuleType("typer")
fake_typer.Argument = lambda *args, **kwargs: None
fake_typer.run = lambda *args, **kwargs: None
fake_typer.Typer = lambda *args, **kwargs: fake_app
fake_typing_extensions = types.ModuleType("typing_extensions")
fake_typing_extensions.Annotated = Annotated

View File

@ -268,5 +268,8 @@ def main(
return
app = typer.Typer(pretty_exceptions_show_locals=False)
app.command()(main)
if __name__ == "__main__":
typer.run(main)
app()

View File

@ -177,5 +177,8 @@ def main(
sys.exit(exit_code)
app = typer.Typer(pretty_exceptions_show_locals=False)
app.command()(main)
if __name__ == "__main__":
typer.run(main)
app()

View File

@ -60,5 +60,8 @@ def main(
)
app = typer.Typer(pretty_exceptions_show_locals=False)
app.command()(main)
if __name__ == "__main__":
typer.run(main)
app()

View File

@ -8,7 +8,7 @@ from googleapiclient.discovery import build
from googleapiclient.errors import HttpError
from googleapiclient.http import MediaFileUpload
app = typer.Typer(add_completion=False)
app = typer.Typer(add_completion=False, pretty_exceptions_show_locals=False)
@app.command()

View File

@ -10,6 +10,7 @@ from typing_extensions import Annotated
app = typer.Typer(
help="Checks for SBOM file changes in a PR and uploads it to Kondukto if changed.",
add_completion=False,
pretty_exceptions_show_locals=False,
)

View File

@ -95,7 +95,7 @@ def merge_decl(decl: Decl):
or (decl["kind"] == "CLASS_DECL" and old["kind"] == "CLASS_TEMPLATE")
or (decl["kind"] == "CLASS_TEMPLATE" and old["kind"] == "CLASS_DECL")
)
# assert decl["display_name"] == old["display_name"] # TODO ugh sometimes mongo:: screws it up
# assert decl["display_name"] == old["display_name"] # ugh sometimes mongo:: screws it up
class Timer:
@ -295,5 +295,8 @@ def main(
sys.exit(found_violations) # bools are ints, so False(0) is success and True(1) is failure
app = typer.Typer(pretty_exceptions_show_locals=False)
app.command()(main)
if __name__ == "__main__":
typer.run(main)
app()

View File

@ -298,5 +298,8 @@ def main(
print("No _forTest violations found.")
app = typer.Typer(pretty_exceptions_show_locals=False)
app.command()(main)
if __name__ == "__main__":
typer.run(main)
app()

View File

@ -79,5 +79,8 @@ def main(
print("uploaded unowned")
app = typer.Typer(pretty_exceptions_show_locals=False)
app.command()(main)
if __name__ == "__main__":
typer.run(main)
app()

View File

@ -2,7 +2,7 @@ import typer
from tools.flag_sync import flag, namespace
app = typer.Typer()
app = typer.Typer(pretty_exceptions_show_locals=False)
app.add_typer(flag.app, name="flag")
app.add_typer(namespace.app, name="namespace")

View File

@ -7,7 +7,7 @@ import typer
from tools.flag_sync import util
app = typer.Typer()
app = typer.Typer(pretty_exceptions_show_locals=False)
@app.command()

View File

@ -5,7 +5,7 @@ import typer
from tools.flag_sync import util
app = typer.Typer()
app = typer.Typer(pretty_exceptions_show_locals=False)
@app.command()