[{"data":1,"prerenderedAt":3026},["ShallowReactive",2],{"page-\u002Fcli-runtime-systems-integration\u002Fsecrets-and-credentials-in-python-clis\u002Fstoring-tokens-with-keyring\u002F":3,"content-directory":2478},{"id":4,"title":5,"body":6,"date":2464,"description":2465,"difficulty":2466,"draft":2467,"extension":2468,"meta":2469,"navigation":164,"path":2470,"seo":2471,"stem":2472,"tags":2473,"updated":2464,"__hash__":2477},"content\u002Fcli-runtime-systems-integration\u002Fsecrets-and-credentials-in-python-clis\u002Fstoring-tokens-with-keyring\u002Findex.md","Storing CLI Tokens Securely with keyring",{"type":7,"value":8,"toc":2447},"minimark",[9,43,48,72,76,81,85,97,111,115,123,677,1527,1539,1542,1547,1572,1582,1588,1594,1598,1601,1658,1662,1669,2333,2349,2353,2368,2372,2376,2379,2383,2392,2396,2399,2403,2410,2414,2443],[10,11,12,13,17,18,21,22,25,26,29,30,33,34,36,37,42],"p",{},"Your CLI needs an API token on every run, and asking for it every time is not an option. The quick fix is to write it into ",[14,15,16],"code",{},"~\u002F.config\u002Fmytool\u002Fconfig.toml"," — and from that moment the token is in every backup of that directory, in the dotfiles repository the user syncs to GitHub, and in the config they paste into a support ticket. Every major operating system already provides a place designed for exactly this: an encrypted credential store unlocked by the user's login. The ",[14,19,20],{},"keyring"," package gives Python one API over all of them. This guide builds ",[14,23,24],{},"auth login",", ",[14,27,28],{},"auth status"," and ",[14,31,32],{},"auth logout"," commands on ",[14,35,20],{},", handles machines where no keychain exists, and tests it all without touching the real keychain. It is part of the ",[38,39,41],"a",{"href":40},"\u002Fcli-runtime-systems-integration\u002Fsecrets-and-credentials-in-python-clis\u002F","secrets and credentials topic",".",[44,45,47],"h2",{"id":46},"prerequisites","Prerequisites",[49,50,51,62,69],"ul",{},[52,53,54,55,57,58,61],"li",{},"Python 3.10+, ",[14,56,20],{}," 25+ (",[14,59,60],{},"uv add keyring",") and Typer.",[52,63,64,65,42],{},"A token to store — obtained from a web UI, or from a login flow such as the ",[38,66,68],{"href":67},"\u002Fcli-runtime-systems-integration\u002Fcalling-http-apis-from-python-clis\u002Foauth-device-flow-login-for-clis\u002F","OAuth device flow",[52,70,71],{},"On Linux desktops, a Secret Service provider (GNOME Keyring or KWallet), which most desktop distributions run by default.",[44,73,75],{"id":74},"what-keyring-talks-to","What keyring talks to",[10,77,78,80],{},[14,79,20],{}," selects a backend for the current platform automatically:",[82,83],"inline-diagram",{"name":84},"sec-keyring-backends",[10,86,87,88,92,93,96],{},"Each backend stores credentials encrypted at rest, keyed by a ",[89,90,91],"strong",{},"service name"," and a ",[89,94,95],{},"username",". The operating system unlocks the store with the user's login, so there is nothing for your tool to encrypt and no key for it to protect. The value never appears in a file your tool writes.",[10,98,99,100,102,103,106,107,110],{},"The awkward case is the last row. On servers, in containers, in CI, and in WSL without a desktop session, there is often no backend at all. ",[14,101,20],{}," then selects its ",[14,104,105],{},"fail.Keyring"," backend, whose operations raise ",[14,108,109],{},"NoKeyringError",". A CLI must detect that and fall back to something reasonable — usually environment variables — rather than crashing with a traceback.",[44,112,114],{"id":113},"the-recipe","The recipe",[10,116,117,118,122],{},"Keep keychain access in one module. The service name identifies your tool; the \"username\" slot holds the profile name, so each profile gets its own entry (see ",[38,119,121],{"href":120},"\u002Fcli-runtime-systems-integration\u002Fsecrets-and-credentials-in-python-clis\u002Fsupporting-multiple-profiles-and-accounts\u002F","supporting multiple profiles and accounts",").",[124,125,130],"pre",{"className":126,"code":127,"language":128,"meta":129,"style":129},"language-python shiki shiki-themes github-light github-dark","# src\u002Fmytool\u002Ftokenstore.py\nfrom __future__ import annotations\n\nimport keyring\nfrom keyring.backends import fail\nfrom keyring.errors import KeyringError, PasswordDeleteError\n\nSERVICE = \"mytool\"\n\n\nclass StoreUnavailable(Exception):\n    pass\n\n\ndef backend_name() -> str | None:\n    \"\"\"Human-readable backend name, or None when no usable keychain exists.\"\"\"\n    kr = keyring.get_keyring()\n    if isinstance(kr, fail.Keyring):\n        return None\n    return getattr(kr, \"name\", type(kr).__name__)\n\n\ndef save(profile: str, token: str) -> str:\n    name = backend_name()\n    if name is None:\n        raise StoreUnavailable(\"no system keychain is available on this machine\")\n    try:\n        keyring.set_password(SERVICE, profile, token)\n    except KeyringError as exc:\n        raise StoreUnavailable(f\"could not write to {name}: {exc}\") from exc\n    return name\n\n\ndef load(profile: str) -> str | None:\n    if backend_name() is None:\n        return None\n    try:\n        return keyring.get_password(SERVICE, profile)\n    except KeyringError:\n        return None                         # locked or denied: treat as absent\n\n\ndef delete(profile: str) -> bool:\n    try:\n        keyring.delete_password(SERVICE, profile)\n        return True\n    except (PasswordDeleteError, KeyringError):\n        return False\n","python","",[14,131,132,141,159,166,175,188,201,206,219,224,229,248,254,259,264,288,294,306,318,327,356,361,366,391,402,417,431,439,450,465,508,516,521,526,548,562,569,576,589,597,607,612,617,636,643,653,661,669],{"__ignoreMap":129},[133,134,137],"span",{"class":135,"line":136},"line",1,[133,138,140],{"class":139},"sJ8bj","# src\u002Fmytool\u002Ftokenstore.py\n",[133,142,144,148,152,155],{"class":135,"line":143},2,[133,145,147],{"class":146},"szBVR","from",[133,149,151],{"class":150},"sj4cs"," __future__",[133,153,154],{"class":146}," import",[133,156,158],{"class":157},"sVt8B"," annotations\n",[133,160,162],{"class":135,"line":161},3,[133,163,165],{"emptyLinePlaceholder":164},true,"\n",[133,167,169,172],{"class":135,"line":168},4,[133,170,171],{"class":146},"import",[133,173,174],{"class":157}," keyring\n",[133,176,178,180,183,185],{"class":135,"line":177},5,[133,179,147],{"class":146},[133,181,182],{"class":157}," keyring.backends ",[133,184,171],{"class":146},[133,186,187],{"class":157}," fail\n",[133,189,191,193,196,198],{"class":135,"line":190},6,[133,192,147],{"class":146},[133,194,195],{"class":157}," keyring.errors ",[133,197,171],{"class":146},[133,199,200],{"class":157}," KeyringError, PasswordDeleteError\n",[133,202,204],{"class":135,"line":203},7,[133,205,165],{"emptyLinePlaceholder":164},[133,207,209,212,215],{"class":135,"line":208},8,[133,210,211],{"class":150},"SERVICE",[133,213,214],{"class":146}," =",[133,216,218],{"class":217},"sZZnC"," \"mytool\"\n",[133,220,222],{"class":135,"line":221},9,[133,223,165],{"emptyLinePlaceholder":164},[133,225,227],{"class":135,"line":226},10,[133,228,165],{"emptyLinePlaceholder":164},[133,230,232,235,239,242,245],{"class":135,"line":231},11,[133,233,234],{"class":146},"class",[133,236,238],{"class":237},"sScJk"," StoreUnavailable",[133,240,241],{"class":157},"(",[133,243,244],{"class":150},"Exception",[133,246,247],{"class":157},"):\n",[133,249,251],{"class":135,"line":250},12,[133,252,253],{"class":146},"    pass\n",[133,255,257],{"class":135,"line":256},13,[133,258,165],{"emptyLinePlaceholder":164},[133,260,262],{"class":135,"line":261},14,[133,263,165],{"emptyLinePlaceholder":164},[133,265,267,270,273,276,279,282,285],{"class":135,"line":266},15,[133,268,269],{"class":146},"def",[133,271,272],{"class":237}," backend_name",[133,274,275],{"class":157},"() -> ",[133,277,278],{"class":150},"str",[133,280,281],{"class":146}," |",[133,283,284],{"class":150}," None",[133,286,287],{"class":157},":\n",[133,289,291],{"class":135,"line":290},16,[133,292,293],{"class":217},"    \"\"\"Human-readable backend name, or None when no usable keychain exists.\"\"\"\n",[133,295,297,300,303],{"class":135,"line":296},17,[133,298,299],{"class":157},"    kr ",[133,301,302],{"class":146},"=",[133,304,305],{"class":157}," keyring.get_keyring()\n",[133,307,309,312,315],{"class":135,"line":308},18,[133,310,311],{"class":146},"    if",[133,313,314],{"class":150}," isinstance",[133,316,317],{"class":157},"(kr, fail.Keyring):\n",[133,319,321,324],{"class":135,"line":320},19,[133,322,323],{"class":146},"        return",[133,325,326],{"class":150}," None\n",[133,328,330,333,336,339,342,344,347,350,353],{"class":135,"line":329},20,[133,331,332],{"class":146},"    return",[133,334,335],{"class":150}," getattr",[133,337,338],{"class":157},"(kr, ",[133,340,341],{"class":217},"\"name\"",[133,343,25],{"class":157},[133,345,346],{"class":150},"type",[133,348,349],{"class":157},"(kr).",[133,351,352],{"class":150},"__name__",[133,354,355],{"class":157},")\n",[133,357,359],{"class":135,"line":358},21,[133,360,165],{"emptyLinePlaceholder":164},[133,362,364],{"class":135,"line":363},22,[133,365,165],{"emptyLinePlaceholder":164},[133,367,369,371,374,377,379,382,384,387,389],{"class":135,"line":368},23,[133,370,269],{"class":146},[133,372,373],{"class":237}," save",[133,375,376],{"class":157},"(profile: ",[133,378,278],{"class":150},[133,380,381],{"class":157},", token: ",[133,383,278],{"class":150},[133,385,386],{"class":157},") -> ",[133,388,278],{"class":150},[133,390,287],{"class":157},[133,392,394,397,399],{"class":135,"line":393},24,[133,395,396],{"class":157},"    name ",[133,398,302],{"class":146},[133,400,401],{"class":157}," backend_name()\n",[133,403,405,407,410,413,415],{"class":135,"line":404},25,[133,406,311],{"class":146},[133,408,409],{"class":157}," name ",[133,411,412],{"class":146},"is",[133,414,284],{"class":150},[133,416,287],{"class":157},[133,418,420,423,426,429],{"class":135,"line":419},26,[133,421,422],{"class":146},"        raise",[133,424,425],{"class":157}," StoreUnavailable(",[133,427,428],{"class":217},"\"no system keychain is available on this machine\"",[133,430,355],{"class":157},[133,432,434,437],{"class":135,"line":433},27,[133,435,436],{"class":146},"    try",[133,438,287],{"class":157},[133,440,442,445,447],{"class":135,"line":441},28,[133,443,444],{"class":157},"        keyring.set_password(",[133,446,211],{"class":150},[133,448,449],{"class":157},", profile, token)\n",[133,451,453,456,459,462],{"class":135,"line":452},29,[133,454,455],{"class":146},"    except",[133,457,458],{"class":157}," KeyringError ",[133,460,461],{"class":146},"as",[133,463,464],{"class":157}," exc:\n",[133,466,468,470,472,475,478,481,484,487,490,492,495,497,500,503,505],{"class":135,"line":467},30,[133,469,422],{"class":146},[133,471,425],{"class":157},[133,473,474],{"class":146},"f",[133,476,477],{"class":217},"\"could not write to ",[133,479,480],{"class":150},"{",[133,482,483],{"class":157},"name",[133,485,486],{"class":150},"}",[133,488,489],{"class":217},": ",[133,491,480],{"class":150},[133,493,494],{"class":157},"exc",[133,496,486],{"class":150},[133,498,499],{"class":217},"\"",[133,501,502],{"class":157},") ",[133,504,147],{"class":146},[133,506,507],{"class":157}," exc\n",[133,509,511,513],{"class":135,"line":510},31,[133,512,332],{"class":146},[133,514,515],{"class":157}," name\n",[133,517,519],{"class":135,"line":518},32,[133,520,165],{"emptyLinePlaceholder":164},[133,522,524],{"class":135,"line":523},33,[133,525,165],{"emptyLinePlaceholder":164},[133,527,529,531,534,536,538,540,542,544,546],{"class":135,"line":528},34,[133,530,269],{"class":146},[133,532,533],{"class":237}," load",[133,535,376],{"class":157},[133,537,278],{"class":150},[133,539,386],{"class":157},[133,541,278],{"class":150},[133,543,281],{"class":146},[133,545,284],{"class":150},[133,547,287],{"class":157},[133,549,551,553,556,558,560],{"class":135,"line":550},35,[133,552,311],{"class":146},[133,554,555],{"class":157}," backend_name() ",[133,557,412],{"class":146},[133,559,284],{"class":150},[133,561,287],{"class":157},[133,563,565,567],{"class":135,"line":564},36,[133,566,323],{"class":146},[133,568,326],{"class":150},[133,570,572,574],{"class":135,"line":571},37,[133,573,436],{"class":146},[133,575,287],{"class":157},[133,577,579,581,584,586],{"class":135,"line":578},38,[133,580,323],{"class":146},[133,582,583],{"class":157}," keyring.get_password(",[133,585,211],{"class":150},[133,587,588],{"class":157},", profile)\n",[133,590,592,594],{"class":135,"line":591},39,[133,593,455],{"class":146},[133,595,596],{"class":157}," KeyringError:\n",[133,598,600,602,604],{"class":135,"line":599},40,[133,601,323],{"class":146},[133,603,284],{"class":150},[133,605,606],{"class":139},"                         # locked or denied: treat as absent\n",[133,608,610],{"class":135,"line":609},41,[133,611,165],{"emptyLinePlaceholder":164},[133,613,615],{"class":135,"line":614},42,[133,616,165],{"emptyLinePlaceholder":164},[133,618,620,622,625,627,629,631,634],{"class":135,"line":619},43,[133,621,269],{"class":146},[133,623,624],{"class":237}," delete",[133,626,376],{"class":157},[133,628,278],{"class":150},[133,630,386],{"class":157},[133,632,633],{"class":150},"bool",[133,635,287],{"class":157},[133,637,639,641],{"class":135,"line":638},44,[133,640,436],{"class":146},[133,642,287],{"class":157},[133,644,646,649,651],{"class":135,"line":645},45,[133,647,648],{"class":157},"        keyring.delete_password(",[133,650,211],{"class":150},[133,652,588],{"class":157},[133,654,656,658],{"class":135,"line":655},46,[133,657,323],{"class":146},[133,659,660],{"class":150}," True\n",[133,662,664,666],{"class":135,"line":663},47,[133,665,455],{"class":146},[133,667,668],{"class":157}," (PasswordDeleteError, KeyringError):\n",[133,670,672,674],{"class":135,"line":671},48,[133,673,323],{"class":146},[133,675,676],{"class":150}," False\n",[124,678,680],{"className":126,"code":679,"language":128,"meta":129,"style":129},"# src\u002Fmytool\u002Fauth.py\nimport os\nimport sys\n\nimport typer\n\nfrom mytool import tokenstore\n\nauth = typer.Typer(help=\"Manage stored credentials.\")\n\n\ndef _tail(token: str) -> str:\n    return f\"...{token[-4:]}\" if len(token) >= 12 else \"(short token)\"\n\n\n@auth.command()\ndef login(\n    profile: str = typer.Option(\"default\", \"--profile\", \"-p\"),\n    token_stdin: bool = typer.Option(False, \"--token-stdin\", help=\"Read the token from stdin.\"),\n) -> None:\n    \"\"\"Store an API token in the system keychain.\"\"\"\n    if token_stdin:\n        token = sys.stdin.read().strip()\n    elif sys.stdin.isatty():\n        token = typer.prompt(\"API token\", hide_input=True, err=True).strip()\n    else:\n        typer.echo(\"error: no terminal to prompt on; use --token-stdin\", err=True)\n        raise typer.Exit(2)\n    if not token:\n        typer.echo(\"error: empty token\", err=True)\n        raise typer.Exit(2)\n    try:\n        where = tokenstore.save(profile, token)\n    except tokenstore.StoreUnavailable as exc:\n        typer.echo(f\"error: {exc}\", err=True)\n        typer.echo(\"hint: set MYTOOL_TOKEN or MYTOOL_TOKEN_FILE instead\", err=True)\n        raise typer.Exit(1)\n    typer.echo(f\"stored token for profile {profile!r} in {where}\", err=True)\n\n\n@auth.command()\ndef status(profile: str = typer.Option(\"default\", \"--profile\", \"-p\")) -> None:\n    \"\"\"Show which credential would be used, without revealing it.\"\"\"\n    if os.environ.get(\"MYTOOL_TOKEN\"):\n        typer.echo(f\"profile {profile!r}: token from MYTOOL_TOKEN ({_tail(os.environ['MYTOOL_TOKEN'])})\")\n        return\n    token = tokenstore.load(profile)\n    backend = tokenstore.backend_name() or \"no keychain available\"\n    if token:\n        typer.echo(f\"profile {profile!r}: token from {backend} ({_tail(token)})\")\n    else:\n        typer.echo(f\"profile {profile!r}: not logged in ({backend})\")\n        raise typer.Exit(1)\n\n\n@auth.command()\ndef logout(profile: str = typer.Option(\"default\", \"--profile\", \"-p\")) -> None:\n    \"\"\"Remove the stored token.\"\"\"\n    removed = tokenstore.delete(profile)\n    typer.echo(f\"{'removed' if removed else 'no stored'} token for profile {profile!r}\", err=True)\n",[14,681,682,687,694,701,705,712,716,728,732,753,757,761,779,828,832,836,844,854,882,912,921,926,933,943,951,985,992,1010,1022,1032,1049,1059,1065,1075,1086,1113,1130,1141,1183,1187,1191,1197,1229,1234,1246,1284,1289,1299,1315,1322,1363,1370,1400,1411,1416,1421,1428,1460,1466,1477],{"__ignoreMap":129},[133,683,684],{"class":135,"line":136},[133,685,686],{"class":139},"# src\u002Fmytool\u002Fauth.py\n",[133,688,689,691],{"class":135,"line":143},[133,690,171],{"class":146},[133,692,693],{"class":157}," os\n",[133,695,696,698],{"class":135,"line":161},[133,697,171],{"class":146},[133,699,700],{"class":157}," sys\n",[133,702,703],{"class":135,"line":168},[133,704,165],{"emptyLinePlaceholder":164},[133,706,707,709],{"class":135,"line":177},[133,708,171],{"class":146},[133,710,711],{"class":157}," typer\n",[133,713,714],{"class":135,"line":190},[133,715,165],{"emptyLinePlaceholder":164},[133,717,718,720,723,725],{"class":135,"line":203},[133,719,147],{"class":146},[133,721,722],{"class":157}," mytool ",[133,724,171],{"class":146},[133,726,727],{"class":157}," tokenstore\n",[133,729,730],{"class":135,"line":208},[133,731,165],{"emptyLinePlaceholder":164},[133,733,734,737,739,742,746,748,751],{"class":135,"line":221},[133,735,736],{"class":157},"auth ",[133,738,302],{"class":146},[133,740,741],{"class":157}," typer.Typer(",[133,743,745],{"class":744},"s4XuR","help",[133,747,302],{"class":146},[133,749,750],{"class":217},"\"Manage stored credentials.\"",[133,752,355],{"class":157},[133,754,755],{"class":135,"line":226},[133,756,165],{"emptyLinePlaceholder":164},[133,758,759],{"class":135,"line":231},[133,760,165],{"emptyLinePlaceholder":164},[133,762,763,765,768,771,773,775,777],{"class":135,"line":250},[133,764,269],{"class":146},[133,766,767],{"class":237}," _tail",[133,769,770],{"class":157},"(token: ",[133,772,278],{"class":150},[133,774,386],{"class":157},[133,776,278],{"class":150},[133,778,287],{"class":157},[133,780,781,783,786,789,791,794,797,800,803,805,807,810,813,816,819,822,825],{"class":135,"line":256},[133,782,332],{"class":146},[133,784,785],{"class":146}," f",[133,787,788],{"class":217},"\"...",[133,790,480],{"class":150},[133,792,793],{"class":157},"token[",[133,795,796],{"class":146},"-",[133,798,799],{"class":150},"4",[133,801,802],{"class":157},":]",[133,804,486],{"class":150},[133,806,499],{"class":217},[133,808,809],{"class":146}," if",[133,811,812],{"class":150}," len",[133,814,815],{"class":157},"(token) ",[133,817,818],{"class":146},">=",[133,820,821],{"class":150}," 12",[133,823,824],{"class":146}," else",[133,826,827],{"class":217}," \"(short token)\"\n",[133,829,830],{"class":135,"line":261},[133,831,165],{"emptyLinePlaceholder":164},[133,833,834],{"class":135,"line":266},[133,835,165],{"emptyLinePlaceholder":164},[133,837,838,841],{"class":135,"line":290},[133,839,840],{"class":237},"@auth.command",[133,842,843],{"class":157},"()\n",[133,845,846,848,851],{"class":135,"line":296},[133,847,269],{"class":146},[133,849,850],{"class":237}," login",[133,852,853],{"class":157},"(\n",[133,855,856,859,861,863,866,869,871,874,876,879],{"class":135,"line":308},[133,857,858],{"class":157},"    profile: ",[133,860,278],{"class":150},[133,862,214],{"class":146},[133,864,865],{"class":157}," typer.Option(",[133,867,868],{"class":217},"\"default\"",[133,870,25],{"class":157},[133,872,873],{"class":217},"\"--profile\"",[133,875,25],{"class":157},[133,877,878],{"class":217},"\"-p\"",[133,880,881],{"class":157},"),\n",[133,883,884,887,889,891,893,896,898,901,903,905,907,910],{"class":135,"line":320},[133,885,886],{"class":157},"    token_stdin: ",[133,888,633],{"class":150},[133,890,214],{"class":146},[133,892,865],{"class":157},[133,894,895],{"class":150},"False",[133,897,25],{"class":157},[133,899,900],{"class":217},"\"--token-stdin\"",[133,902,25],{"class":157},[133,904,745],{"class":744},[133,906,302],{"class":146},[133,908,909],{"class":217},"\"Read the token from stdin.\"",[133,911,881],{"class":157},[133,913,914,916,919],{"class":135,"line":329},[133,915,386],{"class":157},[133,917,918],{"class":150},"None",[133,920,287],{"class":157},[133,922,923],{"class":135,"line":358},[133,924,925],{"class":217},"    \"\"\"Store an API token in the system keychain.\"\"\"\n",[133,927,928,930],{"class":135,"line":363},[133,929,311],{"class":146},[133,931,932],{"class":157}," token_stdin:\n",[133,934,935,938,940],{"class":135,"line":368},[133,936,937],{"class":157},"        token ",[133,939,302],{"class":146},[133,941,942],{"class":157}," sys.stdin.read().strip()\n",[133,944,945,948],{"class":135,"line":393},[133,946,947],{"class":146},"    elif",[133,949,950],{"class":157}," sys.stdin.isatty():\n",[133,952,953,955,957,960,963,965,968,970,973,975,978,980,982],{"class":135,"line":404},[133,954,937],{"class":157},[133,956,302],{"class":146},[133,958,959],{"class":157}," typer.prompt(",[133,961,962],{"class":217},"\"API token\"",[133,964,25],{"class":157},[133,966,967],{"class":744},"hide_input",[133,969,302],{"class":146},[133,971,972],{"class":150},"True",[133,974,25],{"class":157},[133,976,977],{"class":744},"err",[133,979,302],{"class":146},[133,981,972],{"class":150},[133,983,984],{"class":157},").strip()\n",[133,986,987,990],{"class":135,"line":419},[133,988,989],{"class":146},"    else",[133,991,287],{"class":157},[133,993,994,997,1000,1002,1004,1006,1008],{"class":135,"line":433},[133,995,996],{"class":157},"        typer.echo(",[133,998,999],{"class":217},"\"error: no terminal to prompt on; use --token-stdin\"",[133,1001,25],{"class":157},[133,1003,977],{"class":744},[133,1005,302],{"class":146},[133,1007,972],{"class":150},[133,1009,355],{"class":157},[133,1011,1012,1014,1017,1020],{"class":135,"line":441},[133,1013,422],{"class":146},[133,1015,1016],{"class":157}," typer.Exit(",[133,1018,1019],{"class":150},"2",[133,1021,355],{"class":157},[133,1023,1024,1026,1029],{"class":135,"line":452},[133,1025,311],{"class":146},[133,1027,1028],{"class":146}," not",[133,1030,1031],{"class":157}," token:\n",[133,1033,1034,1036,1039,1041,1043,1045,1047],{"class":135,"line":467},[133,1035,996],{"class":157},[133,1037,1038],{"class":217},"\"error: empty token\"",[133,1040,25],{"class":157},[133,1042,977],{"class":744},[133,1044,302],{"class":146},[133,1046,972],{"class":150},[133,1048,355],{"class":157},[133,1050,1051,1053,1055,1057],{"class":135,"line":510},[133,1052,422],{"class":146},[133,1054,1016],{"class":157},[133,1056,1019],{"class":150},[133,1058,355],{"class":157},[133,1060,1061,1063],{"class":135,"line":518},[133,1062,436],{"class":146},[133,1064,287],{"class":157},[133,1066,1067,1070,1072],{"class":135,"line":523},[133,1068,1069],{"class":157},"        where ",[133,1071,302],{"class":146},[133,1073,1074],{"class":157}," tokenstore.save(profile, token)\n",[133,1076,1077,1079,1082,1084],{"class":135,"line":528},[133,1078,455],{"class":146},[133,1080,1081],{"class":157}," tokenstore.StoreUnavailable ",[133,1083,461],{"class":146},[133,1085,464],{"class":157},[133,1087,1088,1090,1092,1095,1097,1099,1101,1103,1105,1107,1109,1111],{"class":135,"line":550},[133,1089,996],{"class":157},[133,1091,474],{"class":146},[133,1093,1094],{"class":217},"\"error: ",[133,1096,480],{"class":150},[133,1098,494],{"class":157},[133,1100,486],{"class":150},[133,1102,499],{"class":217},[133,1104,25],{"class":157},[133,1106,977],{"class":744},[133,1108,302],{"class":146},[133,1110,972],{"class":150},[133,1112,355],{"class":157},[133,1114,1115,1117,1120,1122,1124,1126,1128],{"class":135,"line":564},[133,1116,996],{"class":157},[133,1118,1119],{"class":217},"\"hint: set MYTOOL_TOKEN or MYTOOL_TOKEN_FILE instead\"",[133,1121,25],{"class":157},[133,1123,977],{"class":744},[133,1125,302],{"class":146},[133,1127,972],{"class":150},[133,1129,355],{"class":157},[133,1131,1132,1134,1136,1139],{"class":135,"line":571},[133,1133,422],{"class":146},[133,1135,1016],{"class":157},[133,1137,1138],{"class":150},"1",[133,1140,355],{"class":157},[133,1142,1143,1146,1148,1151,1153,1156,1159,1161,1164,1166,1169,1171,1173,1175,1177,1179,1181],{"class":135,"line":578},[133,1144,1145],{"class":157},"    typer.echo(",[133,1147,474],{"class":146},[133,1149,1150],{"class":217},"\"stored token for profile ",[133,1152,480],{"class":150},[133,1154,1155],{"class":157},"profile",[133,1157,1158],{"class":146},"!r",[133,1160,486],{"class":150},[133,1162,1163],{"class":217}," in ",[133,1165,480],{"class":150},[133,1167,1168],{"class":157},"where",[133,1170,486],{"class":150},[133,1172,499],{"class":217},[133,1174,25],{"class":157},[133,1176,977],{"class":744},[133,1178,302],{"class":146},[133,1180,972],{"class":150},[133,1182,355],{"class":157},[133,1184,1185],{"class":135,"line":591},[133,1186,165],{"emptyLinePlaceholder":164},[133,1188,1189],{"class":135,"line":599},[133,1190,165],{"emptyLinePlaceholder":164},[133,1192,1193,1195],{"class":135,"line":609},[133,1194,840],{"class":237},[133,1196,843],{"class":157},[133,1198,1199,1201,1204,1206,1208,1210,1212,1214,1216,1218,1220,1222,1225,1227],{"class":135,"line":614},[133,1200,269],{"class":146},[133,1202,1203],{"class":237}," status",[133,1205,376],{"class":157},[133,1207,278],{"class":150},[133,1209,214],{"class":146},[133,1211,865],{"class":157},[133,1213,868],{"class":217},[133,1215,25],{"class":157},[133,1217,873],{"class":217},[133,1219,25],{"class":157},[133,1221,878],{"class":217},[133,1223,1224],{"class":157},")) -> ",[133,1226,918],{"class":150},[133,1228,287],{"class":157},[133,1230,1231],{"class":135,"line":619},[133,1232,1233],{"class":217},"    \"\"\"Show which credential would be used, without revealing it.\"\"\"\n",[133,1235,1236,1238,1241,1244],{"class":135,"line":638},[133,1237,311],{"class":146},[133,1239,1240],{"class":157}," os.environ.get(",[133,1242,1243],{"class":217},"\"MYTOOL_TOKEN\"",[133,1245,247],{"class":157},[133,1247,1248,1250,1252,1255,1257,1259,1261,1263,1266,1268,1271,1274,1277,1279,1282],{"class":135,"line":645},[133,1249,996],{"class":157},[133,1251,474],{"class":146},[133,1253,1254],{"class":217},"\"profile ",[133,1256,480],{"class":150},[133,1258,1155],{"class":157},[133,1260,1158],{"class":146},[133,1262,486],{"class":150},[133,1264,1265],{"class":217},": token from MYTOOL_TOKEN (",[133,1267,480],{"class":150},[133,1269,1270],{"class":157},"_tail(os.environ[",[133,1272,1273],{"class":217},"'MYTOOL_TOKEN'",[133,1275,1276],{"class":157},"])",[133,1278,486],{"class":150},[133,1280,1281],{"class":217},")\"",[133,1283,355],{"class":157},[133,1285,1286],{"class":135,"line":655},[133,1287,1288],{"class":146},"        return\n",[133,1290,1291,1294,1296],{"class":135,"line":663},[133,1292,1293],{"class":157},"    token ",[133,1295,302],{"class":146},[133,1297,1298],{"class":157}," tokenstore.load(profile)\n",[133,1300,1301,1304,1306,1309,1312],{"class":135,"line":671},[133,1302,1303],{"class":157},"    backend ",[133,1305,302],{"class":146},[133,1307,1308],{"class":157}," tokenstore.backend_name() ",[133,1310,1311],{"class":146},"or",[133,1313,1314],{"class":217}," \"no keychain available\"\n",[133,1316,1318,1320],{"class":135,"line":1317},49,[133,1319,311],{"class":146},[133,1321,1031],{"class":157},[133,1323,1325,1327,1329,1331,1333,1335,1337,1339,1342,1344,1347,1349,1352,1354,1357,1359,1361],{"class":135,"line":1324},50,[133,1326,996],{"class":157},[133,1328,474],{"class":146},[133,1330,1254],{"class":217},[133,1332,480],{"class":150},[133,1334,1155],{"class":157},[133,1336,1158],{"class":146},[133,1338,486],{"class":150},[133,1340,1341],{"class":217},": token from ",[133,1343,480],{"class":150},[133,1345,1346],{"class":157},"backend",[133,1348,486],{"class":150},[133,1350,1351],{"class":217}," (",[133,1353,480],{"class":150},[133,1355,1356],{"class":157},"_tail(token)",[133,1358,486],{"class":150},[133,1360,1281],{"class":217},[133,1362,355],{"class":157},[133,1364,1366,1368],{"class":135,"line":1365},51,[133,1367,989],{"class":146},[133,1369,287],{"class":157},[133,1371,1373,1375,1377,1379,1381,1383,1385,1387,1390,1392,1394,1396,1398],{"class":135,"line":1372},52,[133,1374,996],{"class":157},[133,1376,474],{"class":146},[133,1378,1254],{"class":217},[133,1380,480],{"class":150},[133,1382,1155],{"class":157},[133,1384,1158],{"class":146},[133,1386,486],{"class":150},[133,1388,1389],{"class":217},": not logged in (",[133,1391,480],{"class":150},[133,1393,1346],{"class":157},[133,1395,486],{"class":150},[133,1397,1281],{"class":217},[133,1399,355],{"class":157},[133,1401,1403,1405,1407,1409],{"class":135,"line":1402},53,[133,1404,422],{"class":146},[133,1406,1016],{"class":157},[133,1408,1138],{"class":150},[133,1410,355],{"class":157},[133,1412,1414],{"class":135,"line":1413},54,[133,1415,165],{"emptyLinePlaceholder":164},[133,1417,1419],{"class":135,"line":1418},55,[133,1420,165],{"emptyLinePlaceholder":164},[133,1422,1424,1426],{"class":135,"line":1423},56,[133,1425,840],{"class":237},[133,1427,843],{"class":157},[133,1429,1431,1433,1436,1438,1440,1442,1444,1446,1448,1450,1452,1454,1456,1458],{"class":135,"line":1430},57,[133,1432,269],{"class":146},[133,1434,1435],{"class":237}," logout",[133,1437,376],{"class":157},[133,1439,278],{"class":150},[133,1441,214],{"class":146},[133,1443,865],{"class":157},[133,1445,868],{"class":217},[133,1447,25],{"class":157},[133,1449,873],{"class":217},[133,1451,25],{"class":157},[133,1453,878],{"class":217},[133,1455,1224],{"class":157},[133,1457,918],{"class":150},[133,1459,287],{"class":157},[133,1461,1463],{"class":135,"line":1462},58,[133,1464,1465],{"class":217},"    \"\"\"Remove the stored token.\"\"\"\n",[133,1467,1469,1472,1474],{"class":135,"line":1468},59,[133,1470,1471],{"class":157},"    removed ",[133,1473,302],{"class":146},[133,1475,1476],{"class":157}," tokenstore.delete(profile)\n",[133,1478,1480,1482,1484,1486,1488,1491,1493,1496,1499,1502,1504,1507,1509,1511,1513,1515,1517,1519,1521,1523,1525],{"class":135,"line":1479},60,[133,1481,1145],{"class":157},[133,1483,474],{"class":146},[133,1485,499],{"class":217},[133,1487,480],{"class":150},[133,1489,1490],{"class":217},"'removed'",[133,1492,809],{"class":146},[133,1494,1495],{"class":157}," removed ",[133,1497,1498],{"class":146},"else",[133,1500,1501],{"class":217}," 'no stored'",[133,1503,486],{"class":150},[133,1505,1506],{"class":217}," token for profile ",[133,1508,480],{"class":150},[133,1510,1155],{"class":157},[133,1512,1158],{"class":146},[133,1514,486],{"class":150},[133,1516,499],{"class":217},[133,1518,25],{"class":157},[133,1520,977],{"class":744},[133,1522,302],{"class":146},[133,1524,972],{"class":150},[133,1526,355],{"class":157},[10,1528,1529,1530,1533,1534,1538],{},"Mount the sub-app in your main CLI with ",[14,1531,1532],{},"app.add_typer(auth, name=\"auth\")",", the pattern described in ",[38,1535,1537],{"href":1536},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftyper-vs-click-when-to-use-each\u002Fbuilding-a-cli-with-subcommands-in-click\u002F","building a CLI with subcommands in Click"," and its Typer equivalents.",[82,1540],{"name":1541},"sec-keyring-flow",[1543,1544,1546],"h3",{"id":1545},"design-notes","Design notes",[10,1548,1549,1552,1553,1556,1557,1560,1561,1564,1565,1568,1569,42],{},[89,1550,1551],{},"The token never touches argv."," ",[14,1554,1555],{},"login"," reads from a hidden prompt or from stdin; there is deliberately no ",[14,1558,1559],{},"--token VALUE"," option. ",[14,1562,1563],{},"--token-stdin"," lets scripts and password managers pipe a token in (",[14,1566,1567],{},"op read op:\u002F\u002Fvault\u002Fapi\u002Ftoken | mytool auth login --token-stdin",") without it appearing in the process list — the same design as ",[14,1570,1571],{},"docker login --password-stdin",[10,1573,1574,1577,1578,1581],{},[89,1575,1576],{},"Status shows a tail, not the token."," The last four characters are enough to tell two tokens apart and not enough to use one. Reporting ",[1579,1580,1168],"em",{}," the token came from — keychain or environment — resolves most \"why is it using the wrong account?\" questions.",[10,1583,1584,1587],{},[89,1585,1586],{},"Locked keychains are \"absent\", not errors."," On macOS the user may deny access; on Linux the collection may be locked and the unlock dialog dismissed. Treating that as \"no token\" lets the normal fallback and error messages take over.",[10,1589,1590,1593],{},[89,1591,1592],{},"Reads can prompt."," The first time a new binary reads a Keychain item on macOS, the user may be asked to allow access. That is a feature — the operating system is protecting the item — but it means reads can block on user interaction. Never read the keychain in non-interactive contexts where an environment variable would do.",[44,1595,1597],{"id":1596},"ux-considerations","UX considerations",[82,1599],{"name":1600},"sec-keyring-terminal",[49,1602,1603,1615,1628,1638,1644],{},[52,1604,1605,1608,1609,1612,1613,42],{},[89,1606,1607],{},"Environment beats keychain."," For CI and one-off overrides, ",[14,1610,1611],{},"MYTOOL_TOKEN"," should win over the stored token. Make the precedence visible in ",[14,1614,28],{},[52,1616,1617,1620,1621,1623,1624,42],{},[89,1618,1619],{},"Fail helpfully on headless machines."," \"no system keychain is available on this machine — set MYTOOL_TOKEN or MYTOOL_TOKEN_FILE instead\" is actionable; a ",[14,1622,109],{}," traceback is not. Guidance on the environment route is in ",[38,1625,1627],{"href":1626},"\u002Fcli-runtime-systems-integration\u002Fsecrets-and-credentials-in-python-clis\u002Freading-secrets-from-env-and-files\u002F","reading secrets from env and files",[52,1629,1630,1633,1634,1637],{},[89,1631,1632],{},"Do not silently fall back to plain-text files."," The ",[14,1635,1636],{},"keyrings.alt"," package offers file-based backends, some with weak or no encryption. If you offer one, make it an explicit opt-in and say what it does and does not protect.",[52,1639,1640,1643],{},[89,1641,1642],{},"Make logout complete."," Remove the keychain entry, and if the API supports token revocation, revoke it server-side too, so a copy that leaked elsewhere stops working.",[52,1645,1646,1649,1650,1653,1654,1657],{},[89,1647,1648],{},"Name the service after the tool."," Users see the service name in Keychain Access or Credential Manager; ",[14,1651,1652],{},"mytool"," is recognisable, ",[14,1655,1656],{},"python-keyring-default"," is not.",[44,1659,1661],{"id":1660},"testing-the-behaviour","Testing the behaviour",[10,1663,1664,1665,1668],{},"Never let tests touch the developer's real keychain. ",[14,1666,1667],{},"keyring.set_keyring()"," installs any backend object, so an in-memory backend in a fixture isolates every test:",[124,1670,1672],{"className":126,"code":1671,"language":128,"meta":129,"style":129},"# tests\u002Ftest_auth.py\nimport keyring\nimport pytest\nfrom keyring.backend import KeyringBackend\nfrom keyring.backends import fail\nfrom typer.testing import CliRunner\n\nfrom mytool.auth import auth\n\nrunner = CliRunner()\n\n\nclass MemoryKeyring(KeyringBackend):\n    priority = 1\n    name = \"memory\"\n\n    def __init__(self):\n        self.data = {}\n\n    def get_password(self, service, username):\n        return self.data.get((service, username))\n\n    def set_password(self, service, username, password):\n        self.data[(service, username)] = password\n\n    def delete_password(self, service, username):\n        if (service, username) not in self.data:\n            raise keyring.errors.PasswordDeleteError(\"missing\")\n        del self.data[(service, username)]\n\n\n@pytest.fixture\ndef kr(monkeypatch):\n    monkeypatch.delenv(\"MYTOOL_TOKEN\", raising=False)\n    backend = MemoryKeyring()\n    keyring.set_keyring(backend)\n    return backend\n\n\ndef test_login_status_logout(kr):\n    token = \"tok_1234567890abcdef\"\n    assert runner.invoke(auth, [\"login\", \"--token-stdin\"], input=token + \"\\n\").exit_code == 0\n    assert kr.data[(\"mytool\", \"default\")] == token\n\n    result = runner.invoke(auth, [\"status\"])\n    assert result.exit_code == 0\n    assert \"...cdef\" in result.output and token not in result.output\n\n    assert runner.invoke(auth, [\"logout\"]).exit_code == 0\n    assert runner.invoke(auth, [\"status\"]).exit_code == 1\n\n\ndef test_env_overrides_keychain(kr, monkeypatch):\n    kr.set_password(\"mytool\", \"default\", \"tok_from_keychain_0000\")\n    monkeypatch.setenv(\"MYTOOL_TOKEN\", \"tok_from_env_99999999\")\n    assert \"MYTOOL_TOKEN\" in runner.invoke(auth, [\"status\"]).output\n\n\ndef test_no_backend_is_explained(monkeypatch):\n    monkeypatch.delenv(\"MYTOOL_TOKEN\", raising=False)\n    keyring.set_keyring(fail.Keyring())\n    result = runner.invoke(auth, [\"login\", \"--token-stdin\"], input=\"tok_abcdefghijklmnop\\n\")\n    assert result.exit_code == 1\n    assert \"MYTOOL_TOKEN\" in result.output\n",[14,1673,1674,1679,1685,1692,1704,1714,1726,1730,1742,1746,1756,1760,1764,1778,1788,1797,1801,1812,1825,1829,1839,1849,1853,1863,1875,1879,1888,1907,1920,1930,1934,1938,1943,1953,1971,1980,1985,1992,1996,2000,2010,2019,2065,2087,2091,2106,2117,2142,2146,2162,2176,2180,2184,2194,2212,2226,2242,2246,2250,2259,2275,2281,2311,2322],{"__ignoreMap":129},[133,1675,1676],{"class":135,"line":136},[133,1677,1678],{"class":139},"# tests\u002Ftest_auth.py\n",[133,1680,1681,1683],{"class":135,"line":143},[133,1682,171],{"class":146},[133,1684,174],{"class":157},[133,1686,1687,1689],{"class":135,"line":161},[133,1688,171],{"class":146},[133,1690,1691],{"class":157}," pytest\n",[133,1693,1694,1696,1699,1701],{"class":135,"line":168},[133,1695,147],{"class":146},[133,1697,1698],{"class":157}," keyring.backend ",[133,1700,171],{"class":146},[133,1702,1703],{"class":157}," KeyringBackend\n",[133,1705,1706,1708,1710,1712],{"class":135,"line":177},[133,1707,147],{"class":146},[133,1709,182],{"class":157},[133,1711,171],{"class":146},[133,1713,187],{"class":157},[133,1715,1716,1718,1721,1723],{"class":135,"line":190},[133,1717,147],{"class":146},[133,1719,1720],{"class":157}," typer.testing ",[133,1722,171],{"class":146},[133,1724,1725],{"class":157}," CliRunner\n",[133,1727,1728],{"class":135,"line":203},[133,1729,165],{"emptyLinePlaceholder":164},[133,1731,1732,1734,1737,1739],{"class":135,"line":208},[133,1733,147],{"class":146},[133,1735,1736],{"class":157}," mytool.auth ",[133,1738,171],{"class":146},[133,1740,1741],{"class":157}," auth\n",[133,1743,1744],{"class":135,"line":221},[133,1745,165],{"emptyLinePlaceholder":164},[133,1747,1748,1751,1753],{"class":135,"line":226},[133,1749,1750],{"class":157},"runner ",[133,1752,302],{"class":146},[133,1754,1755],{"class":157}," CliRunner()\n",[133,1757,1758],{"class":135,"line":231},[133,1759,165],{"emptyLinePlaceholder":164},[133,1761,1762],{"class":135,"line":250},[133,1763,165],{"emptyLinePlaceholder":164},[133,1765,1766,1768,1771,1773,1776],{"class":135,"line":256},[133,1767,234],{"class":146},[133,1769,1770],{"class":237}," MemoryKeyring",[133,1772,241],{"class":157},[133,1774,1775],{"class":237},"KeyringBackend",[133,1777,247],{"class":157},[133,1779,1780,1783,1785],{"class":135,"line":261},[133,1781,1782],{"class":157},"    priority ",[133,1784,302],{"class":146},[133,1786,1787],{"class":150}," 1\n",[133,1789,1790,1792,1794],{"class":135,"line":266},[133,1791,396],{"class":157},[133,1793,302],{"class":146},[133,1795,1796],{"class":217}," \"memory\"\n",[133,1798,1799],{"class":135,"line":290},[133,1800,165],{"emptyLinePlaceholder":164},[133,1802,1803,1806,1809],{"class":135,"line":296},[133,1804,1805],{"class":146},"    def",[133,1807,1808],{"class":150}," __init__",[133,1810,1811],{"class":157},"(self):\n",[133,1813,1814,1817,1820,1822],{"class":135,"line":308},[133,1815,1816],{"class":150},"        self",[133,1818,1819],{"class":157},".data ",[133,1821,302],{"class":146},[133,1823,1824],{"class":157}," {}\n",[133,1826,1827],{"class":135,"line":320},[133,1828,165],{"emptyLinePlaceholder":164},[133,1830,1831,1833,1836],{"class":135,"line":329},[133,1832,1805],{"class":146},[133,1834,1835],{"class":237}," get_password",[133,1837,1838],{"class":157},"(self, service, username):\n",[133,1840,1841,1843,1846],{"class":135,"line":358},[133,1842,323],{"class":146},[133,1844,1845],{"class":150}," self",[133,1847,1848],{"class":157},".data.get((service, username))\n",[133,1850,1851],{"class":135,"line":363},[133,1852,165],{"emptyLinePlaceholder":164},[133,1854,1855,1857,1860],{"class":135,"line":368},[133,1856,1805],{"class":146},[133,1858,1859],{"class":237}," set_password",[133,1861,1862],{"class":157},"(self, service, username, password):\n",[133,1864,1865,1867,1870,1872],{"class":135,"line":393},[133,1866,1816],{"class":150},[133,1868,1869],{"class":157},".data[(service, username)] ",[133,1871,302],{"class":146},[133,1873,1874],{"class":157}," password\n",[133,1876,1877],{"class":135,"line":404},[133,1878,165],{"emptyLinePlaceholder":164},[133,1880,1881,1883,1886],{"class":135,"line":419},[133,1882,1805],{"class":146},[133,1884,1885],{"class":237}," delete_password",[133,1887,1838],{"class":157},[133,1889,1890,1893,1896,1899,1902,1904],{"class":135,"line":433},[133,1891,1892],{"class":146},"        if",[133,1894,1895],{"class":157}," (service, username) ",[133,1897,1898],{"class":146},"not",[133,1900,1901],{"class":146}," in",[133,1903,1845],{"class":150},[133,1905,1906],{"class":157},".data:\n",[133,1908,1909,1912,1915,1918],{"class":135,"line":441},[133,1910,1911],{"class":146},"            raise",[133,1913,1914],{"class":157}," keyring.errors.PasswordDeleteError(",[133,1916,1917],{"class":217},"\"missing\"",[133,1919,355],{"class":157},[133,1921,1922,1925,1927],{"class":135,"line":452},[133,1923,1924],{"class":146},"        del",[133,1926,1845],{"class":150},[133,1928,1929],{"class":157},".data[(service, username)]\n",[133,1931,1932],{"class":135,"line":467},[133,1933,165],{"emptyLinePlaceholder":164},[133,1935,1936],{"class":135,"line":510},[133,1937,165],{"emptyLinePlaceholder":164},[133,1939,1940],{"class":135,"line":518},[133,1941,1942],{"class":237},"@pytest.fixture\n",[133,1944,1945,1947,1950],{"class":135,"line":523},[133,1946,269],{"class":146},[133,1948,1949],{"class":237}," kr",[133,1951,1952],{"class":157},"(monkeypatch):\n",[133,1954,1955,1958,1960,1962,1965,1967,1969],{"class":135,"line":528},[133,1956,1957],{"class":157},"    monkeypatch.delenv(",[133,1959,1243],{"class":217},[133,1961,25],{"class":157},[133,1963,1964],{"class":744},"raising",[133,1966,302],{"class":146},[133,1968,895],{"class":150},[133,1970,355],{"class":157},[133,1972,1973,1975,1977],{"class":135,"line":550},[133,1974,1303],{"class":157},[133,1976,302],{"class":146},[133,1978,1979],{"class":157}," MemoryKeyring()\n",[133,1981,1982],{"class":135,"line":564},[133,1983,1984],{"class":157},"    keyring.set_keyring(backend)\n",[133,1986,1987,1989],{"class":135,"line":571},[133,1988,332],{"class":146},[133,1990,1991],{"class":157}," backend\n",[133,1993,1994],{"class":135,"line":578},[133,1995,165],{"emptyLinePlaceholder":164},[133,1997,1998],{"class":135,"line":591},[133,1999,165],{"emptyLinePlaceholder":164},[133,2001,2002,2004,2007],{"class":135,"line":599},[133,2003,269],{"class":146},[133,2005,2006],{"class":237}," test_login_status_logout",[133,2008,2009],{"class":157},"(kr):\n",[133,2011,2012,2014,2016],{"class":135,"line":609},[133,2013,1293],{"class":157},[133,2015,302],{"class":146},[133,2017,2018],{"class":217}," \"tok_1234567890abcdef\"\n",[133,2020,2021,2024,2027,2030,2032,2034,2037,2040,2042,2045,2048,2051,2054,2056,2059,2062],{"class":135,"line":614},[133,2022,2023],{"class":146},"    assert",[133,2025,2026],{"class":157}," runner.invoke(auth, [",[133,2028,2029],{"class":217},"\"login\"",[133,2031,25],{"class":157},[133,2033,900],{"class":217},[133,2035,2036],{"class":157},"], ",[133,2038,2039],{"class":744},"input",[133,2041,302],{"class":146},[133,2043,2044],{"class":157},"token ",[133,2046,2047],{"class":146},"+",[133,2049,2050],{"class":217}," \"",[133,2052,2053],{"class":150},"\\n",[133,2055,499],{"class":217},[133,2057,2058],{"class":157},").exit_code ",[133,2060,2061],{"class":146},"==",[133,2063,2064],{"class":150}," 0\n",[133,2066,2067,2069,2072,2075,2077,2079,2082,2084],{"class":135,"line":619},[133,2068,2023],{"class":146},[133,2070,2071],{"class":157}," kr.data[(",[133,2073,2074],{"class":217},"\"mytool\"",[133,2076,25],{"class":157},[133,2078,868],{"class":217},[133,2080,2081],{"class":157},")] ",[133,2083,2061],{"class":146},[133,2085,2086],{"class":157}," token\n",[133,2088,2089],{"class":135,"line":638},[133,2090,165],{"emptyLinePlaceholder":164},[133,2092,2093,2096,2098,2100,2103],{"class":135,"line":645},[133,2094,2095],{"class":157},"    result ",[133,2097,302],{"class":146},[133,2099,2026],{"class":157},[133,2101,2102],{"class":217},"\"status\"",[133,2104,2105],{"class":157},"])\n",[133,2107,2108,2110,2113,2115],{"class":135,"line":655},[133,2109,2023],{"class":146},[133,2111,2112],{"class":157}," result.exit_code ",[133,2114,2061],{"class":146},[133,2116,2064],{"class":150},[133,2118,2119,2121,2124,2126,2129,2132,2135,2137,2139],{"class":135,"line":663},[133,2120,2023],{"class":146},[133,2122,2123],{"class":217}," \"...cdef\"",[133,2125,1901],{"class":146},[133,2127,2128],{"class":157}," result.output ",[133,2130,2131],{"class":146},"and",[133,2133,2134],{"class":157}," token ",[133,2136,1898],{"class":146},[133,2138,1901],{"class":146},[133,2140,2141],{"class":157}," result.output\n",[133,2143,2144],{"class":135,"line":671},[133,2145,165],{"emptyLinePlaceholder":164},[133,2147,2148,2150,2152,2155,2158,2160],{"class":135,"line":1317},[133,2149,2023],{"class":146},[133,2151,2026],{"class":157},[133,2153,2154],{"class":217},"\"logout\"",[133,2156,2157],{"class":157},"]).exit_code ",[133,2159,2061],{"class":146},[133,2161,2064],{"class":150},[133,2163,2164,2166,2168,2170,2172,2174],{"class":135,"line":1324},[133,2165,2023],{"class":146},[133,2167,2026],{"class":157},[133,2169,2102],{"class":217},[133,2171,2157],{"class":157},[133,2173,2061],{"class":146},[133,2175,1787],{"class":150},[133,2177,2178],{"class":135,"line":1365},[133,2179,165],{"emptyLinePlaceholder":164},[133,2181,2182],{"class":135,"line":1372},[133,2183,165],{"emptyLinePlaceholder":164},[133,2185,2186,2188,2191],{"class":135,"line":1402},[133,2187,269],{"class":146},[133,2189,2190],{"class":237}," test_env_overrides_keychain",[133,2192,2193],{"class":157},"(kr, monkeypatch):\n",[133,2195,2196,2199,2201,2203,2205,2207,2210],{"class":135,"line":1413},[133,2197,2198],{"class":157},"    kr.set_password(",[133,2200,2074],{"class":217},[133,2202,25],{"class":157},[133,2204,868],{"class":217},[133,2206,25],{"class":157},[133,2208,2209],{"class":217},"\"tok_from_keychain_0000\"",[133,2211,355],{"class":157},[133,2213,2214,2217,2219,2221,2224],{"class":135,"line":1418},[133,2215,2216],{"class":157},"    monkeypatch.setenv(",[133,2218,1243],{"class":217},[133,2220,25],{"class":157},[133,2222,2223],{"class":217},"\"tok_from_env_99999999\"",[133,2225,355],{"class":157},[133,2227,2228,2230,2233,2235,2237,2239],{"class":135,"line":1423},[133,2229,2023],{"class":146},[133,2231,2232],{"class":217}," \"MYTOOL_TOKEN\"",[133,2234,1901],{"class":146},[133,2236,2026],{"class":157},[133,2238,2102],{"class":217},[133,2240,2241],{"class":157},"]).output\n",[133,2243,2244],{"class":135,"line":1430},[133,2245,165],{"emptyLinePlaceholder":164},[133,2247,2248],{"class":135,"line":1462},[133,2249,165],{"emptyLinePlaceholder":164},[133,2251,2252,2254,2257],{"class":135,"line":1468},[133,2253,269],{"class":146},[133,2255,2256],{"class":237}," test_no_backend_is_explained",[133,2258,1952],{"class":157},[133,2260,2261,2263,2265,2267,2269,2271,2273],{"class":135,"line":1479},[133,2262,1957],{"class":157},[133,2264,1243],{"class":217},[133,2266,25],{"class":157},[133,2268,1964],{"class":744},[133,2270,302],{"class":146},[133,2272,895],{"class":150},[133,2274,355],{"class":157},[133,2276,2278],{"class":135,"line":2277},61,[133,2279,2280],{"class":157},"    keyring.set_keyring(fail.Keyring())\n",[133,2282,2284,2286,2288,2290,2292,2294,2296,2298,2300,2302,2305,2307,2309],{"class":135,"line":2283},62,[133,2285,2095],{"class":157},[133,2287,302],{"class":146},[133,2289,2026],{"class":157},[133,2291,2029],{"class":217},[133,2293,25],{"class":157},[133,2295,900],{"class":217},[133,2297,2036],{"class":157},[133,2299,2039],{"class":744},[133,2301,302],{"class":146},[133,2303,2304],{"class":217},"\"tok_abcdefghijklmnop",[133,2306,2053],{"class":150},[133,2308,499],{"class":217},[133,2310,355],{"class":157},[133,2312,2314,2316,2318,2320],{"class":135,"line":2313},63,[133,2315,2023],{"class":146},[133,2317,2112],{"class":157},[133,2319,2061],{"class":146},[133,2321,1787],{"class":150},[133,2323,2325,2327,2329,2331],{"class":135,"line":2324},64,[133,2326,2023],{"class":146},[133,2328,2232],{"class":217},[133,2330,1901],{"class":146},[133,2332,2141],{"class":157},[10,2334,2335,2336,2339,2340,2342,2343,2345,2346,42],{},"The final test pins the headless-machine behaviour: with the ",[14,2337,2338],{},"fail"," backend active, ",[14,2341,1555],{}," explains the alternative instead of crashing. For a CI job that needs a keychain for an integration test, ",[14,2344,1636],{}," provides simple backends you can configure through ",[14,2347,2348],{},"PYTHON_KEYRING_BACKEND",[44,2350,2352],{"id":2351},"conclusion","Conclusion",[10,2354,2355,2356,2358,2359,2361,2362,2364,2365,2367],{},"The operating system already has a secure place for your CLI's tokens; ",[14,2357,20],{}," makes using it a three-function affair. Wrap it in a small module that detects a missing backend, give users ",[14,2360,24],{}," (from a hidden prompt or stdin, never an argument), ",[14,2363,28],{}," (source and tail, never the value) and ",[14,2366,32],{},", and let environment variables override the keychain for automation. Test with an in-memory backend, and the whole credential lifecycle is covered without ever writing a token to disk yourself.",[44,2369,2371],{"id":2370},"frequently-asked-questions","Frequently asked questions",[1543,2373,2375],{"id":2374},"is-the-keychain-safe-from-other-programs-run-by-the-same-user","Is the keychain safe from other programs run by the same user?",[10,2377,2378],{},"Partially. macOS and Windows can restrict items to the application that created them or prompt on access, which helps. The Linux Secret Service generally allows any program in the unlocked session to read items. The keychain protects against files leaking, backups and casual access — not against malware running as the user, which nothing in a CLI can fully prevent.",[1543,2380,2382],{"id":2381},"can-i-store-more-than-a-token-such-as-a-refresh-token-and-expiry","Can I store more than a token, such as a refresh token and expiry?",[10,2384,2385,2386,29,2388,2391],{},"Yes: store a small JSON document as the \"password\", or use separate entries (",[14,2387,1155],{},[14,2389,2390],{},"profile:refresh","). Some Windows Credential Manager configurations limit value size to a few kilobytes, so keep it compact.",[1543,2393,2395],{"id":2394},"why-does-macos-ask-for-access-every-time-after-i-upgrade-my-cli","Why does macOS ask for access every time after I upgrade my CLI?",[10,2397,2398],{},"Keychain access-control lists are tied to the calling binary. When a Python interpreter or a frozen executable changes, macOS treats it as a new application. Users can choose \"Always Allow\"; signed binaries with a stable identity avoid the repeat prompts.",[1543,2400,2402],{"id":2401},"how-do-i-use-keyring-inside-docker","How do I use keyring inside Docker?",[10,2404,2405,2406,2409],{},"Usually you should not: containers rarely run a Secret Service, and the whole point of a container is injected configuration. Pass the token with ",[14,2407,2408],{},"MYTOOL_TOKEN_FILE"," pointing at a mounted secret, and let the keychain path apply only on workstations.",[44,2411,2413],{"id":2412},"related","Related",[49,2415,2416,2422,2427,2432,2437],{},[52,2417,2418,2419],{},"Up: ",[38,2420,2421],{"href":40},"Secrets and credentials in Python CLIs",[52,2423,2424],{},[38,2425,2426],{"href":1626},"Reading secrets from env and files",[52,2428,2429],{},[38,2430,2431],{"href":120},"Supporting multiple profiles and accounts",[52,2433,2434],{},[38,2435,2436],{"href":67},"OAuth device flow login for CLIs",[52,2438,2439],{},[38,2440,2442],{"href":2441},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes\u002Fstoring-app-data-with-platformdirs\u002F","Storing app data with platformdirs",[2444,2445,2446],"style",{},"html pre.shiki code .sJ8bj, html code.shiki .sJ8bj{--shiki-default:#6A737D;--shiki-dark:#6A737D}html pre.shiki code .szBVR, html code.shiki .szBVR{--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .s4XuR, html code.shiki .s4XuR{--shiki-default:#E36209;--shiki-dark:#FFAB70}",{"title":129,"searchDepth":143,"depth":143,"links":2448},[2449,2450,2451,2454,2455,2456,2457,2463],{"id":46,"depth":143,"text":47},{"id":74,"depth":143,"text":75},{"id":113,"depth":143,"text":114,"children":2452},[2453],{"id":1545,"depth":161,"text":1546},{"id":1596,"depth":143,"text":1597},{"id":1660,"depth":143,"text":1661},{"id":2351,"depth":143,"text":2352},{"id":2370,"depth":143,"text":2371,"children":2458},[2459,2460,2461,2462],{"id":2374,"depth":161,"text":2375},{"id":2381,"depth":161,"text":2382},{"id":2394,"depth":161,"text":2395},{"id":2401,"depth":161,"text":2402},{"id":2412,"depth":143,"text":2413},"2026-09-18","Keep a Python CLI’s API tokens in the macOS Keychain, Windows Credential Manager or Secret Service with keyring: login, status, logout, fallbacks and tests.","intermediate",false,"md",{},"\u002Fcli-runtime-systems-integration\u002Fsecrets-and-credentials-in-python-clis\u002Fstoring-tokens-with-keyring",{"title":5,"description":2465},"cli-runtime-systems-integration\u002Fsecrets-and-credentials-in-python-clis\u002Fstoring-tokens-with-keyring\u002Findex",[20,2474,2475,2476],"security","credentials","authentication","mryld79KGltohM3DjDLacxO72KRi8i2bazQldimso88",[2479,2482,2485,2488,2491,2494,2497,2500,2503,2506,2509,2512,2515,2518,2521,2524,2527,2530,2533,2536,2539,2542,2545,2548,2551,2554,2557,2560,2563,2566,2569,2572,2575,2578,2581,2584,2587,2590,2593,2596,2599,2602,2605,2608,2611,2614,2617,2620,2623,2626,2629,2632,2635,2638,2641,2644,2647,2650,2653,2656,2659,2662,2665,2668,2671,2674,2677,2680,2683,2686,2689,2692,2695,2698,2701,2704,2707,2710,2713,2716,2719,2722,2725,2728,2731,2734,2737,2740,2743,2746,2747,2750,2753,2756,2759,2762,2765,2768,2771,2774,2777,2780,2783,2786,2789,2792,2795,2798,2801,2804,2807,2810,2813,2816,2819,2822,2825,2828,2831,2834,2837,2840,2843,2846,2849,2852,2855,2858,2861,2864,2867,2870,2873,2876,2879,2882,2885,2888,2891,2894,2897,2900,2903,2906,2909,2912,2915,2918,2921,2924,2927,2930,2933,2936,2939,2942,2945,2948,2951,2954,2957,2960,2963,2966,2969,2972,2975,2978,2981,2984,2987,2990,2993,2996,2999,3002,3005,3008,3011,3014,3017,3020,3023],{"path":2480,"title":2481},"\u002Fabout","About Python CLI Toolcraft",{"path":2483,"title":2484},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies","Advanced Argument Validation Strategies",{"path":2486,"title":2487},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies\u002Fparsing-nested-json-arguments-in-python-clis","Parsing Nested JSON Args in Python CLIs",{"path":2489,"title":2490},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies\u002Fvalidating-dependent-and-conflicting-options","Validating Dependent and Conflicting CLI Options",{"path":2492,"title":2493},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies\u002Fvalidating-file-and-directory-paths-in-clis","Validating File and Directory Paths in CLIs",{"path":2495,"title":2496},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies\u002Fwriting-custom-click-parameter-types","Writing Custom Click Parameter Types",{"path":2498,"title":2499},"\u002Fadvanced-input-parsing-user-experience\u002Fbuilding-terminal-uis-with-textual\u002Fbuilding-your-first-textual-app","Building Your First Textual App for a Python CLI",{"path":2501,"title":2502},"\u002Fadvanced-input-parsing-user-experience\u002Fbuilding-terminal-uis-with-textual\u002Fchoosing-between-a-cli-a-prompt-flow-and-a-tui","Choosing Between a CLI, a Prompt Flow and a TUI",{"path":2504,"title":2505},"\u002Fadvanced-input-parsing-user-experience\u002Fbuilding-terminal-uis-with-textual","Building Terminal UIs with Textual for Python CLIs",{"path":2507,"title":2508},"\u002Fadvanced-input-parsing-user-experience\u002Fbuilding-terminal-uis-with-textual\u002Ftesting-textual-apps-with-pilot","Testing Textual Apps with Pilot",{"path":2510,"title":2511},"\u002Fadvanced-input-parsing-user-experience\u002Fcli-help-output-and-documentation\u002Fadding-examples-and-epilogs-to-help-output","Adding Examples and Epilogs to Help Output",{"path":2513,"title":2514},"\u002Fadvanced-input-parsing-user-experience\u002Fcli-help-output-and-documentation\u002Fgenerating-man-pages-and-docs-from-a-cli","Generating Man Pages and Docs from a CLI",{"path":2516,"title":2517},"\u002Fadvanced-input-parsing-user-experience\u002Fcli-help-output-and-documentation","CLI Help Output and Documentation",{"path":2519,"title":2520},"\u002Fadvanced-input-parsing-user-experience\u002Fcli-help-output-and-documentation\u002Fversioning-and-deprecating-cli-flags","Versioning and Deprecating CLI Flags",{"path":2522,"title":2523},"\u002Fadvanced-input-parsing-user-experience\u002Fcli-help-output-and-documentation\u002Fwriting-help-text-users-actually-read","Writing Help Text Users Actually Read",{"path":2525,"title":2526},"\u002Fadvanced-input-parsing-user-experience\u002Fcross-platform-terminal-compatibility\u002Fadapting-output-to-terminal-width","Adapting Python CLI Output to Terminal Width",{"path":2528,"title":2529},"\u002Fadvanced-input-parsing-user-experience\u002Fcross-platform-terminal-compatibility\u002Fdetecting-ci-environments-and-non-interactive-shells","Detecting CI Environments and Non-Interactive Shells",{"path":2531,"title":2532},"\u002Fadvanced-input-parsing-user-experience\u002Fcross-platform-terminal-compatibility\u002Ffixing-unicode-and-encoding-errors-on-windows","Fixing Unicode and Encoding Errors on Windows in Python CLIs",{"path":2534,"title":2535},"\u002Fadvanced-input-parsing-user-experience\u002Fcross-platform-terminal-compatibility","Cross-Platform Terminal Compatibility for Python CLIs",{"path":2537,"title":2538},"\u002Fadvanced-input-parsing-user-experience\u002Fcross-platform-terminal-compatibility\u002Frespecting-no-color-and-force-color","Respecting NO_COLOR and FORCE_COLOR in Python CLIs",{"path":2540,"title":2541},"\u002Fadvanced-input-parsing-user-experience\u002Ferror-handling-and-exit-codes\u002Fchoosing-exit-codes-for-cli-tools","Choosing Exit Codes for CLI Tools",{"path":2543,"title":2544},"\u002Fadvanced-input-parsing-user-experience\u002Ferror-handling-and-exit-codes\u002Fdesigning-an-exception-hierarchy-for-a-cli","Designing an Exception Hierarchy for a Python CLI",{"path":2546,"title":2547},"\u002Fadvanced-input-parsing-user-experience\u002Ferror-handling-and-exit-codes\u002Ffriendly-error-messages-and-tracebacks","Friendly Error Messages and Tracebacks",{"path":2549,"title":2550},"\u002Fadvanced-input-parsing-user-experience\u002Ferror-handling-and-exit-codes\u002Fhandling-keyboard-interrupt-cleanly","Handling Keyboard Interrupt Cleanly",{"path":2552,"title":2553},"\u002Fadvanced-input-parsing-user-experience\u002Ferror-handling-and-exit-codes","Error Handling and Exit Codes for CLIs",{"path":2555,"title":2556},"\u002Fadvanced-input-parsing-user-experience\u002Ferror-handling-and-exit-codes\u002Freporting-machine-readable-errors-in-json-mode","Reporting Machine-Readable Errors in JSON Mode",{"path":2558,"title":2559},"\u002Fadvanced-input-parsing-user-experience\u002Fhandling-configuration-files-env-vars\u002Fconfig-precedence-flags-env-files-defaults","Config Precedence: Flags, Env, Files, Defaults",{"path":2561,"title":2562},"\u002Fadvanced-input-parsing-user-experience\u002Fhandling-configuration-files-env-vars\u002Fdiscovering-project-config-files-by-walking-up-directories","Discovering Project Config Files by Walking Up Directories",{"path":2564,"title":2565},"\u002Fadvanced-input-parsing-user-experience\u002Fhandling-configuration-files-env-vars","Handling Config Files and Env Vars in CLIs",{"path":2567,"title":2568},"\u002Fadvanced-input-parsing-user-experience\u002Fhandling-configuration-files-env-vars\u002Floading-yaml-configs-safely-in-cli-apps","Loading YAML configs safely in CLI apps",{"path":2570,"title":2571},"\u002Fadvanced-input-parsing-user-experience\u002Fhandling-configuration-files-env-vars\u002Freading-toml-config-with-tomllib","Reading TOML Config with tomllib in Python CLIs",{"path":2573,"title":2574},"\u002Fadvanced-input-parsing-user-experience\u002Fhandling-configuration-files-env-vars\u002Ftyped-settings-with-pydantic-settings","Typed Settings with pydantic-settings in Python CLIs",{"path":2576,"title":2577},"\u002Fadvanced-input-parsing-user-experience","Advanced Input Parsing for Python CLIs",{"path":2579,"title":2580},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich\u002Fadding-progress-bars-and-spinners-to-python-clis","Progress Bars and Spinners for Python CLIs",{"path":2582,"title":2583},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich\u002Fbuilding-interactive-prompts-and-menus","Building Interactive Prompts and Menus in Python CLIs",{"path":2585,"title":2586},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich","Interactive Terminal UI with Rich",{"path":2588,"title":2589},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich\u002Flive-dashboards-with-rich-live","Live Dashboards with Rich Live in Python CLIs",{"path":2591,"title":2592},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich\u002Frendering-tables-and-json-with-rich","Rendering Tables and JSON with Rich",{"path":2594,"title":2595},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich\u002Ftheming-rich-output-consistently","Theming Rich Output Consistently in Python CLIs",{"path":2597,"title":2598},"\u002Fadvanced-input-parsing-user-experience\u002Fshell-completion-for-python-clis\u002Fdynamic-completion-values-from-apis-and-files","Dynamic Completion Values from APIs and Files",{"path":2600,"title":2601},"\u002Fadvanced-input-parsing-user-experience\u002Fshell-completion-for-python-clis\u002Fenabling-tab-completion-in-click-and-typer","Enabling Tab Completion in Click and Typer",{"path":2603,"title":2604},"\u002Fadvanced-input-parsing-user-experience\u002Fshell-completion-for-python-clis","Shell Completion for Python CLIs",{"path":2606,"title":2607},"\u002Fadvanced-input-parsing-user-experience\u002Fshell-completion-for-python-clis\u002Finstalling-shell-completion-for-bash-zsh-fish","Installing Shell Completion for bash, zsh, fish",{"path":2609,"title":2610},"\u002Fadvanced-input-parsing-user-experience\u002Fshell-completion-for-python-clis\u002Ftesting-shell-completion-in-python-clis","Testing Shell Completion in Python CLIs",{"path":2612,"title":2613},"\u002Fadvanced-input-parsing-user-experience\u002Fstructured-logging-for-cli-apps\u002Fadding-trace-ids-and-context-to-cli-logs","Adding Trace IDs and Context to Python CLI Logs",{"path":2615,"title":2616},"\u002Fadvanced-input-parsing-user-experience\u002Fstructured-logging-for-cli-apps\u002Fadding-verbose-and-quiet-logging-flags","Adding Verbose and Quiet Logging Flags",{"path":2618,"title":2619},"\u002Fadvanced-input-parsing-user-experience\u002Fstructured-logging-for-cli-apps","Structured Logging for CLI Apps",{"path":2621,"title":2622},"\u002Fadvanced-input-parsing-user-experience\u002Fstructured-logging-for-cli-apps\u002Fstructured-json-logging-in-python-clis","Structured JSON Logging in Python CLIs",{"path":2624,"title":2625},"\u002Fadvanced-input-parsing-user-experience\u002Fstructured-logging-for-cli-apps\u002Fwriting-rotating-log-files-from-a-cli","Writing Rotating Log Files from a Python CLI",{"path":2627,"title":2628},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes\u002Fdetecting-tty-and-adapting-output","Detecting a TTY and Adapting Output",{"path":2630,"title":2631},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes\u002Femitting-json-output-for-scripting","Emitting JSON Output for Scripting",{"path":2633,"title":2634},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes\u002Fhandling-broken-pipe-and-sigpipe","Handling Broken Pipe and SIGPIPE",{"path":2636,"title":2637},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes","Working with stdin, stdout and Pipes",{"path":2639,"title":2640},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes\u002Fprocessing-large-files-and-ndjson-streams","Processing Large Files and NDJSON Streams in Python CLIs",{"path":2642,"title":2643},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes\u002Freading-piped-input-in-python-clis","Reading Piped Input in Python CLIs",{"path":2645,"title":2646},"\u002Fcli-runtime-systems-integration\u002Fcalling-http-apis-from-python-clis\u002Fbuilding-an-api-client-cli-with-httpx","Building an API Client CLI with httpx",{"path":2648,"title":2649},"\u002Fcli-runtime-systems-integration\u002Fcalling-http-apis-from-python-clis\u002Fdownloading-files-with-progress-in-python","Downloading Files with Progress in Python CLIs",{"path":2651,"title":2652},"\u002Fcli-runtime-systems-integration\u002Fcalling-http-apis-from-python-clis","Calling HTTP APIs from Python CLIs",{"path":2654,"title":2655},"\u002Fcli-runtime-systems-integration\u002Fcalling-http-apis-from-python-clis\u002Foauth-device-flow-login-for-clis","OAuth Device Flow Login for Python CLIs",{"path":2657,"title":2658},"\u002Fcli-runtime-systems-integration\u002Fcalling-http-apis-from-python-clis\u002Fpaginating-api-results-in-a-cli","Paginating API Results in a Python CLI",{"path":2660,"title":2661},"\u002Fcli-runtime-systems-integration\u002Fcalling-http-apis-from-python-clis\u002Fretries-and-backoff-for-cli-http-calls","Retries and Backoff for CLI HTTP Calls",{"path":2663,"title":2664},"\u002Fcli-runtime-systems-integration\u002Fconcurrency-and-async-in-python-clis\u002Fcancelling-async-tasks-on-ctrl-c","Cancelling Async Tasks on Ctrl+C in Python CLIs",{"path":2666,"title":2667},"\u002Fcli-runtime-systems-integration\u002Fconcurrency-and-async-in-python-clis","Concurrency and Async in Python CLIs",{"path":2669,"title":2670},"\u002Fcli-runtime-systems-integration\u002Fconcurrency-and-async-in-python-clis\u002Fmultiprocessing-for-cpu-bound-cli-tasks","Multiprocessing for CPU-Bound CLI Tasks",{"path":2672,"title":2673},"\u002Fcli-runtime-systems-integration\u002Fconcurrency-and-async-in-python-clis\u002Fparallelising-cli-work-with-thread-pools","Parallelising CLI Work with Thread Pools",{"path":2675,"title":2676},"\u002Fcli-runtime-systems-integration\u002Fconcurrency-and-async-in-python-clis\u002Frate-limiting-concurrent-requests-in-clis","Rate-Limiting Concurrent Requests in Python CLIs",{"path":2678,"title":2679},"\u002Fcli-runtime-systems-integration\u002Fconcurrency-and-async-in-python-clis\u002Frunning-async-code-in-typer-and-click","Running Async Code in Typer and Click",{"path":2681,"title":2682},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes\u002Fcross-platform-paths-with-pathlib","Cross-Platform Paths with pathlib in CLIs",{"path":2684,"title":2685},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes\u002Ffile-locking-for-concurrent-cli-runs","File Locking for Concurrent CLI Runs in Python",{"path":2687,"title":2688},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes","Filesystem Paths and Atomic Writes for CLIs",{"path":2690,"title":2691},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes\u002Fsafe-temporary-files-and-directories","Safe Temporary Files and Directories in CLIs",{"path":2693,"title":2694},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes\u002Fstoring-app-data-with-platformdirs","Storing CLI App Data with platformdirs",{"path":2696,"title":2697},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes\u002Fwriting-files-atomically-in-python-clis","Writing Files Atomically in Python CLIs",{"path":2699,"title":2700},"\u002Fcli-runtime-systems-integration","CLI Runtime & Systems Integration for Python",{"path":2702,"title":2703},"\u002Fcli-runtime-systems-integration\u002Flong-running-and-watch-mode-clis\u002Fbuilding-a-watch-mode-with-watchfiles","Building a Watch Mode with watchfiles in Python",{"path":2705,"title":2706},"\u002Fcli-runtime-systems-integration\u002Flong-running-and-watch-mode-clis\u002Fhandling-sigterm-and-graceful-shutdown","Handling SIGTERM and Graceful Shutdown in CLIs",{"path":2708,"title":2709},"\u002Fcli-runtime-systems-integration\u002Flong-running-and-watch-mode-clis\u002Fhealth-checks-and-heartbeats-for-long-running-clis","Health Checks and Heartbeats for Long-Running CLIs",{"path":2711,"title":2712},"\u002Fcli-runtime-systems-integration\u002Flong-running-and-watch-mode-clis","Long-Running and Watch-Mode Python CLIs",{"path":2714,"title":2715},"\u002Fcli-runtime-systems-integration\u002Flong-running-and-watch-mode-clis\u002Frunning-a-cli-on-a-schedule-with-cron-and-systemd","Running a Python CLI on a Schedule with cron and systemd",{"path":2717,"title":2718},"\u002Fcli-runtime-systems-integration\u002Frunning-subprocesses-from-python-clis\u002Favoiding-shell-injection-in-python-clis","Avoiding Shell Injection in Python CLIs",{"path":2720,"title":2721},"\u002Fcli-runtime-systems-integration\u002Frunning-subprocesses-from-python-clis\u002Fcalling-external-commands-safely-with-subprocess","Calling External Commands Safely with subprocess",{"path":2723,"title":2724},"\u002Fcli-runtime-systems-integration\u002Frunning-subprocesses-from-python-clis\u002Fhandling-subprocess-timeouts-and-exit-codes","Handling Subprocess Timeouts and Exit Codes",{"path":2726,"title":2727},"\u002Fcli-runtime-systems-integration\u002Frunning-subprocesses-from-python-clis","Running Subprocesses from Python CLIs",{"path":2729,"title":2730},"\u002Fcli-runtime-systems-integration\u002Frunning-subprocesses-from-python-clis\u002Fstreaming-subprocess-output-in-real-time","Streaming Subprocess Output in Real Time",{"path":2732,"title":2733},"\u002Fcli-runtime-systems-integration\u002Frunning-subprocesses-from-python-clis\u002Fwrapping-git-and-other-tools-from-a-python-cli","Wrapping git and Other Tools from a Python CLI",{"path":2735,"title":2736},"\u002Fcli-runtime-systems-integration\u002Fsecrets-and-credentials-in-python-clis","Secrets and Credentials in Python CLIs",{"path":2738,"title":2739},"\u002Fcli-runtime-systems-integration\u002Fsecrets-and-credentials-in-python-clis\u002Fprompting-for-passwords-securely","Prompting for Passwords Securely in Python CLIs",{"path":2741,"title":2742},"\u002Fcli-runtime-systems-integration\u002Fsecrets-and-credentials-in-python-clis\u002Freading-secrets-from-env-and-files","Reading Secrets from Env Vars and Files in CLIs",{"path":2744,"title":2745},"\u002Fcli-runtime-systems-integration\u002Fsecrets-and-credentials-in-python-clis\u002Fredacting-secrets-from-cli-output-and-logs","Redacting Secrets from CLI Output and Logs",{"path":2470,"title":5},{"path":2748,"title":2749},"\u002Fcli-runtime-systems-integration\u002Fsecrets-and-credentials-in-python-clis\u002Fsupporting-multiple-profiles-and-accounts","Supporting Multiple Profiles and Accounts in CLIs",{"path":2751,"title":2752},"\u002F","Python CLI Toolcraft",{"path":2754,"title":2755},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcli-startup-performance-and-lazy-loading\u002Fcaching-expensive-work-between-cli-runs","Caching Expensive Work Between Python CLI Runs",{"path":2757,"title":2758},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcli-startup-performance-and-lazy-loading","CLI Startup Performance and Lazy Loading",{"path":2760,"title":2761},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcli-startup-performance-and-lazy-loading\u002Flazy-loading-subcommands-for-faster-startup","Lazy Loading Subcommands for Faster Startup",{"path":2763,"title":2764},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcli-startup-performance-and-lazy-loading\u002Fprofiling-python-cli-startup-time","Profiling Python CLI Startup Time",{"path":2766,"title":2767},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcli-startup-performance-and-lazy-loading\u002Freducing-cli-dependency-weight","Reducing CLI Dependency Weight",{"path":2769,"title":2770},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse\u002Fargparse-subparsers-for-subcommands","argparse Subparsers for Subcommands",{"path":2772,"title":2773},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse\u002Fargparse-vs-click-vs-typer-comparison","argparse vs Click vs Typer Compared",{"path":2775,"title":2776},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse","Command-Line Parsing with argparse",{"path":2778,"title":2779},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse\u002Fmigrating-from-argparse-to-typer","Migrating from argparse to Typer",{"path":2781,"title":2782},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse\u002Fmutually-exclusive-options-in-argparse","Mutually Exclusive Options in argparse",{"path":2784,"title":2785},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse\u002Fwriting-custom-argparse-actions","Writing Custom argparse Actions in Python",{"path":2787,"title":2788},"\u002Fmodern-python-cli-frameworks-architecture\u002Fdesigning-cli-interfaces-and-conventions\u002Fadding-dry-run-and-confirmation-to-destructive-commands","Adding Dry-Run and Confirmation to Destructive Commands",{"path":2790,"title":2791},"\u002Fmodern-python-cli-frameworks-architecture\u002Fdesigning-cli-interfaces-and-conventions\u002Ffollowing-posix-and-gnu-argument-conventions","Following POSIX and GNU Argument Conventions in Python",{"path":2793,"title":2794},"\u002Fmodern-python-cli-frameworks-architecture\u002Fdesigning-cli-interfaces-and-conventions\u002Fglobal-options-vs-per-command-options","Global Options vs Per-Command Options in Python CLIs",{"path":2796,"title":2797},"\u002Fmodern-python-cli-frameworks-architecture\u002Fdesigning-cli-interfaces-and-conventions","Designing CLI Interfaces and Conventions in Python",{"path":2799,"title":2800},"\u002Fmodern-python-cli-frameworks-architecture\u002Fdesigning-cli-interfaces-and-conventions\u002Fnaming-commands-and-flags-consistently","Naming Commands and Flags Consistently in Python CLIs",{"path":2802,"title":2803},"\u002Fmodern-python-cli-frameworks-architecture","Python CLI Frameworks and Architecture",{"path":2805,"title":2806},"\u002Fmodern-python-cli-frameworks-architecture\u002Fplugin-architectures-for-extensible-clis\u002Fdiscovering-plugins-with-entry-points","Discovering Plugins with Entry Points in Python CLIs",{"path":2808,"title":2809},"\u002Fmodern-python-cli-frameworks-architecture\u002Fplugin-architectures-for-extensible-clis\u002Fhook-based-plugins-with-pluggy","Hook-Based Plugins for Python CLIs with pluggy",{"path":2811,"title":2812},"\u002Fmodern-python-cli-frameworks-architecture\u002Fplugin-architectures-for-extensible-clis","Plugin Architectures for Extensible CLIs",{"path":2814,"title":2815},"\u002Fmodern-python-cli-frameworks-architecture\u002Fplugin-architectures-for-extensible-clis\u002Fversioning-a-plugin-api","Versioning a Plugin API for a Python CLI",{"path":2817,"title":2818},"\u002Fmodern-python-cli-frameworks-architecture\u002Fplugin-architectures-for-extensible-clis\u002Fwriting-a-plugin-for-an-existing-cli","Writing a Plugin for an Existing CLI",{"path":2820,"title":2821},"\u002Fmodern-python-cli-frameworks-architecture\u002Fstructuring-multi-command-python-clis\u002Fbest-practices-for-python-cli-entry-points","Best practices for Python CLI entry points",{"path":2823,"title":2824},"\u002Fmodern-python-cli-frameworks-architecture\u002Fstructuring-multi-command-python-clis\u002Fdependency-injection-patterns-for-cli-commands","Dependency Injection Patterns for CLI Commands",{"path":2826,"title":2827},"\u002Fmodern-python-cli-frameworks-architecture\u002Fstructuring-multi-command-python-clis\u002Fhow-to-structure-a-large-python-cli-project","Structuring a Large Python CLI Project",{"path":2829,"title":2830},"\u002Fmodern-python-cli-frameworks-architecture\u002Fstructuring-multi-command-python-clis","Structuring Multi-Command Python CLIs",{"path":2832,"title":2833},"\u002Fmodern-python-cli-frameworks-architecture\u002Fstructuring-multi-command-python-clis\u002Fsharing-common-options-across-commands","Sharing Common Options Across Python CLI Commands",{"path":2835,"title":2836},"\u002Fmodern-python-cli-frameworks-architecture\u002Fstructuring-multi-command-python-clis\u002Fsharing-state-with-click-context-objects","Sharing State with Click Context Objects",{"path":2838,"title":2839},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Fend-to-end-testing-an-installed-cli","End-to-End Testing an Installed Python CLI",{"path":2841,"title":2842},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications","Testing Python CLI Applications",{"path":2844,"title":2845},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Fmeasuring-cli-test-coverage","Measuring CLI Test Coverage",{"path":2847,"title":2848},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Fmocking-filesystem-and-network-in-cli-tests","Mocking the Filesystem and Network in CLI Tests",{"path":2850,"title":2851},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Fproperty-based-testing-cli-arguments-with-hypothesis","Property-Based Testing CLI Arguments with Hypothesis",{"path":2853,"title":2854},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Fsnapshot-testing-cli-output","Snapshot Testing CLI Output",{"path":2856,"title":2857},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Ftesting-click-commands-with-clirunner","Testing Click Commands with CliRunner",{"path":2859,"title":2860},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Ftesting-interactive-prompts-and-stdin","Testing Interactive Prompts and stdin",{"path":2862,"title":2863},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftyper-vs-click-when-to-use-each\u002Fbuilding-a-cli-with-subcommands-in-click","Building a CLI with subcommands in Click",{"path":2865,"title":2866},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftyper-vs-click-when-to-use-each\u002Fbuilding-dynamic-commands-in-click","Building Dynamic Commands in Click",{"path":2868,"title":2869},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftyper-vs-click-when-to-use-each\u002Fconverting-a-click-app-to-typer","Converting a Click App to Typer",{"path":2871,"title":2872},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftyper-vs-click-when-to-use-each","Typer vs Click: When to Use Each",{"path":2874,"title":2875},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftyper-vs-click-when-to-use-each\u002Ftyper-callback-functions-explained","Typer callback functions explained",{"path":2877,"title":2878},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftyper-vs-click-when-to-use-each\u002Fusing-annotated-options-in-typer","Using Annotated Options in Typer",{"path":2880,"title":2881},"\u002Fproject-setup-dependency-management\u002Fci-cd-pipelines-for-python-clis\u002Fautomating-releases-from-git-tags","Automating Python CLI Releases from Git Tags",{"path":2883,"title":2884},"\u002Fproject-setup-dependency-management\u002Fci-cd-pipelines-for-python-clis\u002Fcaching-uv-dependencies-in-ci","Caching uv Dependencies in CI for Python CLIs",{"path":2886,"title":2887},"\u002Fproject-setup-dependency-management\u002Fci-cd-pipelines-for-python-clis","CI\u002FCD Pipelines for Python CLIs",{"path":2889,"title":2890},"\u002Fproject-setup-dependency-management\u002Fci-cd-pipelines-for-python-clis\u002Fpublishing-to-pypi-with-trusted-publishing","Publishing a CLI to PyPI with Trusted Publishing",{"path":2892,"title":2893},"\u002Fproject-setup-dependency-management\u002Fci-cd-pipelines-for-python-clis\u002Fsmoke-testing-the-built-wheel-in-ci","Smoke-Testing the Built Wheel of a Python CLI in CI",{"path":2895,"title":2896},"\u002Fproject-setup-dependency-management\u002Fci-cd-pipelines-for-python-clis\u002Ftesting-a-cli-across-python-versions-with-github-actions","Testing a CLI Across Python Versions in GitHub Actions",{"path":2898,"title":2899},"\u002Fproject-setup-dependency-management\u002Fcli-project-scaffolding-with-cookiecutter\u002Fbuilding-a-cookiecutter-template-for-typer-clis","Building a Cookiecutter Template for Typer CLIs",{"path":2901,"title":2902},"\u002Fproject-setup-dependency-management\u002Fcli-project-scaffolding-with-cookiecutter\u002Fcopier-vs-cookiecutter-for-cli-templates","Copier vs Cookiecutter for CLI Templates",{"path":2904,"title":2905},"\u002Fproject-setup-dependency-management\u002Fcli-project-scaffolding-with-cookiecutter","CLI Project Scaffolding with Cookiecutter",{"path":2907,"title":2908},"\u002Fproject-setup-dependency-management\u002Fcli-project-scaffolding-with-cookiecutter\u002Fpost-generation-hooks-in-cli-templates","Post-Generation Hooks in Python CLI Templates",{"path":2910,"title":2911},"\u002Fproject-setup-dependency-management\u002Fdistributing-clis-as-standalone-binaries\u002Fbuilding-cross-platform-release-binaries-in-ci","Building Cross-Platform Release Binaries in CI",{"path":2913,"title":2914},"\u002Fproject-setup-dependency-management\u002Fdistributing-clis-as-standalone-binaries\u002Fbundling-a-python-cli-with-pyinstaller","Bundling a Python CLI with PyInstaller",{"path":2916,"title":2917},"\u002Fproject-setup-dependency-management\u002Fdistributing-clis-as-standalone-binaries\u002Fhomebrew-and-scoop-packaging-for-python-clis","Homebrew and Scoop Packaging for Python CLIs",{"path":2919,"title":2920},"\u002Fproject-setup-dependency-management\u002Fdistributing-clis-as-standalone-binaries","Distributing CLIs as Standalone Binaries",{"path":2922,"title":2923},"\u002Fproject-setup-dependency-management\u002Fdistributing-clis-as-standalone-binaries\u002Fnuitka-vs-pyinstaller-for-python-clis","Nuitka vs PyInstaller for Python CLI Binaries",{"path":2925,"title":2926},"\u002Fproject-setup-dependency-management\u002Fdistributing-clis-as-standalone-binaries\u002Fshipping-a-cli-as-a-zipapp-with-shiv","Shipping a CLI as a Zipapp with shiv",{"path":2928,"title":2929},"\u002Fproject-setup-dependency-management","Project Setup & Dependency Management",{"path":2931,"title":2932},"\u002Fproject-setup-dependency-management\u002Flinting-and-type-checking-cli-code\u002Fconfiguring-ruff-for-a-cli-project","Configuring Ruff for a Python CLI Project",{"path":2934,"title":2935},"\u002Fproject-setup-dependency-management\u002Flinting-and-type-checking-cli-code\u002Fenforcing-import-boundaries-in-a-cli-codebase","Enforcing Import Boundaries in a Python CLI Codebase",{"path":2937,"title":2938},"\u002Fproject-setup-dependency-management\u002Flinting-and-type-checking-cli-code","Linting and Type-Checking Python CLI Code",{"path":2940,"title":2941},"\u002Fproject-setup-dependency-management\u002Flinting-and-type-checking-cli-code\u002Ftype-checking-click-and-typer-code-with-mypy","Type-Checking Click and Typer Code with mypy",{"path":2943,"title":2944},"\u002Fproject-setup-dependency-management\u002Fmanaging-cli-versioning-changelogs\u002Fautomating-changelogs-with-conventional-commits","Automating Changelogs with Conventional Commits",{"path":2946,"title":2947},"\u002Fproject-setup-dependency-management\u002Fmanaging-cli-versioning-changelogs\u002Fderiving-versions-from-git-tags-with-hatch-vcs","Deriving CLI Versions from Git Tags with hatch-vcs",{"path":2949,"title":2950},"\u002Fproject-setup-dependency-management\u002Fmanaging-cli-versioning-changelogs\u002Fexposing-version-info-and-build-metadata","Exposing Version Info and Build Metadata",{"path":2952,"title":2953},"\u002Fproject-setup-dependency-management\u002Fmanaging-cli-versioning-changelogs","Managing CLI Versioning & Changelogs",{"path":2955,"title":2956},"\u002Fproject-setup-dependency-management\u002Fmanaging-cli-versioning-changelogs\u002Fsemantic-versioning-policy-for-cli-tools","A Semantic Versioning Policy for CLI Tools",{"path":2958,"title":2959},"\u002Fproject-setup-dependency-management\u002Fpackaging-python-clis-for-distribution\u002Fbuilding-wheels-and-sdists-for-python-clis","Building Wheels and sdists for Python CLIs",{"path":2961,"title":2962},"\u002Fproject-setup-dependency-management\u002Fpackaging-python-clis-for-distribution\u002Fbundling-data-files-with-importlib-resources","Bundling Data Files with importlib.resources in CLIs",{"path":2964,"title":2965},"\u002Fproject-setup-dependency-management\u002Fpackaging-python-clis-for-distribution","Packaging Python CLIs for Distribution",{"path":2967,"title":2968},"\u002Fproject-setup-dependency-management\u002Fpackaging-python-clis-for-distribution\u002Finstalling-and-distributing-clis-with-pipx","Installing and Distributing CLIs with pipx",{"path":2970,"title":2971},"\u002Fproject-setup-dependency-management\u002Fpackaging-python-clis-for-distribution\u002Fpublishing-a-python-cli-to-pypi","Publishing a Python CLI to PyPI",{"path":2973,"title":2974},"\u002Fproject-setup-dependency-management\u002Fpackaging-python-clis-for-distribution\u002Fwriting-pyproject-toml-metadata-for-a-cli","Writing pyproject.toml Metadata for a Python CLI",{"path":2976,"title":2977},"\u002Fproject-setup-dependency-management\u002Fpoetry-workflows-for-cli-development","Poetry Workflows for CLI Development",{"path":2979,"title":2980},"\u002Fproject-setup-dependency-management\u002Fpoetry-workflows-for-cli-development\u002Fmigrating-a-cli-from-poetry-to-uv","Migrating a Python CLI from Poetry to uv",{"path":2982,"title":2983},"\u002Fproject-setup-dependency-management\u002Fpoetry-workflows-for-cli-development\u002Fpoetry-dependency-groups-for-cli-tooling","Poetry Dependency Groups for CLI Tooling",{"path":2985,"title":2986},"\u002Fproject-setup-dependency-management\u002Fpoetry-workflows-for-cli-development\u002Fpoetry-entry-points-and-scripts-for-clis","Poetry Entry Points and Scripts for CLIs",{"path":2988,"title":2989},"\u002Fproject-setup-dependency-management\u002Fpre-commit-hooks-for-cli-projects","Pre-commit Hooks for CLI Projects",{"path":2991,"title":2992},"\u002Fproject-setup-dependency-management\u002Fpre-commit-hooks-for-cli-projects\u002Fsetting-up-pre-commit-for-python-cli-repos","Setting up pre-commit for Python CLI repos",{"path":2994,"title":2995},"\u002Fproject-setup-dependency-management\u002Fpre-commit-hooks-for-cli-projects\u002Fshipping-your-cli-as-a-pre-commit-hook","Shipping Your Python CLI as a pre-commit Hook",{"path":2997,"title":2998},"\u002Fproject-setup-dependency-management\u002Fpre-commit-hooks-for-cli-projects\u002Fwriting-local-pre-commit-hooks-in-python","Writing Local pre-commit Hooks in Python",{"path":3000,"title":3001},"\u002Fproject-setup-dependency-management\u002Fuv-for-python-cli-dependency-management","uv for Python CLI Dependency Management",{"path":3003,"title":3004},"\u002Fproject-setup-dependency-management\u002Fuv-for-python-cli-dependency-management\u002Frunning-one-off-cli-scripts-with-uv-run","Running One-Off CLI Scripts with uv run and PEP 723",{"path":3006,"title":3007},"\u002Fproject-setup-dependency-management\u002Fuv-for-python-cli-dependency-management\u002Fuv-init-vs-poetry-init-for-cli-tools","uv init vs poetry init for CLI tools",{"path":3009,"title":3010},"\u002Fproject-setup-dependency-management\u002Fuv-for-python-cli-dependency-management\u002Fuv-tool-install-vs-pipx-for-clis","uv tool install vs pipx for CLIs",{"path":3012,"title":3013},"\u002Fproject-setup-dependency-management\u002Fuv-for-python-cli-dependency-management\u002Fuv-workspaces-for-multi-package-clis","uv Workspaces for Multi-Package Python CLIs",{"path":3015,"title":3016},"\u002Fproject-setup-dependency-management\u002Fvirtual-environments-isolation-best-practices","Python CLI Env Isolation Best Practices",{"path":3018,"title":3019},"\u002Fproject-setup-dependency-management\u002Fvirtual-environments-isolation-best-practices\u002Fmanaging-virtual-environments-for-cross-platform-clis","Managing Python CLI Virtual Environments",{"path":3021,"title":3022},"\u002Fproject-setup-dependency-management\u002Fvirtual-environments-isolation-best-practices\u002Fpinning-the-python-version-for-a-cli","Pinning the Python Version for a CLI",{"path":3024,"title":3025},"\u002Fproject-setup-dependency-management\u002Fvirtual-environments-isolation-best-practices\u002Fsupporting-multiple-python-versions-with-nox","Supporting Multiple Python Versions with nox",1789736905051]