Repository navigation
Add cli ai llms-txt, publish /llms.txt, release 0.7.1 #61
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
Changes from all commits
fea5bf2
b69f54b
7e51185
01de87e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -8,6 +8,7 @@ | |||||||||||||
| import typer | ||||||||||||||
|
|
||||||||||||||
| from cliffy.commander import CLI | ||||||||||||||
| from cliffy.manifest import CLIManifest, Command, CommandParam | ||||||||||||||
|
|
||||||||||||||
| GENERATED_FILE = "<generated CLI>" | ||||||||||||||
| FUNCTION_DEFINITION = re.compile(r"(?:async\s+)?def (\w+)\(") | ||||||||||||||
|
|
@@ -73,3 +74,29 @@ def check_generated_code(cli: CLI) -> None: | |||||||||||||
| ] | ||||||||||||||
| line_number = generated_frames[-1].lineno if generated_frames else None | ||||||||||||||
| raise GeneratedCodeError(describe(cli, e, line_number)) from e | ||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
| def ignored_param_settings(manifest: CLIManifest) -> list[str]: | ||||||||||||||
| """Params whose `default` or `help` is dropped because their type is a complete Typer definition.""" | ||||||||||||||
| complete = {name for name, definition in manifest.types.items() if "typer." in definition} | ||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win 🔎 Supported by static analysis🏁 Script executed: git diff cf5ca6f3f48c1f707b76a2fc4c819b315370c024 01de87e20c7806b23cd37e5ff5bdb22f5003129b -- cliffy/parser.py cliffy/checker.pyRepository: jaykv/cliffy Length of output: 2034 🏁 Script executed: set -eu
printf '%s\n' '--- full relevant diff ---'
git diff --unified=80 cf5ca6f3f48c1f707b76a2fc4c819b315370c024 01de87e20c7806b23cd37e5ff5bdb22f5003129b -- cliffy/parser.py cliffy/manifest.py cliffy/checker.py cliffy/cli.py tests || true
printf '%s\n' '--- head parser references ---'
rg -n -C 8 -F -- '"typer."' cliffy/parser.py cliffy/checker.py
printf '%s\n' '--- manifest type contract ---'
rg -n -C 12 -F -- 'types' cliffy/manifest.py
printf '%s\n' '--- parser definition context ---'
sed -n '130,195p' cliffy/parser.py
printf '%s\n' '--- checker callers ---'
rg -n -C 8 -F -- 'ignored_param_settings' cliffyRepository: jaykv/cliffy Length of output: 41838 Handle complete Typer definitions in the parser and checker, arrr. A plain type such as Match only Suggested fixdiff --git a/cliffy/parser.py b/cliffy/parser.py
@@
- if isinstance(param, SimpleCommandParam) and "typer." in param.raw_type:
- # a full typer definition, i.e. `name: str = typer.Option(..., prompt=True)`, is passed through as-is
- return f"{norm_param_name}: {param.raw_type.strip()}, "
+ if isinstance(param, SimpleCommandParam):
+ _, separator, expression = param.raw_type.partition("=")
+ if separator and expression.strip().startswith(("typer.Option(", "typer.Argument(")):
+ # a full typer definition, i.e. `name: str = typer.Option(..., prompt=True)`, is passed through as-is
+ return f"{norm_param_name}: {param.raw_type.strip()}, "
@@
- if "typer." in definition:
+ _, separator, expression = definition.partition("=")
+ if separator and expression.strip().startswith(("typer.Option(", "typer.Argument(")):
# a complete Typer definition replaces everything after the param name
return f"{norm_param_name}: {definition},"
diff --git a/cliffy/checker.py b/cliffy/checker.py
@@
- complete = {name for name, definition in manifest.types.items() if "typer." in definition}
+ complete = set()
+ for name, definition in manifest.types.items():
+ _, separator, expression = definition.partition("=")
+ if separator and expression.strip().startswith(("typer.Option(", "typer.Argument(")):
+ complete.add(name)📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||
| problems = [] | ||||||||||||||
| params = [("global_params", param) for param in manifest.global_params] | ||||||||||||||
| commands = manifest.commands | ||||||||||||||
| if isinstance(commands, list): | ||||||||||||||
| commands = {command.name: command for command in commands} | ||||||||||||||
| # a command can also be a bare run block, which has no params | ||||||||||||||
| params += [ | ||||||||||||||
| (f"command `{name}`", param) | ||||||||||||||
| for name, command in commands.items() | ||||||||||||||
| if isinstance(command, Command) | ||||||||||||||
| for param in command.params | ||||||||||||||
| ] | ||||||||||||||
| for where, param in params: | ||||||||||||||
| if isinstance(param, CommandParam) and param.type in complete: | ||||||||||||||
| ignored = [setting for setting in ("default", "help", "short") if getattr(param, setting)] | ||||||||||||||
| if ignored: | ||||||||||||||
| problems.append( | ||||||||||||||
| f"{where}, param `{param.name}`: `types.{param.type}` is a complete Typer definition, " | ||||||||||||||
| f"so the param's {' and '.join(f'`{setting}`' for setting in ignored)} is ignored" | ||||||||||||||
| ) | ||||||||||||||
| return problems | ||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: jaykv/cliffy
Length of output: 3366
🏁 Script executed:
Repository: jaykv/cliffy
Length of output: 20366
🏁 Script executed:
Repository: jaykv/cliffy
Length of output: 29639
🌐 Web query:
official actions/checkout persist-credentials default documentation v7💡 Result:
Disable credential persistence for the docs checkout, arrr.
The
docsjob runs on pull requests and executes repository-controlled code.actions/checkout@v7persists the read-onlyGITHUB_TOKENby default. Untrusted pull-request code can access that credential from the local Git configuration.Suggested fix
📝 Committable suggestion
🧰 Tools
🪛 zizmor (1.30.1)
[warning] 83-83: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false
(artipacked)
🤖 Prompt for AI Agents