Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions .jules/bolt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 2025-05-14 - Initial Performance Audit
**Learning:** The project is a small Python template. Major overhead comes from `uv run` and `click` imports.
**Action:** Minimize overhead in CLI entry points and avoid unnecessary imports in hot paths.
14 changes: 8 additions & 6 deletions project/app.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
from click import command, option
from argparse import ArgumentParser


@command(context_settings={"help_option_names": ["-h", "--help"]}, help="Say hello")
@option("-n", "--name", default="World", help="Name", show_default=True)
def main(name: str = "World"):
def main(argv: list[str] | None = None):
"""
Say hello to the given name.

Args:
name: the name to be greeted
argv: list of command line arguments
"""
print(f"Hello {name}!")
parser = ArgumentParser(prog="app", description="Say hello", add_help=False)
parser.add_argument("-n", "--name", default="World", help="Name (default: World)")
parser.add_argument("-h", "--help", action="help", help="Show this message and exit.")
args = parser.parse_args(argv)
print(f"Hello {args.name}!")


if __name__ == "__main__":
Expand Down
4 changes: 1 addition & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ readme = "docs/README.md"
authors = [{name = "Amr Abed", email = "amrabed@gmail.com"}]
license = {text = "MIT"}
requires-python = ">=3.12"
dependencies = [
"click>=8.1.8",
]
dependencies = []

[project.scripts]
app = "project.app:main"
Expand Down
13 changes: 11 additions & 2 deletions tests/test_app.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
from pytest import main
from project.app import main as app_main
from io import StringIO
from contextlib import redirect_stdout


def test_main():
pass
def test_main(monkeypatch):
with redirect_stdout(StringIO()) as out:
app_main(["-n", "Bolt"])
assert out.getvalue().strip() == "Hello Bolt!"

with redirect_stdout(StringIO()) as out:
app_main([])
assert out.getvalue().strip() == "Hello World!"


if __name__ == "__main__":
Expand Down
4 changes: 0 additions & 4 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.