{"record":{"id":"1052272159457922","repo":"kovidgoyal/kitty","slug":"this-should-be-run-as-kitten-show-key","errorCode":null,"errorMessage":"This should be run as kitten show_key","messagePattern":"This should be run as kitten show_key","errorType":"console","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"kittens/show_key/main.py","lineNumber":21,"sourceCode":"\n\nimport sys\n\nOPTIONS = r\"\"\"\n--key-mode -m\ndefault=normal\ntype=choices\nchoices=normal,application,kitty,unchanged\nThe keyboard mode to use when showing keys. :code:`normal` mode is with DECCKM\nreset and :code:`application` mode is with DECCKM set. :code:`kitty` is the full\nkitty extended keyboard protocol.\n\"\"\".format\nhelp_text = 'Show the codes generated by the terminal for key presses in various keyboard modes'\nusage = ''\n\n\ndef main(args: list[str]) -> None:\n    raise SystemExit('This should be run as kitten show_key')\n\n\nif __name__ == '__main__':\n    main(sys.argv)\nelif __name__ == '__doc__':\n    cd = sys.cli_docs  # type: ignore\n    cd['usage'] = usage\n    cd['options'] = OPTIONS\n    cd['help_text'] = help_text\n    cd['short_desc'] = help_text\n","sourceCodeStart":3,"sourceCodeEnd":32,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/kittens/show_key/main.py#L3-L32","documentation":"kitty's show_key kitten is not a standalone program: its main() unconditionally raises SystemExit('This should be run as kitten show_key'). The real implementation is injected by kitty's kitten runner, which runs the file under the '__run_kitten__' run_name and provides the actual entry points; executing the file directly (as __main__) hits the stub.","triggerScenarios":"Running `python kittens/show_key/main.py` directly, importing the module and calling main(args), or executing it via runpy without run_name='__run_kitten__'. Any path where __name__ == '__main__' reaches the stub main().","commonSituations":"Developers exploring the kitty source tree executing kitten files with python; IDE 'Run file' actions; tests importing kitten modules and calling main(); copy-pasting a kitten file out of kitty and running it standalone.","solutions":["Invoke it through kitty: `kitten show_key` (or @ map a shortcut to launch kitten show_key).","If running from source: `kitten --debug-input` style usage or `python -m kitty.main kitten show_key` / `kitten show_key` built from your checkout.","In tests/scripts, import and call the real implementation functions rather than main(); never call the stub main().","If embedding, use kittens.runner.run_kitten('show_key', ...) so the module is executed with the proper run_name."],"exampleFix":"# before\npython kittens/show_key/main.py   # SystemExit: This should be run as kitten show_key\n\n# after\nkitten show_key","handlingStrategy":"validation","validationCode":"import sys\n\ndef run_show_key(args):\n    if sys.__dict__.get('__name__') and __name__ == '__main__':\n        raise SystemExit('use: kitten show_key')\n    # delegate to kitty's launcher instead\n    import subprocess\n    subprocess.run(['kitten', 'show_key', *args], check=True)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never execute kitten files with python directly; always go through the kitty binary.","In test suites, monkeypatch/call the kitten's real implementation functions, not main().","Use `kitten show_key` in keybindings rather than file paths."],"tags":["kitty","kitten","show-key","standalone-execution","system-exit"],"backgroundTag":"must-run-via-parent-runner","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}