[{"data":1,"prerenderedAt":4145},["ShallowReactive",2],{"page-\u002Fcli-runtime-systems-integration\u002Flocal-state-and-sqlite-in-python-clis\u002Fcaching-http-responses-on-disk-in-a-cli\u002F":3,"content-directory":3301},{"id":4,"title":5,"body":6,"date":3286,"description":3287,"difficulty":3288,"draft":3289,"extension":3290,"meta":3291,"navigation":172,"path":3292,"seo":3293,"stem":3294,"tags":3295,"updated":3286,"__hash__":3300},"content\u002Fcli-runtime-systems-integration\u002Flocal-state-and-sqlite-in-python-clis\u002Fcaching-http-responses-on-disk-in-a-cli\u002Findex.md","Caching HTTP Responses on Disk in a Python CLI",{"type":7,"value":8,"toc":3268},"minimark",[9,32,37,74,78,84,88,127,131,1639,1661,1664,1669,1681,1685,2223,2227,2287,2290,2294,2303,3158,3165,3169,3186,3190,3194,3197,3201,3210,3214,3217,3221,3228,3232,3264],[10,11,12,13,17,18,21,22,25,26,31],"p",{},"A CLI that talks to an API repeats itself constantly. ",[14,15,16],"code",{},"mytool show 42"," fetches ticket 42; a minute later ",[14,19,20],{},"mytool show 42 --json | jq .status"," fetches it again; the shell completion for ticket numbers fetches the whole list on every Tab. Each request costs latency the user feels, counts against a rate limit, and fails outright on a train with no signal. A small disk cache fixes all three: answers for recently fetched URLs come from local storage in a millisecond, revalidation with ",[14,23,24],{},"ETag"," makes refreshes nearly free, and stale data can stand in when the network is gone. This guide builds that cache on SQLite with httpx, with the expiry, size limits and user controls that keep it from becoming a source of confusing stale results. It belongs to the ",[27,28,30],"a",{"href":29},"\u002Fcli-runtime-systems-integration\u002Flocal-state-and-sqlite-in-python-clis\u002F","SQLite state topic",".",[33,34,36],"h2",{"id":35},"prerequisites","Prerequisites",[38,39,40,60,67],"ul",{},[41,42,43,44,47,48,51,52,55,56,59],"li",{},"Python 3.10+, ",[14,45,46],{},"httpx",", ",[14,49,50],{},"platformdirs","; ",[14,53,54],{},"respx"," and ",[14,57,58],{},"pytest"," for tests.",[41,61,62,63,31],{},"An API client along the lines of ",[27,64,66],{"href":65},"\u002Fcli-runtime-systems-integration\u002Fcalling-http-apis-from-python-clis\u002Fbuilding-an-api-client-cli-with-httpx\u002F","building an API client CLI with httpx",[41,68,69,70,73],{},"A clear idea of which endpoints are safe to cache. Only cache ",[14,71,72],{},"GET"," requests whose answers are the same for every call with the same URL and credentials.",[33,75,77],{"id":76},"how-the-cache-decides","How the cache decides",[10,79,80,81,83],{},"For each ",[14,82,72],{},", the cache has four possible answers, and the order of checks matters:",[85,86],"inline-diagram",{"name":87},"sql-cache-decision",[89,90,91,98,115,121],"ol",{},[41,92,93,97],{},[94,95,96],"strong",{},"Fresh hit"," — a stored response younger than its time-to-live. Return it without touching the network.",[41,99,100,103,104,106,107,110,111,114],{},[94,101,102],{},"Stale with a validator"," — the stored response is old, but it has an ",[14,105,24],{}," (or ",[14,108,109],{},"Last-Modified","). Send a conditional request; a ",[14,112,113],{},"304 Not Modified"," answer refreshes the timestamp and returns the stored body, at the cost of a tiny response.",[41,116,117,120],{},[94,118,119],{},"Miss"," — nothing stored, or stale without a validator. Fetch normally and store the result if it is cacheable.",[41,122,123,126],{},[94,124,125],{},"Network failure with stale data"," — return the stale response and tell the user it is stale. Without stale data, the error propagates as usual.",[33,128,130],{"id":129},"the-recipe","The recipe",[132,133,138],"pre",{"className":134,"code":135,"language":136,"meta":137,"style":137},"language-python shiki shiki-themes github-light github-dark","# src\u002Ftickets\u002Fhttpcache.py\nfrom __future__ import annotations\n\nimport json\nimport sqlite3\nimport time\nfrom dataclasses import dataclass\nfrom pathlib import Path\n\nimport httpx\n\nSCHEMA = \"\"\"\nCREATE TABLE IF NOT EXISTS responses (\n    key TEXT PRIMARY KEY,\n    status INTEGER NOT NULL,\n    headers TEXT NOT NULL,\n    body BLOB NOT NULL,\n    etag TEXT,\n    fetched_at REAL NOT NULL,\n    size INTEGER NOT NULL\n)\"\"\"\n\n\n@dataclass\nclass CachedResponse:\n    status: int\n    headers: dict[str, str]\n    body: bytes\n    age: float\n    stale: bool = False\n\n    def json(self):\n        return json.loads(self.body)\n\n\nclass HttpCache:\n    def __init__(self, path: Path, *, max_bytes: int = 50_000_000) -> None:\n        path.parent.mkdir(parents=True, exist_ok=True)\n        try:\n            self.conn = self._open(path)\n        except sqlite3.DatabaseError:            # corrupt cache: throw it away\n            path.unlink(missing_ok=True)\n            self.conn = self._open(path)\n        self.max_bytes = max_bytes\n\n    @staticmethod\n    def _open(path: Path) -> sqlite3.Connection:\n        conn = sqlite3.connect(path, timeout=5.0)\n        conn.execute(\"PRAGMA journal_mode = WAL\")\n        conn.execute(SCHEMA)\n        return conn\n\n    def get(self, key: str) -> CachedResponse | None:\n        row = self.conn.execute(\n            \"SELECT status, headers, body, fetched_at FROM responses WHERE key = ?\", (key,)\n        ).fetchone()\n        if row is None:\n            return None\n        status, headers, body, fetched_at = row\n        return CachedResponse(status, json.loads(headers), body, time.time() - fetched_at)\n\n    def etag(self, key: str) -> str | None:\n        row = self.conn.execute(\"SELECT etag FROM responses WHERE key = ?\", (key,)).fetchone()\n        return row[0] if row else None\n\n    def put(self, key: str, response: httpx.Response) -> None:\n        body = response.content\n        headers = {k: v for k, v in response.headers.items() if k.lower() in\n                   (\"content-type\", \"etag\", \"last-modified\")}\n        with self.conn:\n            self.conn.execute(\n                \"INSERT OR REPLACE INTO responses VALUES (?, ?, ?, ?, ?, ?, ?)\",\n                (key, response.status_code, json.dumps(headers), body,\n                 response.headers.get(\"etag\"), time.time(), len(body)),\n            )\n        self.prune()\n\n    def touch(self, key: str) -> None:\n        with self.conn:\n            self.conn.execute(\"UPDATE responses SET fetched_at = ? WHERE key = ?\",\n                              (time.time(), key))\n\n    def prune(self) -> None:\n        \"\"\"Evict the oldest entries until the cache fits in max_bytes.\"\"\"\n        total = self.conn.execute(\"SELECT COALESCE(SUM(size), 0) FROM responses\").fetchone()[0]\n        if total \u003C= self.max_bytes:\n            return\n        with self.conn:\n            for key, size in self.conn.execute(\n                    \"SELECT key, size FROM responses ORDER BY fetched_at\").fetchall():\n                self.conn.execute(\"DELETE FROM responses WHERE key = ?\", (key,))\n                total -= size\n                if total \u003C= self.max_bytes:\n                    break\n\n    def clear(self) -> int:\n        with self.conn:\n            return self.conn.execute(\"DELETE FROM responses\").rowcount\n\n\ndef cached_get(client: httpx.Client, cache: HttpCache, url: str, *, ttl: float = 300,\n               refresh: bool = False, use_cache: bool = True) -> CachedResponse:\n    key = str(client.build_request(\"GET\", url).url)          # normalised absolute URL\n    if not use_cache:\n        r = client.get(url)\n        r.raise_for_status()\n        return CachedResponse(r.status_code, dict(r.headers), r.content, 0.0)\n    stored = cache.get(key)\n    if stored and stored.age \u003C ttl and not refresh:\n        return stored                                         # 1. fresh hit\n    headers = {}\n    if stored and (tag := cache.etag(key)):\n        headers[\"If-None-Match\"] = tag                        # 2. revalidate\n    try:\n        r = client.get(url, headers=headers)\n    except httpx.TransportError:\n        if stored:\n            stored.stale = True                               # 4. offline fallback\n            return stored\n        raise\n    if r.status_code == 304 and stored:\n        cache.touch(key)\n        stored.age = 0.0\n        return stored\n    r.raise_for_status()\n    if \"no-store\" not in r.headers.get(\"cache-control\", \"\"):\n        cache.put(key, r)                                     # 3. store the miss\n    return CachedResponse(r.status_code, dict(r.headers), r.content, 0.0)\n","python","",[14,139,140,149,167,174,183,191,199,212,225,230,238,243,256,262,268,274,280,286,292,298,304,310,315,320,327,339,348,364,373,382,396,401,413,428,433,438,448,481,509,517,534,546,561,574,588,593,602,613,634,645,654,662,667,691,704,713,719,735,744,755,769,774,797,815,839,844,863,874,905,927,938,945,954,960,977,983,991,996,1014,1023,1035,1041,1046,1061,1067,1089,1105,1111,1120,1135,1144,1158,1170,1184,1190,1195,1209,1218,1233,1238,1243,1274,1300,1323,1335,1346,1352,1371,1382,1409,1420,1431,1449,1468,1476,1494,1503,1511,1524,1532,1538,1557,1563,1574,1581,1587,1614,1623],{"__ignoreMap":137},[141,142,145],"span",{"class":143,"line":144},"line",1,[141,146,148],{"class":147},"sJ8bj","# src\u002Ftickets\u002Fhttpcache.py\n",[141,150,152,156,160,163],{"class":143,"line":151},2,[141,153,155],{"class":154},"szBVR","from",[141,157,159],{"class":158},"sj4cs"," __future__",[141,161,162],{"class":154}," import",[141,164,166],{"class":165},"sVt8B"," annotations\n",[141,168,170],{"class":143,"line":169},3,[141,171,173],{"emptyLinePlaceholder":172},true,"\n",[141,175,177,180],{"class":143,"line":176},4,[141,178,179],{"class":154},"import",[141,181,182],{"class":165}," json\n",[141,184,186,188],{"class":143,"line":185},5,[141,187,179],{"class":154},[141,189,190],{"class":165}," sqlite3\n",[141,192,194,196],{"class":143,"line":193},6,[141,195,179],{"class":154},[141,197,198],{"class":165}," time\n",[141,200,202,204,207,209],{"class":143,"line":201},7,[141,203,155],{"class":154},[141,205,206],{"class":165}," dataclasses ",[141,208,179],{"class":154},[141,210,211],{"class":165}," dataclass\n",[141,213,215,217,220,222],{"class":143,"line":214},8,[141,216,155],{"class":154},[141,218,219],{"class":165}," pathlib ",[141,221,179],{"class":154},[141,223,224],{"class":165}," Path\n",[141,226,228],{"class":143,"line":227},9,[141,229,173],{"emptyLinePlaceholder":172},[141,231,233,235],{"class":143,"line":232},10,[141,234,179],{"class":154},[141,236,237],{"class":165}," httpx\n",[141,239,241],{"class":143,"line":240},11,[141,242,173],{"emptyLinePlaceholder":172},[141,244,246,249,252],{"class":143,"line":245},12,[141,247,248],{"class":158},"SCHEMA",[141,250,251],{"class":154}," =",[141,253,255],{"class":254},"sZZnC"," \"\"\"\n",[141,257,259],{"class":143,"line":258},13,[141,260,261],{"class":254},"CREATE TABLE IF NOT EXISTS responses (\n",[141,263,265],{"class":143,"line":264},14,[141,266,267],{"class":254},"    key TEXT PRIMARY KEY,\n",[141,269,271],{"class":143,"line":270},15,[141,272,273],{"class":254},"    status INTEGER NOT NULL,\n",[141,275,277],{"class":143,"line":276},16,[141,278,279],{"class":254},"    headers TEXT NOT NULL,\n",[141,281,283],{"class":143,"line":282},17,[141,284,285],{"class":254},"    body BLOB NOT NULL,\n",[141,287,289],{"class":143,"line":288},18,[141,290,291],{"class":254},"    etag TEXT,\n",[141,293,295],{"class":143,"line":294},19,[141,296,297],{"class":254},"    fetched_at REAL NOT NULL,\n",[141,299,301],{"class":143,"line":300},20,[141,302,303],{"class":254},"    size INTEGER NOT NULL\n",[141,305,307],{"class":143,"line":306},21,[141,308,309],{"class":254},")\"\"\"\n",[141,311,313],{"class":143,"line":312},22,[141,314,173],{"emptyLinePlaceholder":172},[141,316,318],{"class":143,"line":317},23,[141,319,173],{"emptyLinePlaceholder":172},[141,321,323],{"class":143,"line":322},24,[141,324,326],{"class":325},"sScJk","@dataclass\n",[141,328,330,333,336],{"class":143,"line":329},25,[141,331,332],{"class":154},"class",[141,334,335],{"class":325}," CachedResponse",[141,337,338],{"class":165},":\n",[141,340,342,345],{"class":143,"line":341},26,[141,343,344],{"class":165},"    status: ",[141,346,347],{"class":158},"int\n",[141,349,351,354,357,359,361],{"class":143,"line":350},27,[141,352,353],{"class":165},"    headers: dict[",[141,355,356],{"class":158},"str",[141,358,47],{"class":165},[141,360,356],{"class":158},[141,362,363],{"class":165},"]\n",[141,365,367,370],{"class":143,"line":366},28,[141,368,369],{"class":165},"    body: ",[141,371,372],{"class":158},"bytes\n",[141,374,376,379],{"class":143,"line":375},29,[141,377,378],{"class":165},"    age: ",[141,380,381],{"class":158},"float\n",[141,383,385,388,391,393],{"class":143,"line":384},30,[141,386,387],{"class":165},"    stale: ",[141,389,390],{"class":158},"bool",[141,392,251],{"class":154},[141,394,395],{"class":158}," False\n",[141,397,399],{"class":143,"line":398},31,[141,400,173],{"emptyLinePlaceholder":172},[141,402,404,407,410],{"class":143,"line":403},32,[141,405,406],{"class":154},"    def",[141,408,409],{"class":325}," json",[141,411,412],{"class":165},"(self):\n",[141,414,416,419,422,425],{"class":143,"line":415},33,[141,417,418],{"class":154},"        return",[141,420,421],{"class":165}," json.loads(",[141,423,424],{"class":158},"self",[141,426,427],{"class":165},".body)\n",[141,429,431],{"class":143,"line":430},34,[141,432,173],{"emptyLinePlaceholder":172},[141,434,436],{"class":143,"line":435},35,[141,437,173],{"emptyLinePlaceholder":172},[141,439,441,443,446],{"class":143,"line":440},36,[141,442,332],{"class":154},[141,444,445],{"class":325}," HttpCache",[141,447,338],{"class":165},[141,449,451,453,456,459,462,465,468,470,473,476,479],{"class":143,"line":450},37,[141,452,406],{"class":154},[141,454,455],{"class":158}," __init__",[141,457,458],{"class":165},"(self, path: Path, ",[141,460,461],{"class":154},"*",[141,463,464],{"class":165},", max_bytes: ",[141,466,467],{"class":158},"int",[141,469,251],{"class":154},[141,471,472],{"class":158}," 50_000_000",[141,474,475],{"class":165},") -> ",[141,477,478],{"class":158},"None",[141,480,338],{"class":165},[141,482,484,487,491,494,497,499,502,504,506],{"class":143,"line":483},38,[141,485,486],{"class":165},"        path.parent.mkdir(",[141,488,490],{"class":489},"s4XuR","parents",[141,492,493],{"class":154},"=",[141,495,496],{"class":158},"True",[141,498,47],{"class":165},[141,500,501],{"class":489},"exist_ok",[141,503,493],{"class":154},[141,505,496],{"class":158},[141,507,508],{"class":165},")\n",[141,510,512,515],{"class":143,"line":511},39,[141,513,514],{"class":154},"        try",[141,516,338],{"class":165},[141,518,520,523,526,528,531],{"class":143,"line":519},40,[141,521,522],{"class":158},"            self",[141,524,525],{"class":165},".conn ",[141,527,493],{"class":154},[141,529,530],{"class":158}," self",[141,532,533],{"class":165},"._open(path)\n",[141,535,537,540,543],{"class":143,"line":536},41,[141,538,539],{"class":154},"        except",[141,541,542],{"class":165}," sqlite3.DatabaseError:            ",[141,544,545],{"class":147},"# corrupt cache: throw it away\n",[141,547,549,552,555,557,559],{"class":143,"line":548},42,[141,550,551],{"class":165},"            path.unlink(",[141,553,554],{"class":489},"missing_ok",[141,556,493],{"class":154},[141,558,496],{"class":158},[141,560,508],{"class":165},[141,562,564,566,568,570,572],{"class":143,"line":563},43,[141,565,522],{"class":158},[141,567,525],{"class":165},[141,569,493],{"class":154},[141,571,530],{"class":158},[141,573,533],{"class":165},[141,575,577,580,583,585],{"class":143,"line":576},44,[141,578,579],{"class":158},"        self",[141,581,582],{"class":165},".max_bytes ",[141,584,493],{"class":154},[141,586,587],{"class":165}," max_bytes\n",[141,589,591],{"class":143,"line":590},45,[141,592,173],{"emptyLinePlaceholder":172},[141,594,596,599],{"class":143,"line":595},46,[141,597,598],{"class":325},"    @",[141,600,601],{"class":158},"staticmethod\n",[141,603,605,607,610],{"class":143,"line":604},47,[141,606,406],{"class":154},[141,608,609],{"class":325}," _open",[141,611,612],{"class":165},"(path: Path) -> sqlite3.Connection:\n",[141,614,616,619,621,624,627,629,632],{"class":143,"line":615},48,[141,617,618],{"class":165},"        conn ",[141,620,493],{"class":154},[141,622,623],{"class":165}," sqlite3.connect(path, ",[141,625,626],{"class":489},"timeout",[141,628,493],{"class":154},[141,630,631],{"class":158},"5.0",[141,633,508],{"class":165},[141,635,637,640,643],{"class":143,"line":636},49,[141,638,639],{"class":165},"        conn.execute(",[141,641,642],{"class":254},"\"PRAGMA journal_mode = WAL\"",[141,644,508],{"class":165},[141,646,648,650,652],{"class":143,"line":647},50,[141,649,639],{"class":165},[141,651,248],{"class":158},[141,653,508],{"class":165},[141,655,657,659],{"class":143,"line":656},51,[141,658,418],{"class":154},[141,660,661],{"class":165}," conn\n",[141,663,665],{"class":143,"line":664},52,[141,666,173],{"emptyLinePlaceholder":172},[141,668,670,672,675,678,680,683,686,689],{"class":143,"line":669},53,[141,671,406],{"class":154},[141,673,674],{"class":325}," get",[141,676,677],{"class":165},"(self, key: ",[141,679,356],{"class":158},[141,681,682],{"class":165},") -> CachedResponse ",[141,684,685],{"class":154},"|",[141,687,688],{"class":158}," None",[141,690,338],{"class":165},[141,692,694,697,699,701],{"class":143,"line":693},54,[141,695,696],{"class":165},"        row ",[141,698,493],{"class":154},[141,700,530],{"class":158},[141,702,703],{"class":165},".conn.execute(\n",[141,705,707,710],{"class":143,"line":706},55,[141,708,709],{"class":254},"            \"SELECT status, headers, body, fetched_at FROM responses WHERE key = ?\"",[141,711,712],{"class":165},", (key,)\n",[141,714,716],{"class":143,"line":715},56,[141,717,718],{"class":165},"        ).fetchone()\n",[141,720,722,725,728,731,733],{"class":143,"line":721},57,[141,723,724],{"class":154},"        if",[141,726,727],{"class":165}," row ",[141,729,730],{"class":154},"is",[141,732,688],{"class":158},[141,734,338],{"class":165},[141,736,738,741],{"class":143,"line":737},58,[141,739,740],{"class":154},"            return",[141,742,743],{"class":158}," None\n",[141,745,747,750,752],{"class":143,"line":746},59,[141,748,749],{"class":165},"        status, headers, body, fetched_at ",[141,751,493],{"class":154},[141,753,754],{"class":165}," row\n",[141,756,758,760,763,766],{"class":143,"line":757},60,[141,759,418],{"class":154},[141,761,762],{"class":165}," CachedResponse(status, json.loads(headers), body, time.time() ",[141,764,765],{"class":154},"-",[141,767,768],{"class":165}," fetched_at)\n",[141,770,772],{"class":143,"line":771},61,[141,773,173],{"emptyLinePlaceholder":172},[141,775,777,779,782,784,786,788,790,793,795],{"class":143,"line":776},62,[141,778,406],{"class":154},[141,780,781],{"class":325}," etag",[141,783,677],{"class":165},[141,785,356],{"class":158},[141,787,475],{"class":165},[141,789,356],{"class":158},[141,791,792],{"class":154}," |",[141,794,688],{"class":158},[141,796,338],{"class":165},[141,798,800,802,804,806,809,812],{"class":143,"line":799},63,[141,801,696],{"class":165},[141,803,493],{"class":154},[141,805,530],{"class":158},[141,807,808],{"class":165},".conn.execute(",[141,810,811],{"class":254},"\"SELECT etag FROM responses WHERE key = ?\"",[141,813,814],{"class":165},", (key,)).fetchone()\n",[141,816,818,820,823,826,829,832,834,837],{"class":143,"line":817},64,[141,819,418],{"class":154},[141,821,822],{"class":165}," row[",[141,824,825],{"class":158},"0",[141,827,828],{"class":165},"] ",[141,830,831],{"class":154},"if",[141,833,727],{"class":165},[141,835,836],{"class":154},"else",[141,838,743],{"class":158},[141,840,842],{"class":143,"line":841},65,[141,843,173],{"emptyLinePlaceholder":172},[141,845,847,849,852,854,856,859,861],{"class":143,"line":846},66,[141,848,406],{"class":154},[141,850,851],{"class":325}," put",[141,853,677],{"class":165},[141,855,356],{"class":158},[141,857,858],{"class":165},", response: httpx.Response) -> ",[141,860,478],{"class":158},[141,862,338],{"class":165},[141,864,866,869,871],{"class":143,"line":865},67,[141,867,868],{"class":165},"        body ",[141,870,493],{"class":154},[141,872,873],{"class":165}," response.content\n",[141,875,877,880,882,885,888,891,894,897,899,902],{"class":143,"line":876},68,[141,878,879],{"class":165},"        headers ",[141,881,493],{"class":154},[141,883,884],{"class":165}," {k: v ",[141,886,887],{"class":154},"for",[141,889,890],{"class":165}," k, v ",[141,892,893],{"class":154},"in",[141,895,896],{"class":165}," response.headers.items() ",[141,898,831],{"class":154},[141,900,901],{"class":165}," k.lower() ",[141,903,904],{"class":154},"in\n",[141,906,908,911,914,916,919,921,924],{"class":143,"line":907},69,[141,909,910],{"class":165},"                   (",[141,912,913],{"class":254},"\"content-type\"",[141,915,47],{"class":165},[141,917,918],{"class":254},"\"etag\"",[141,920,47],{"class":165},[141,922,923],{"class":254},"\"last-modified\"",[141,925,926],{"class":165},")}\n",[141,928,930,933,935],{"class":143,"line":929},70,[141,931,932],{"class":154},"        with",[141,934,530],{"class":158},[141,936,937],{"class":165},".conn:\n",[141,939,941,943],{"class":143,"line":940},71,[141,942,522],{"class":158},[141,944,703],{"class":165},[141,946,948,951],{"class":143,"line":947},72,[141,949,950],{"class":254},"                \"INSERT OR REPLACE INTO responses VALUES (?, ?, ?, ?, ?, ?, ?)\"",[141,952,953],{"class":165},",\n",[141,955,957],{"class":143,"line":956},73,[141,958,959],{"class":165},"                (key, response.status_code, json.dumps(headers), body,\n",[141,961,963,966,968,971,974],{"class":143,"line":962},74,[141,964,965],{"class":165},"                 response.headers.get(",[141,967,918],{"class":254},[141,969,970],{"class":165},"), time.time(), ",[141,972,973],{"class":158},"len",[141,975,976],{"class":165},"(body)),\n",[141,978,980],{"class":143,"line":979},75,[141,981,982],{"class":165},"            )\n",[141,984,986,988],{"class":143,"line":985},76,[141,987,579],{"class":158},[141,989,990],{"class":165},".prune()\n",[141,992,994],{"class":143,"line":993},77,[141,995,173],{"emptyLinePlaceholder":172},[141,997,999,1001,1004,1006,1008,1010,1012],{"class":143,"line":998},78,[141,1000,406],{"class":154},[141,1002,1003],{"class":325}," touch",[141,1005,677],{"class":165},[141,1007,356],{"class":158},[141,1009,475],{"class":165},[141,1011,478],{"class":158},[141,1013,338],{"class":165},[141,1015,1017,1019,1021],{"class":143,"line":1016},79,[141,1018,932],{"class":154},[141,1020,530],{"class":158},[141,1022,937],{"class":165},[141,1024,1026,1028,1030,1033],{"class":143,"line":1025},80,[141,1027,522],{"class":158},[141,1029,808],{"class":165},[141,1031,1032],{"class":254},"\"UPDATE responses SET fetched_at = ? WHERE key = ?\"",[141,1034,953],{"class":165},[141,1036,1038],{"class":143,"line":1037},81,[141,1039,1040],{"class":165},"                              (time.time(), key))\n",[141,1042,1044],{"class":143,"line":1043},82,[141,1045,173],{"emptyLinePlaceholder":172},[141,1047,1049,1051,1054,1057,1059],{"class":143,"line":1048},83,[141,1050,406],{"class":154},[141,1052,1053],{"class":325}," prune",[141,1055,1056],{"class":165},"(self) -> ",[141,1058,478],{"class":158},[141,1060,338],{"class":165},[141,1062,1064],{"class":143,"line":1063},84,[141,1065,1066],{"class":254},"        \"\"\"Evict the oldest entries until the cache fits in max_bytes.\"\"\"\n",[141,1068,1070,1073,1075,1077,1079,1082,1085,1087],{"class":143,"line":1069},85,[141,1071,1072],{"class":165},"        total ",[141,1074,493],{"class":154},[141,1076,530],{"class":158},[141,1078,808],{"class":165},[141,1080,1081],{"class":254},"\"SELECT COALESCE(SUM(size), 0) FROM responses\"",[141,1083,1084],{"class":165},").fetchone()[",[141,1086,825],{"class":158},[141,1088,363],{"class":165},[141,1090,1092,1094,1097,1100,1102],{"class":143,"line":1091},86,[141,1093,724],{"class":154},[141,1095,1096],{"class":165}," total ",[141,1098,1099],{"class":154},"\u003C=",[141,1101,530],{"class":158},[141,1103,1104],{"class":165},".max_bytes:\n",[141,1106,1108],{"class":143,"line":1107},87,[141,1109,1110],{"class":154},"            return\n",[141,1112,1114,1116,1118],{"class":143,"line":1113},88,[141,1115,932],{"class":154},[141,1117,530],{"class":158},[141,1119,937],{"class":165},[141,1121,1123,1126,1129,1131,1133],{"class":143,"line":1122},89,[141,1124,1125],{"class":154},"            for",[141,1127,1128],{"class":165}," key, size ",[141,1130,893],{"class":154},[141,1132,530],{"class":158},[141,1134,703],{"class":165},[141,1136,1138,1141],{"class":143,"line":1137},90,[141,1139,1140],{"class":254},"                    \"SELECT key, size FROM responses ORDER BY fetched_at\"",[141,1142,1143],{"class":165},").fetchall():\n",[141,1145,1147,1150,1152,1155],{"class":143,"line":1146},91,[141,1148,1149],{"class":158},"                self",[141,1151,808],{"class":165},[141,1153,1154],{"class":254},"\"DELETE FROM responses WHERE key = ?\"",[141,1156,1157],{"class":165},", (key,))\n",[141,1159,1161,1164,1167],{"class":143,"line":1160},92,[141,1162,1163],{"class":165},"                total ",[141,1165,1166],{"class":154},"-=",[141,1168,1169],{"class":165}," size\n",[141,1171,1173,1176,1178,1180,1182],{"class":143,"line":1172},93,[141,1174,1175],{"class":154},"                if",[141,1177,1096],{"class":165},[141,1179,1099],{"class":154},[141,1181,530],{"class":158},[141,1183,1104],{"class":165},[141,1185,1187],{"class":143,"line":1186},94,[141,1188,1189],{"class":154},"                    break\n",[141,1191,1193],{"class":143,"line":1192},95,[141,1194,173],{"emptyLinePlaceholder":172},[141,1196,1198,1200,1203,1205,1207],{"class":143,"line":1197},96,[141,1199,406],{"class":154},[141,1201,1202],{"class":325}," clear",[141,1204,1056],{"class":165},[141,1206,467],{"class":158},[141,1208,338],{"class":165},[141,1210,1212,1214,1216],{"class":143,"line":1211},97,[141,1213,932],{"class":154},[141,1215,530],{"class":158},[141,1217,937],{"class":165},[141,1219,1221,1223,1225,1227,1230],{"class":143,"line":1220},98,[141,1222,740],{"class":154},[141,1224,530],{"class":158},[141,1226,808],{"class":165},[141,1228,1229],{"class":254},"\"DELETE FROM responses\"",[141,1231,1232],{"class":165},").rowcount\n",[141,1234,1236],{"class":143,"line":1235},99,[141,1237,173],{"emptyLinePlaceholder":172},[141,1239,1241],{"class":143,"line":1240},100,[141,1242,173],{"emptyLinePlaceholder":172},[141,1244,1246,1249,1252,1255,1257,1259,1261,1264,1267,1269,1272],{"class":143,"line":1245},101,[141,1247,1248],{"class":154},"def",[141,1250,1251],{"class":325}," cached_get",[141,1253,1254],{"class":165},"(client: httpx.Client, cache: HttpCache, url: ",[141,1256,356],{"class":158},[141,1258,47],{"class":165},[141,1260,461],{"class":154},[141,1262,1263],{"class":165},", ttl: ",[141,1265,1266],{"class":158},"float",[141,1268,251],{"class":154},[141,1270,1271],{"class":158}," 300",[141,1273,953],{"class":165},[141,1275,1277,1280,1282,1284,1287,1290,1292,1294,1297],{"class":143,"line":1276},102,[141,1278,1279],{"class":165},"               refresh: ",[141,1281,390],{"class":158},[141,1283,251],{"class":154},[141,1285,1286],{"class":158}," False",[141,1288,1289],{"class":165},", use_cache: ",[141,1291,390],{"class":158},[141,1293,251],{"class":154},[141,1295,1296],{"class":158}," True",[141,1298,1299],{"class":165},") -> CachedResponse:\n",[141,1301,1303,1306,1308,1311,1314,1317,1320],{"class":143,"line":1302},103,[141,1304,1305],{"class":165},"    key ",[141,1307,493],{"class":154},[141,1309,1310],{"class":158}," str",[141,1312,1313],{"class":165},"(client.build_request(",[141,1315,1316],{"class":254},"\"GET\"",[141,1318,1319],{"class":165},", url).url)          ",[141,1321,1322],{"class":147},"# normalised absolute URL\n",[141,1324,1326,1329,1332],{"class":143,"line":1325},104,[141,1327,1328],{"class":154},"    if",[141,1330,1331],{"class":154}," not",[141,1333,1334],{"class":165}," use_cache:\n",[141,1336,1338,1341,1343],{"class":143,"line":1337},105,[141,1339,1340],{"class":165},"        r ",[141,1342,493],{"class":154},[141,1344,1345],{"class":165}," client.get(url)\n",[141,1347,1349],{"class":143,"line":1348},106,[141,1350,1351],{"class":165},"        r.raise_for_status()\n",[141,1353,1355,1357,1360,1363,1366,1369],{"class":143,"line":1354},107,[141,1356,418],{"class":154},[141,1358,1359],{"class":165}," CachedResponse(r.status_code, ",[141,1361,1362],{"class":158},"dict",[141,1364,1365],{"class":165},"(r.headers), r.content, ",[141,1367,1368],{"class":158},"0.0",[141,1370,508],{"class":165},[141,1372,1374,1377,1379],{"class":143,"line":1373},108,[141,1375,1376],{"class":165},"    stored ",[141,1378,493],{"class":154},[141,1380,1381],{"class":165}," cache.get(key)\n",[141,1383,1385,1387,1390,1393,1396,1399,1402,1404,1406],{"class":143,"line":1384},109,[141,1386,1328],{"class":154},[141,1388,1389],{"class":165}," stored ",[141,1391,1392],{"class":154},"and",[141,1394,1395],{"class":165}," stored.age ",[141,1397,1398],{"class":154},"\u003C",[141,1400,1401],{"class":165}," ttl ",[141,1403,1392],{"class":154},[141,1405,1331],{"class":154},[141,1407,1408],{"class":165}," refresh:\n",[141,1410,1412,1414,1417],{"class":143,"line":1411},110,[141,1413,418],{"class":154},[141,1415,1416],{"class":165}," stored                                         ",[141,1418,1419],{"class":147},"# 1. fresh hit\n",[141,1421,1423,1426,1428],{"class":143,"line":1422},111,[141,1424,1425],{"class":165},"    headers ",[141,1427,493],{"class":154},[141,1429,1430],{"class":165}," {}\n",[141,1432,1434,1436,1438,1440,1443,1446],{"class":143,"line":1433},112,[141,1435,1328],{"class":154},[141,1437,1389],{"class":165},[141,1439,1392],{"class":154},[141,1441,1442],{"class":165}," (tag ",[141,1444,1445],{"class":154},":=",[141,1447,1448],{"class":165}," cache.etag(key)):\n",[141,1450,1452,1455,1458,1460,1462,1465],{"class":143,"line":1451},113,[141,1453,1454],{"class":165},"        headers[",[141,1456,1457],{"class":254},"\"If-None-Match\"",[141,1459,828],{"class":165},[141,1461,493],{"class":154},[141,1463,1464],{"class":165}," tag                        ",[141,1466,1467],{"class":147},"# 2. revalidate\n",[141,1469,1471,1474],{"class":143,"line":1470},114,[141,1472,1473],{"class":154},"    try",[141,1475,338],{"class":165},[141,1477,1479,1481,1483,1486,1489,1491],{"class":143,"line":1478},115,[141,1480,1340],{"class":165},[141,1482,493],{"class":154},[141,1484,1485],{"class":165}," client.get(url, ",[141,1487,1488],{"class":489},"headers",[141,1490,493],{"class":154},[141,1492,1493],{"class":165},"headers)\n",[141,1495,1497,1500],{"class":143,"line":1496},116,[141,1498,1499],{"class":154},"    except",[141,1501,1502],{"class":165}," httpx.TransportError:\n",[141,1504,1506,1508],{"class":143,"line":1505},117,[141,1507,724],{"class":154},[141,1509,1510],{"class":165}," stored:\n",[141,1512,1514,1517,1519,1521],{"class":143,"line":1513},118,[141,1515,1516],{"class":165},"            stored.stale ",[141,1518,493],{"class":154},[141,1520,1296],{"class":158},[141,1522,1523],{"class":147},"                               # 4. offline fallback\n",[141,1525,1527,1529],{"class":143,"line":1526},119,[141,1528,740],{"class":154},[141,1530,1531],{"class":165}," stored\n",[141,1533,1535],{"class":143,"line":1534},120,[141,1536,1537],{"class":154},"        raise\n",[141,1539,1541,1543,1546,1549,1552,1555],{"class":143,"line":1540},121,[141,1542,1328],{"class":154},[141,1544,1545],{"class":165}," r.status_code ",[141,1547,1548],{"class":154},"==",[141,1550,1551],{"class":158}," 304",[141,1553,1554],{"class":154}," and",[141,1556,1510],{"class":165},[141,1558,1560],{"class":143,"line":1559},122,[141,1561,1562],{"class":165},"        cache.touch(key)\n",[141,1564,1566,1569,1571],{"class":143,"line":1565},123,[141,1567,1568],{"class":165},"        stored.age ",[141,1570,493],{"class":154},[141,1572,1573],{"class":158}," 0.0\n",[141,1575,1577,1579],{"class":143,"line":1576},124,[141,1578,418],{"class":154},[141,1580,1531],{"class":165},[141,1582,1584],{"class":143,"line":1583},125,[141,1585,1586],{"class":165},"    r.raise_for_status()\n",[141,1588,1590,1592,1595,1597,1600,1603,1606,1608,1611],{"class":143,"line":1589},126,[141,1591,1328],{"class":154},[141,1593,1594],{"class":254}," \"no-store\"",[141,1596,1331],{"class":154},[141,1598,1599],{"class":154}," in",[141,1601,1602],{"class":165}," r.headers.get(",[141,1604,1605],{"class":254},"\"cache-control\"",[141,1607,47],{"class":165},[141,1609,1610],{"class":254},"\"\"",[141,1612,1613],{"class":165},"):\n",[141,1615,1617,1620],{"class":143,"line":1616},127,[141,1618,1619],{"class":165},"        cache.put(key, r)                                     ",[141,1621,1622],{"class":147},"# 3. store the miss\n",[141,1624,1626,1629,1631,1633,1635,1637],{"class":143,"line":1625},128,[141,1627,1628],{"class":154},"    return",[141,1630,1359],{"class":165},[141,1632,1362],{"class":158},[141,1634,1365],{"class":165},[141,1636,1368],{"class":158},[141,1638,508],{"class":165},[10,1640,1641,1642,55,1645,1648,1649,1652,1653,1656,1657,1660],{},"The cache key is the fully built URL, including query parameters, so ",[14,1643,1644],{},"?page=2",[14,1646,1647],{},"?page=3"," are separate entries. Only successful responses are stored, because ",[14,1650,1651],{},"raise_for_status()"," runs first — caching a ",[14,1654,1655],{},"500"," would make an outage last as long as the TTL. Responses marked ",[14,1658,1659],{},"Cache-Control: no-store"," are never written, which respects servers that send sensitive data. And a corrupt cache file is deleted and recreated rather than reported, because nothing in a cache is worth an error.",[85,1662],{"name":1663},"sql-cache-terminal",[1665,1666,1668],"h3",{"id":1667},"credentials-and-the-cache-key","Credentials and the cache key",[10,1670,1671,1672,1676,1677,1680],{},"If different users or ",[27,1673,1675],{"href":1674},"\u002Fcli-runtime-systems-integration\u002Fsecrets-and-credentials-in-python-clis\u002Fsupporting-multiple-profiles-and-accounts\u002F","profiles"," can see different data at the same URL, the URL alone is not a safe key — one profile would be served another's cached answer. Include the profile or account name in the key (",[14,1678,1679],{},"f\"{profile}|{url}\"","), or keep one cache file per profile. Never include the token itself; the key is stored in plain text.",[1665,1682,1684],{"id":1683},"wiring-it-into-commands","Wiring it into commands",[132,1686,1688],{"className":134,"code":1687,"language":136,"meta":137,"style":137},"# src\u002Ftickets\u002Fcli.py\nimport httpx\nimport typer\nfrom platformdirs import user_cache_path\n\nfrom tickets.httpcache import HttpCache, cached_get\n\napp = typer.Typer()\nAPI = \"https:\u002F\u002Fapi.example.com\"\n\n\n@app.callback()\ndef main(ctx: typer.Context,\n         refresh: bool = typer.Option(False, \"--refresh\", help=\"Revalidate cached data.\"),\n         no_cache: bool = typer.Option(False, \"--no-cache\", help=\"Bypass the cache.\")) -> None:\n    \"\"\"Ticket tool.\"\"\"\n    ctx.obj = {\"refresh\": refresh, \"use_cache\": not no_cache,\n               \"cache\": HttpCache(user_cache_path(\"tickets\") \u002F \"http.db\"),\n               \"client\": httpx.Client(base_url=API, timeout=10)}\n\n\n@app.command()\ndef show(ctx: typer.Context, ticket: int) -> None:\n    \"\"\"Show one ticket.\"\"\"\n    o = ctx.obj\n    r = cached_get(o[\"client\"], o[\"cache\"], f\"\u002Ftickets\u002F{ticket}\", ttl=120,\n                   refresh=o[\"refresh\"], use_cache=o[\"use_cache\"])\n    if r.stale:\n        typer.echo(f\"warning: offline, showing data from {int(r.age \u002F\u002F 60)} minutes ago\",\n                   err=True)\n    typer.echo(r.json()[\"title\"])\n\n\ncache_app = typer.Typer(help=\"Manage the local HTTP cache.\")\napp.add_typer(cache_app, name=\"cache\")\n\n\n@cache_app.command(\"clear\")\ndef clear(ctx: typer.Context) -> None:\n    typer.echo(f\"removed {ctx.obj['cache'].clear()} cached responses\")\n",[14,1689,1690,1695,1701,1708,1720,1724,1736,1740,1750,1760,1764,1768,1776,1786,1819,1853,1858,1886,1908,1934,1938,1942,1949,1967,1972,1982,2034,2060,2067,2099,2110,2120,2124,2128,2147,2161,2165,2169,2182,2195],{"__ignoreMap":137},[141,1691,1692],{"class":143,"line":144},[141,1693,1694],{"class":147},"# src\u002Ftickets\u002Fcli.py\n",[141,1696,1697,1699],{"class":143,"line":151},[141,1698,179],{"class":154},[141,1700,237],{"class":165},[141,1702,1703,1705],{"class":143,"line":169},[141,1704,179],{"class":154},[141,1706,1707],{"class":165}," typer\n",[141,1709,1710,1712,1715,1717],{"class":143,"line":176},[141,1711,155],{"class":154},[141,1713,1714],{"class":165}," platformdirs ",[141,1716,179],{"class":154},[141,1718,1719],{"class":165}," user_cache_path\n",[141,1721,1722],{"class":143,"line":185},[141,1723,173],{"emptyLinePlaceholder":172},[141,1725,1726,1728,1731,1733],{"class":143,"line":193},[141,1727,155],{"class":154},[141,1729,1730],{"class":165}," tickets.httpcache ",[141,1732,179],{"class":154},[141,1734,1735],{"class":165}," HttpCache, cached_get\n",[141,1737,1738],{"class":143,"line":201},[141,1739,173],{"emptyLinePlaceholder":172},[141,1741,1742,1745,1747],{"class":143,"line":214},[141,1743,1744],{"class":165},"app ",[141,1746,493],{"class":154},[141,1748,1749],{"class":165}," typer.Typer()\n",[141,1751,1752,1755,1757],{"class":143,"line":227},[141,1753,1754],{"class":158},"API",[141,1756,251],{"class":154},[141,1758,1759],{"class":254}," \"https:\u002F\u002Fapi.example.com\"\n",[141,1761,1762],{"class":143,"line":232},[141,1763,173],{"emptyLinePlaceholder":172},[141,1765,1766],{"class":143,"line":240},[141,1767,173],{"emptyLinePlaceholder":172},[141,1769,1770,1773],{"class":143,"line":245},[141,1771,1772],{"class":325},"@app.callback",[141,1774,1775],{"class":165},"()\n",[141,1777,1778,1780,1783],{"class":143,"line":258},[141,1779,1248],{"class":154},[141,1781,1782],{"class":325}," main",[141,1784,1785],{"class":165},"(ctx: typer.Context,\n",[141,1787,1788,1791,1793,1795,1798,1801,1803,1806,1808,1811,1813,1816],{"class":143,"line":264},[141,1789,1790],{"class":165},"         refresh: ",[141,1792,390],{"class":158},[141,1794,251],{"class":154},[141,1796,1797],{"class":165}," typer.Option(",[141,1799,1800],{"class":158},"False",[141,1802,47],{"class":165},[141,1804,1805],{"class":254},"\"--refresh\"",[141,1807,47],{"class":165},[141,1809,1810],{"class":489},"help",[141,1812,493],{"class":154},[141,1814,1815],{"class":254},"\"Revalidate cached data.\"",[141,1817,1818],{"class":165},"),\n",[141,1820,1821,1824,1826,1828,1830,1832,1834,1837,1839,1841,1843,1846,1849,1851],{"class":143,"line":270},[141,1822,1823],{"class":165},"         no_cache: ",[141,1825,390],{"class":158},[141,1827,251],{"class":154},[141,1829,1797],{"class":165},[141,1831,1800],{"class":158},[141,1833,47],{"class":165},[141,1835,1836],{"class":254},"\"--no-cache\"",[141,1838,47],{"class":165},[141,1840,1810],{"class":489},[141,1842,493],{"class":154},[141,1844,1845],{"class":254},"\"Bypass the cache.\"",[141,1847,1848],{"class":165},")) -> ",[141,1850,478],{"class":158},[141,1852,338],{"class":165},[141,1854,1855],{"class":143,"line":276},[141,1856,1857],{"class":254},"    \"\"\"Ticket tool.\"\"\"\n",[141,1859,1860,1863,1865,1868,1871,1874,1877,1880,1883],{"class":143,"line":282},[141,1861,1862],{"class":165},"    ctx.obj ",[141,1864,493],{"class":154},[141,1866,1867],{"class":165}," {",[141,1869,1870],{"class":254},"\"refresh\"",[141,1872,1873],{"class":165},": refresh, ",[141,1875,1876],{"class":254},"\"use_cache\"",[141,1878,1879],{"class":165},": ",[141,1881,1882],{"class":154},"not",[141,1884,1885],{"class":165}," no_cache,\n",[141,1887,1888,1891,1894,1897,1900,1903,1906],{"class":143,"line":288},[141,1889,1890],{"class":254},"               \"cache\"",[141,1892,1893],{"class":165},": HttpCache(user_cache_path(",[141,1895,1896],{"class":254},"\"tickets\"",[141,1898,1899],{"class":165},") ",[141,1901,1902],{"class":154},"\u002F",[141,1904,1905],{"class":254}," \"http.db\"",[141,1907,1818],{"class":165},[141,1909,1910,1913,1916,1919,1921,1923,1925,1927,1929,1932],{"class":143,"line":294},[141,1911,1912],{"class":254},"               \"client\"",[141,1914,1915],{"class":165},": httpx.Client(",[141,1917,1918],{"class":489},"base_url",[141,1920,493],{"class":154},[141,1922,1754],{"class":158},[141,1924,47],{"class":165},[141,1926,626],{"class":489},[141,1928,493],{"class":154},[141,1930,1931],{"class":158},"10",[141,1933,926],{"class":165},[141,1935,1936],{"class":143,"line":300},[141,1937,173],{"emptyLinePlaceholder":172},[141,1939,1940],{"class":143,"line":306},[141,1941,173],{"emptyLinePlaceholder":172},[141,1943,1944,1947],{"class":143,"line":312},[141,1945,1946],{"class":325},"@app.command",[141,1948,1775],{"class":165},[141,1950,1951,1953,1956,1959,1961,1963,1965],{"class":143,"line":317},[141,1952,1248],{"class":154},[141,1954,1955],{"class":325}," show",[141,1957,1958],{"class":165},"(ctx: typer.Context, ticket: ",[141,1960,467],{"class":158},[141,1962,475],{"class":165},[141,1964,478],{"class":158},[141,1966,338],{"class":165},[141,1968,1969],{"class":143,"line":322},[141,1970,1971],{"class":254},"    \"\"\"Show one ticket.\"\"\"\n",[141,1973,1974,1977,1979],{"class":143,"line":329},[141,1975,1976],{"class":165},"    o ",[141,1978,493],{"class":154},[141,1980,1981],{"class":165}," ctx.obj\n",[141,1983,1984,1987,1989,1992,1995,1998,2001,2004,2007,2010,2013,2016,2019,2022,2024,2027,2029,2032],{"class":143,"line":341},[141,1985,1986],{"class":165},"    r ",[141,1988,493],{"class":154},[141,1990,1991],{"class":165}," cached_get(o[",[141,1993,1994],{"class":254},"\"client\"",[141,1996,1997],{"class":165},"], o[",[141,1999,2000],{"class":254},"\"cache\"",[141,2002,2003],{"class":165},"], ",[141,2005,2006],{"class":154},"f",[141,2008,2009],{"class":254},"\"\u002Ftickets\u002F",[141,2011,2012],{"class":158},"{",[141,2014,2015],{"class":165},"ticket",[141,2017,2018],{"class":158},"}",[141,2020,2021],{"class":254},"\"",[141,2023,47],{"class":165},[141,2025,2026],{"class":489},"ttl",[141,2028,493],{"class":154},[141,2030,2031],{"class":158},"120",[141,2033,953],{"class":165},[141,2035,2036,2039,2041,2044,2046,2048,2051,2053,2055,2057],{"class":143,"line":350},[141,2037,2038],{"class":489},"                   refresh",[141,2040,493],{"class":154},[141,2042,2043],{"class":165},"o[",[141,2045,1870],{"class":254},[141,2047,2003],{"class":165},[141,2049,2050],{"class":489},"use_cache",[141,2052,493],{"class":154},[141,2054,2043],{"class":165},[141,2056,1876],{"class":254},[141,2058,2059],{"class":165},"])\n",[141,2061,2062,2064],{"class":143,"line":366},[141,2063,1328],{"class":154},[141,2065,2066],{"class":165}," r.stale:\n",[141,2068,2069,2072,2074,2077,2080,2083,2086,2089,2092,2094,2097],{"class":143,"line":375},[141,2070,2071],{"class":165},"        typer.echo(",[141,2073,2006],{"class":154},[141,2075,2076],{"class":254},"\"warning: offline, showing data from ",[141,2078,2079],{"class":158},"{int",[141,2081,2082],{"class":165},"(r.age ",[141,2084,2085],{"class":154},"\u002F\u002F",[141,2087,2088],{"class":158}," 60",[141,2090,2091],{"class":165},")",[141,2093,2018],{"class":158},[141,2095,2096],{"class":254}," minutes ago\"",[141,2098,953],{"class":165},[141,2100,2101,2104,2106,2108],{"class":143,"line":384},[141,2102,2103],{"class":489},"                   err",[141,2105,493],{"class":154},[141,2107,496],{"class":158},[141,2109,508],{"class":165},[141,2111,2112,2115,2118],{"class":143,"line":398},[141,2113,2114],{"class":165},"    typer.echo(r.json()[",[141,2116,2117],{"class":254},"\"title\"",[141,2119,2059],{"class":165},[141,2121,2122],{"class":143,"line":403},[141,2123,173],{"emptyLinePlaceholder":172},[141,2125,2126],{"class":143,"line":415},[141,2127,173],{"emptyLinePlaceholder":172},[141,2129,2130,2133,2135,2138,2140,2142,2145],{"class":143,"line":430},[141,2131,2132],{"class":165},"cache_app ",[141,2134,493],{"class":154},[141,2136,2137],{"class":165}," typer.Typer(",[141,2139,1810],{"class":489},[141,2141,493],{"class":154},[141,2143,2144],{"class":254},"\"Manage the local HTTP cache.\"",[141,2146,508],{"class":165},[141,2148,2149,2152,2155,2157,2159],{"class":143,"line":435},[141,2150,2151],{"class":165},"app.add_typer(cache_app, ",[141,2153,2154],{"class":489},"name",[141,2156,493],{"class":154},[141,2158,2000],{"class":254},[141,2160,508],{"class":165},[141,2162,2163],{"class":143,"line":440},[141,2164,173],{"emptyLinePlaceholder":172},[141,2166,2167],{"class":143,"line":450},[141,2168,173],{"emptyLinePlaceholder":172},[141,2170,2171,2174,2177,2180],{"class":143,"line":483},[141,2172,2173],{"class":325},"@cache_app.command",[141,2175,2176],{"class":165},"(",[141,2178,2179],{"class":254},"\"clear\"",[141,2181,508],{"class":165},[141,2183,2184,2186,2188,2191,2193],{"class":143,"line":511},[141,2185,1248],{"class":154},[141,2187,1202],{"class":325},[141,2189,2190],{"class":165},"(ctx: typer.Context) -> ",[141,2192,478],{"class":158},[141,2194,338],{"class":165},[141,2196,2197,2200,2202,2205,2207,2210,2213,2216,2218,2221],{"class":143,"line":519},[141,2198,2199],{"class":165},"    typer.echo(",[141,2201,2006],{"class":154},[141,2203,2204],{"class":254},"\"removed ",[141,2206,2012],{"class":158},[141,2208,2209],{"class":165},"ctx.obj[",[141,2211,2212],{"class":254},"'cache'",[141,2214,2215],{"class":165},"].clear()",[141,2217,2018],{"class":158},[141,2219,2220],{"class":254}," cached responses\"",[141,2222,508],{"class":165},[33,2224,2226],{"id":2225},"ux-considerations","UX considerations",[38,2228,2229,2235,2249,2255,2267,2277],{},[41,2230,2231,2234],{},[94,2232,2233],{},"Choose TTLs per endpoint."," A list of projects can be cached for an hour; a build status for ten seconds; anything the user just changed should not be cached at all. A single global TTL is always wrong for some endpoint.",[41,2236,2237,2240,2241,2244,2245,2248],{},[94,2238,2239],{},"Invalidate after writes."," After ",[14,2242,2243],{},"mytool close 42",", delete the cached entry for ticket 42, or the next ",[14,2246,2247],{},"show"," will contradict the action the user just performed.",[41,2250,2251,2254],{},[94,2252,2253],{},"Say when data is stale."," The offline fallback must announce itself on stderr. Silent stale data is worse than an error.",[41,2256,2257,2266],{},[94,2258,2259,2260,55,2263,31],{},"Offer ",[14,2261,2262],{},"--refresh",[14,2264,2265],{},"--no-cache"," Refresh revalidates (cheap with ETags); no-cache bypasses the store entirely, which is what users reach for when debugging.",[41,2268,2269,2272,2273,2276],{},[94,2270,2271],{},"Put it in the cache directory."," The file may be deleted by the user or a cleaner at any time — that is the definition of a cache. Show its location and size in a ",[14,2274,2275],{},"cache info"," command.",[41,2278,2279,2282,2283,31],{},[94,2280,2281],{},"Cache completion lookups aggressively."," Shell completion runs on every Tab and must answer in tens of milliseconds; a long TTL for completion data is fine, as discussed in ",[27,2284,2286],{"href":2285},"\u002Fadvanced-input-parsing-user-experience\u002Fshell-completion-for-python-clis\u002Fdynamic-completion-values-from-apis-and-files\u002F","dynamic completion values from APIs and files",[85,2288],{"name":2289},"sql-cache-ttl-bars",[33,2291,2293],{"id":2292},"testing-the-behaviour","Testing the behaviour",[10,2295,2296,2298,2299,2302],{},[14,2297,54],{}," counts calls, which makes \"did this hit the network?\" a direct assertion. Patch ",[14,2300,2301],{},"time.time"," to age entries instead of sleeping:",[132,2304,2306],{"className":134,"code":2305,"language":136,"meta":137,"style":137},"# tests\u002Ftest_httpcache.py\nimport httpx\nimport pytest\nimport respx\n\nfrom tickets import httpcache\nfrom tickets.httpcache import HttpCache, cached_get\n\nURL = \"https:\u002F\u002Fapi.example.com\u002Ftickets\u002F42\"\n\n\n@pytest.fixture\ndef setup(tmp_path):\n    client = httpx.Client(base_url=\"https:\u002F\u002Fapi.example.com\")\n    return client, HttpCache(tmp_path \u002F \"http.db\", max_bytes=1000)\n\n\n@respx.mock\ndef test_fresh_hit_skips_network(setup):\n    client, cache = setup\n    route = respx.get(URL).respond(json={\"title\": \"Fix login\"})\n    cached_get(client, cache, \"\u002Ftickets\u002F42\")\n    assert cached_get(client, cache, \"\u002Ftickets\u002F42\").json()[\"title\"] == \"Fix login\"\n    assert route.call_count == 1\n\n\n@respx.mock\ndef test_stale_entry_revalidates_with_etag(setup, monkeypatch):\n    client, cache = setup\n    route = respx.get(URL).mock(side_effect=[\n        httpx.Response(200, json={\"title\": \"A\"}, headers={\"ETag\": '\"v1\"'}),\n        httpx.Response(304),\n    ])\n    cached_get(client, cache, \"\u002Ftickets\u002F42\", ttl=60)\n    real = httpcache.time.time\n    monkeypatch.setattr(httpcache.time, \"time\", lambda: real() + 3600)\n    r = cached_get(client, cache, \"\u002Ftickets\u002F42\", ttl=60)\n    assert r.json()[\"title\"] == \"A\"\n    assert route.calls[1].request.headers[\"If-None-Match\"] == '\"v1\"'\n\n\n@respx.mock\ndef test_offline_falls_back_to_stale(setup):\n    client, cache = setup\n    respx.get(URL).mock(side_effect=[httpx.Response(200, json={\"title\": \"A\"}),\n                                     httpx.ConnectError(\"offline\")])\n    cached_get(client, cache, \"\u002Ftickets\u002F42\")\n    r = cached_get(client, cache, \"\u002Ftickets\u002F42\", refresh=True)\n    assert r.stale and r.json()[\"title\"] == \"A\"\n\n\n@respx.mock\ndef test_errors_are_not_cached(setup):\n    client, cache = setup\n    respx.get(URL).respond(500)\n    with pytest.raises(httpx.HTTPStatusError):\n        cached_get(client, cache, \"\u002Ftickets\u002F42\")\n    assert cache.get(URL) is None\n\n\n@respx.mock\ndef test_size_limit_evicts_oldest(setup):\n    client, cache = setup\n    for n in range(5):\n        respx.get(f\"https:\u002F\u002Fapi.example.com\u002Ft\u002F{n}\").respond(content=b\"x\" * 300)\n        cached_get(client, cache, f\"\u002Ft\u002F{n}\")\n    assert cache.get(\"https:\u002F\u002Fapi.example.com\u002Ft\u002F0\") is None\n    assert cache.get(\"https:\u002F\u002Fapi.example.com\u002Ft\u002F4\") is not None\n\n\ndef test_corrupt_file_is_replaced(tmp_path):\n    path = tmp_path \u002F \"http.db\"\n    path.write_bytes(b\"this is not sqlite\")\n    assert HttpCache(path).get(\"anything\") is None\n",[14,2307,2308,2313,2319,2326,2333,2337,2349,2359,2363,2373,2377,2381,2386,2396,2415,2438,2442,2446,2451,2461,2471,2503,2513,2535,2547,2551,2555,2559,2569,2577,2598,2641,2650,2655,2672,2682,2706,2726,2742,2764,2768,2772,2776,2785,2793,2827,2838,2846,2867,2886,2890,2894,2898,2907,2915,2927,2935,2944,2959,2963,2967,2971,2980,2988,3008,3047,3066,3081,3098,3102,3106,3115,3130,3142],{"__ignoreMap":137},[141,2309,2310],{"class":143,"line":144},[141,2311,2312],{"class":147},"# tests\u002Ftest_httpcache.py\n",[141,2314,2315,2317],{"class":143,"line":151},[141,2316,179],{"class":154},[141,2318,237],{"class":165},[141,2320,2321,2323],{"class":143,"line":169},[141,2322,179],{"class":154},[141,2324,2325],{"class":165}," pytest\n",[141,2327,2328,2330],{"class":143,"line":176},[141,2329,179],{"class":154},[141,2331,2332],{"class":165}," respx\n",[141,2334,2335],{"class":143,"line":185},[141,2336,173],{"emptyLinePlaceholder":172},[141,2338,2339,2341,2344,2346],{"class":143,"line":193},[141,2340,155],{"class":154},[141,2342,2343],{"class":165}," tickets ",[141,2345,179],{"class":154},[141,2347,2348],{"class":165}," httpcache\n",[141,2350,2351,2353,2355,2357],{"class":143,"line":201},[141,2352,155],{"class":154},[141,2354,1730],{"class":165},[141,2356,179],{"class":154},[141,2358,1735],{"class":165},[141,2360,2361],{"class":143,"line":214},[141,2362,173],{"emptyLinePlaceholder":172},[141,2364,2365,2368,2370],{"class":143,"line":227},[141,2366,2367],{"class":158},"URL",[141,2369,251],{"class":154},[141,2371,2372],{"class":254}," \"https:\u002F\u002Fapi.example.com\u002Ftickets\u002F42\"\n",[141,2374,2375],{"class":143,"line":232},[141,2376,173],{"emptyLinePlaceholder":172},[141,2378,2379],{"class":143,"line":240},[141,2380,173],{"emptyLinePlaceholder":172},[141,2382,2383],{"class":143,"line":245},[141,2384,2385],{"class":325},"@pytest.fixture\n",[141,2387,2388,2390,2393],{"class":143,"line":258},[141,2389,1248],{"class":154},[141,2391,2392],{"class":325}," setup",[141,2394,2395],{"class":165},"(tmp_path):\n",[141,2397,2398,2401,2403,2406,2408,2410,2413],{"class":143,"line":264},[141,2399,2400],{"class":165},"    client ",[141,2402,493],{"class":154},[141,2404,2405],{"class":165}," httpx.Client(",[141,2407,1918],{"class":489},[141,2409,493],{"class":154},[141,2411,2412],{"class":254},"\"https:\u002F\u002Fapi.example.com\"",[141,2414,508],{"class":165},[141,2416,2417,2419,2422,2424,2426,2428,2431,2433,2436],{"class":143,"line":270},[141,2418,1628],{"class":154},[141,2420,2421],{"class":165}," client, HttpCache(tmp_path ",[141,2423,1902],{"class":154},[141,2425,1905],{"class":254},[141,2427,47],{"class":165},[141,2429,2430],{"class":489},"max_bytes",[141,2432,493],{"class":154},[141,2434,2435],{"class":158},"1000",[141,2437,508],{"class":165},[141,2439,2440],{"class":143,"line":276},[141,2441,173],{"emptyLinePlaceholder":172},[141,2443,2444],{"class":143,"line":282},[141,2445,173],{"emptyLinePlaceholder":172},[141,2447,2448],{"class":143,"line":288},[141,2449,2450],{"class":325},"@respx.mock\n",[141,2452,2453,2455,2458],{"class":143,"line":294},[141,2454,1248],{"class":154},[141,2456,2457],{"class":325}," test_fresh_hit_skips_network",[141,2459,2460],{"class":165},"(setup):\n",[141,2462,2463,2466,2468],{"class":143,"line":300},[141,2464,2465],{"class":165},"    client, cache ",[141,2467,493],{"class":154},[141,2469,2470],{"class":165}," setup\n",[141,2472,2473,2476,2478,2481,2483,2486,2489,2491,2493,2495,2497,2500],{"class":143,"line":306},[141,2474,2475],{"class":165},"    route ",[141,2477,493],{"class":154},[141,2479,2480],{"class":165}," respx.get(",[141,2482,2367],{"class":158},[141,2484,2485],{"class":165},").respond(",[141,2487,2488],{"class":489},"json",[141,2490,493],{"class":154},[141,2492,2012],{"class":165},[141,2494,2117],{"class":254},[141,2496,1879],{"class":165},[141,2498,2499],{"class":254},"\"Fix login\"",[141,2501,2502],{"class":165},"})\n",[141,2504,2505,2508,2511],{"class":143,"line":312},[141,2506,2507],{"class":165},"    cached_get(client, cache, ",[141,2509,2510],{"class":254},"\"\u002Ftickets\u002F42\"",[141,2512,508],{"class":165},[141,2514,2515,2518,2521,2523,2526,2528,2530,2532],{"class":143,"line":317},[141,2516,2517],{"class":154},"    assert",[141,2519,2520],{"class":165}," cached_get(client, cache, ",[141,2522,2510],{"class":254},[141,2524,2525],{"class":165},").json()[",[141,2527,2117],{"class":254},[141,2529,828],{"class":165},[141,2531,1548],{"class":154},[141,2533,2534],{"class":254}," \"Fix login\"\n",[141,2536,2537,2539,2542,2544],{"class":143,"line":322},[141,2538,2517],{"class":154},[141,2540,2541],{"class":165}," route.call_count ",[141,2543,1548],{"class":154},[141,2545,2546],{"class":158}," 1\n",[141,2548,2549],{"class":143,"line":329},[141,2550,173],{"emptyLinePlaceholder":172},[141,2552,2553],{"class":143,"line":341},[141,2554,173],{"emptyLinePlaceholder":172},[141,2556,2557],{"class":143,"line":350},[141,2558,2450],{"class":325},[141,2560,2561,2563,2566],{"class":143,"line":366},[141,2562,1248],{"class":154},[141,2564,2565],{"class":325}," test_stale_entry_revalidates_with_etag",[141,2567,2568],{"class":165},"(setup, monkeypatch):\n",[141,2570,2571,2573,2575],{"class":143,"line":375},[141,2572,2465],{"class":165},[141,2574,493],{"class":154},[141,2576,2470],{"class":165},[141,2578,2579,2581,2583,2585,2587,2590,2593,2595],{"class":143,"line":384},[141,2580,2475],{"class":165},[141,2582,493],{"class":154},[141,2584,2480],{"class":165},[141,2586,2367],{"class":158},[141,2588,2589],{"class":165},").mock(",[141,2591,2592],{"class":489},"side_effect",[141,2594,493],{"class":154},[141,2596,2597],{"class":165},"[\n",[141,2599,2600,2603,2606,2608,2610,2612,2614,2616,2618,2621,2624,2626,2628,2630,2633,2635,2638],{"class":143,"line":398},[141,2601,2602],{"class":165},"        httpx.Response(",[141,2604,2605],{"class":158},"200",[141,2607,47],{"class":165},[141,2609,2488],{"class":489},[141,2611,493],{"class":154},[141,2613,2012],{"class":165},[141,2615,2117],{"class":254},[141,2617,1879],{"class":165},[141,2619,2620],{"class":254},"\"A\"",[141,2622,2623],{"class":165},"}, ",[141,2625,1488],{"class":489},[141,2627,493],{"class":154},[141,2629,2012],{"class":165},[141,2631,2632],{"class":254},"\"ETag\"",[141,2634,1879],{"class":165},[141,2636,2637],{"class":254},"'\"v1\"'",[141,2639,2640],{"class":165},"}),\n",[141,2642,2643,2645,2648],{"class":143,"line":403},[141,2644,2602],{"class":165},[141,2646,2647],{"class":158},"304",[141,2649,1818],{"class":165},[141,2651,2652],{"class":143,"line":415},[141,2653,2654],{"class":165},"    ])\n",[141,2656,2657,2659,2661,2663,2665,2667,2670],{"class":143,"line":430},[141,2658,2507],{"class":165},[141,2660,2510],{"class":254},[141,2662,47],{"class":165},[141,2664,2026],{"class":489},[141,2666,493],{"class":154},[141,2668,2669],{"class":158},"60",[141,2671,508],{"class":165},[141,2673,2674,2677,2679],{"class":143,"line":435},[141,2675,2676],{"class":165},"    real ",[141,2678,493],{"class":154},[141,2680,2681],{"class":165}," httpcache.time.time\n",[141,2683,2684,2687,2690,2692,2695,2698,2701,2704],{"class":143,"line":440},[141,2685,2686],{"class":165},"    monkeypatch.setattr(httpcache.time, ",[141,2688,2689],{"class":254},"\"time\"",[141,2691,47],{"class":165},[141,2693,2694],{"class":154},"lambda",[141,2696,2697],{"class":165},": real() ",[141,2699,2700],{"class":154},"+",[141,2702,2703],{"class":158}," 3600",[141,2705,508],{"class":165},[141,2707,2708,2710,2712,2714,2716,2718,2720,2722,2724],{"class":143,"line":450},[141,2709,1986],{"class":165},[141,2711,493],{"class":154},[141,2713,2520],{"class":165},[141,2715,2510],{"class":254},[141,2717,47],{"class":165},[141,2719,2026],{"class":489},[141,2721,493],{"class":154},[141,2723,2669],{"class":158},[141,2725,508],{"class":165},[141,2727,2728,2730,2733,2735,2737,2739],{"class":143,"line":483},[141,2729,2517],{"class":154},[141,2731,2732],{"class":165}," r.json()[",[141,2734,2117],{"class":254},[141,2736,828],{"class":165},[141,2738,1548],{"class":154},[141,2740,2741],{"class":254}," \"A\"\n",[141,2743,2744,2746,2749,2752,2755,2757,2759,2761],{"class":143,"line":511},[141,2745,2517],{"class":154},[141,2747,2748],{"class":165}," route.calls[",[141,2750,2751],{"class":158},"1",[141,2753,2754],{"class":165},"].request.headers[",[141,2756,1457],{"class":254},[141,2758,828],{"class":165},[141,2760,1548],{"class":154},[141,2762,2763],{"class":254}," '\"v1\"'\n",[141,2765,2766],{"class":143,"line":519},[141,2767,173],{"emptyLinePlaceholder":172},[141,2769,2770],{"class":143,"line":536},[141,2771,173],{"emptyLinePlaceholder":172},[141,2773,2774],{"class":143,"line":548},[141,2775,2450],{"class":325},[141,2777,2778,2780,2783],{"class":143,"line":563},[141,2779,1248],{"class":154},[141,2781,2782],{"class":325}," test_offline_falls_back_to_stale",[141,2784,2460],{"class":165},[141,2786,2787,2789,2791],{"class":143,"line":576},[141,2788,2465],{"class":165},[141,2790,493],{"class":154},[141,2792,2470],{"class":165},[141,2794,2795,2798,2800,2802,2804,2806,2809,2811,2813,2815,2817,2819,2821,2823,2825],{"class":143,"line":590},[141,2796,2797],{"class":165},"    respx.get(",[141,2799,2367],{"class":158},[141,2801,2589],{"class":165},[141,2803,2592],{"class":489},[141,2805,493],{"class":154},[141,2807,2808],{"class":165},"[httpx.Response(",[141,2810,2605],{"class":158},[141,2812,47],{"class":165},[141,2814,2488],{"class":489},[141,2816,493],{"class":154},[141,2818,2012],{"class":165},[141,2820,2117],{"class":254},[141,2822,1879],{"class":165},[141,2824,2620],{"class":254},[141,2826,2640],{"class":165},[141,2828,2829,2832,2835],{"class":143,"line":595},[141,2830,2831],{"class":165},"                                     httpx.ConnectError(",[141,2833,2834],{"class":254},"\"offline\"",[141,2836,2837],{"class":165},")])\n",[141,2839,2840,2842,2844],{"class":143,"line":604},[141,2841,2507],{"class":165},[141,2843,2510],{"class":254},[141,2845,508],{"class":165},[141,2847,2848,2850,2852,2854,2856,2858,2861,2863,2865],{"class":143,"line":615},[141,2849,1986],{"class":165},[141,2851,493],{"class":154},[141,2853,2520],{"class":165},[141,2855,2510],{"class":254},[141,2857,47],{"class":165},[141,2859,2860],{"class":489},"refresh",[141,2862,493],{"class":154},[141,2864,496],{"class":158},[141,2866,508],{"class":165},[141,2868,2869,2871,2874,2876,2878,2880,2882,2884],{"class":143,"line":636},[141,2870,2517],{"class":154},[141,2872,2873],{"class":165}," r.stale ",[141,2875,1392],{"class":154},[141,2877,2732],{"class":165},[141,2879,2117],{"class":254},[141,2881,828],{"class":165},[141,2883,1548],{"class":154},[141,2885,2741],{"class":254},[141,2887,2888],{"class":143,"line":647},[141,2889,173],{"emptyLinePlaceholder":172},[141,2891,2892],{"class":143,"line":656},[141,2893,173],{"emptyLinePlaceholder":172},[141,2895,2896],{"class":143,"line":664},[141,2897,2450],{"class":325},[141,2899,2900,2902,2905],{"class":143,"line":669},[141,2901,1248],{"class":154},[141,2903,2904],{"class":325}," test_errors_are_not_cached",[141,2906,2460],{"class":165},[141,2908,2909,2911,2913],{"class":143,"line":693},[141,2910,2465],{"class":165},[141,2912,493],{"class":154},[141,2914,2470],{"class":165},[141,2916,2917,2919,2921,2923,2925],{"class":143,"line":706},[141,2918,2797],{"class":165},[141,2920,2367],{"class":158},[141,2922,2485],{"class":165},[141,2924,1655],{"class":158},[141,2926,508],{"class":165},[141,2928,2929,2932],{"class":143,"line":715},[141,2930,2931],{"class":154},"    with",[141,2933,2934],{"class":165}," pytest.raises(httpx.HTTPStatusError):\n",[141,2936,2937,2940,2942],{"class":143,"line":721},[141,2938,2939],{"class":165},"        cached_get(client, cache, ",[141,2941,2510],{"class":254},[141,2943,508],{"class":165},[141,2945,2946,2948,2951,2953,2955,2957],{"class":143,"line":737},[141,2947,2517],{"class":154},[141,2949,2950],{"class":165}," cache.get(",[141,2952,2367],{"class":158},[141,2954,1899],{"class":165},[141,2956,730],{"class":154},[141,2958,743],{"class":158},[141,2960,2961],{"class":143,"line":746},[141,2962,173],{"emptyLinePlaceholder":172},[141,2964,2965],{"class":143,"line":757},[141,2966,173],{"emptyLinePlaceholder":172},[141,2968,2969],{"class":143,"line":771},[141,2970,2450],{"class":325},[141,2972,2973,2975,2978],{"class":143,"line":776},[141,2974,1248],{"class":154},[141,2976,2977],{"class":325}," test_size_limit_evicts_oldest",[141,2979,2460],{"class":165},[141,2981,2982,2984,2986],{"class":143,"line":799},[141,2983,2465],{"class":165},[141,2985,493],{"class":154},[141,2987,2470],{"class":165},[141,2989,2990,2993,2996,2998,3001,3003,3006],{"class":143,"line":817},[141,2991,2992],{"class":154},"    for",[141,2994,2995],{"class":165}," n ",[141,2997,893],{"class":154},[141,2999,3000],{"class":158}," range",[141,3002,2176],{"class":165},[141,3004,3005],{"class":158},"5",[141,3007,1613],{"class":165},[141,3009,3010,3013,3015,3018,3020,3023,3025,3027,3029,3032,3034,3037,3040,3043,3045],{"class":143,"line":841},[141,3011,3012],{"class":165},"        respx.get(",[141,3014,2006],{"class":154},[141,3016,3017],{"class":254},"\"https:\u002F\u002Fapi.example.com\u002Ft\u002F",[141,3019,2012],{"class":158},[141,3021,3022],{"class":165},"n",[141,3024,2018],{"class":158},[141,3026,2021],{"class":254},[141,3028,2485],{"class":165},[141,3030,3031],{"class":489},"content",[141,3033,493],{"class":154},[141,3035,3036],{"class":154},"b",[141,3038,3039],{"class":254},"\"x\"",[141,3041,3042],{"class":154}," *",[141,3044,1271],{"class":158},[141,3046,508],{"class":165},[141,3048,3049,3051,3053,3056,3058,3060,3062,3064],{"class":143,"line":846},[141,3050,2939],{"class":165},[141,3052,2006],{"class":154},[141,3054,3055],{"class":254},"\"\u002Ft\u002F",[141,3057,2012],{"class":158},[141,3059,3022],{"class":165},[141,3061,2018],{"class":158},[141,3063,2021],{"class":254},[141,3065,508],{"class":165},[141,3067,3068,3070,3072,3075,3077,3079],{"class":143,"line":865},[141,3069,2517],{"class":154},[141,3071,2950],{"class":165},[141,3073,3074],{"class":254},"\"https:\u002F\u002Fapi.example.com\u002Ft\u002F0\"",[141,3076,1899],{"class":165},[141,3078,730],{"class":154},[141,3080,743],{"class":158},[141,3082,3083,3085,3087,3090,3092,3094,3096],{"class":143,"line":876},[141,3084,2517],{"class":154},[141,3086,2950],{"class":165},[141,3088,3089],{"class":254},"\"https:\u002F\u002Fapi.example.com\u002Ft\u002F4\"",[141,3091,1899],{"class":165},[141,3093,730],{"class":154},[141,3095,1331],{"class":154},[141,3097,743],{"class":158},[141,3099,3100],{"class":143,"line":907},[141,3101,173],{"emptyLinePlaceholder":172},[141,3103,3104],{"class":143,"line":929},[141,3105,173],{"emptyLinePlaceholder":172},[141,3107,3108,3110,3113],{"class":143,"line":940},[141,3109,1248],{"class":154},[141,3111,3112],{"class":325}," test_corrupt_file_is_replaced",[141,3114,2395],{"class":165},[141,3116,3117,3120,3122,3125,3127],{"class":143,"line":947},[141,3118,3119],{"class":165},"    path ",[141,3121,493],{"class":154},[141,3123,3124],{"class":165}," tmp_path ",[141,3126,1902],{"class":154},[141,3128,3129],{"class":254}," \"http.db\"\n",[141,3131,3132,3135,3137,3140],{"class":143,"line":956},[141,3133,3134],{"class":165},"    path.write_bytes(",[141,3136,3036],{"class":154},[141,3138,3139],{"class":254},"\"this is not sqlite\"",[141,3141,508],{"class":165},[141,3143,3144,3146,3149,3152,3154,3156],{"class":143,"line":962},[141,3145,2517],{"class":154},[141,3147,3148],{"class":165}," HttpCache(path).get(",[141,3150,3151],{"class":254},"\"anything\"",[141,3153,1899],{"class":165},[141,3155,730],{"class":154},[141,3157,743],{"class":158},[10,3159,3160,3161,31],{},"Each test pins one row of the decision diagram, so a refactor that breaks revalidation or starts caching errors fails loudly. The general respx techniques are covered in ",[27,3162,3164],{"href":3163},"\u002Fcli-runtime-systems-integration\u002Fcalling-http-apis-from-python-clis\u002Fmocking-http-in-cli-tests-with-respx\u002F","mocking HTTP in CLI tests with respx",[33,3166,3168],{"id":3167},"conclusion","Conclusion",[10,3170,3171,3172,3174,3175,3177,3178,47,3180,55,3182,3185],{},"An HTTP cache makes a CLI faster, kinder to rate limits and usable offline — provided it is honest about freshness. Store successful ",[14,3173,72],{}," responses in SQLite keyed by URL (and profile), serve them within a per-endpoint TTL, revalidate with ",[14,3176,24],{},", fall back to clearly labelled stale data when the network is gone, cap the size, and give users ",[14,3179,2262],{},[14,3181,2265],{},[14,3183,3184],{},"cache clear",". Test each path with respx call counts rather than timing.",[33,3187,3189],{"id":3188},"frequently-asked-questions","Frequently asked questions",[1665,3191,3193],{"id":3192},"should-i-use-hishel-or-requests-cache-instead","Should I use hishel or requests-cache instead?",[10,3195,3196],{},"Both are solid: hishel adds RFC 9111 caching to httpx, requests-cache does the same for requests, and both can store in SQLite. Use one if you want standards-complete HTTP caching semantics. The hand-written version here is about 100 lines, has no extra dependency, and makes the CLI-specific policies — per-endpoint TTLs, stale fallback, profile-aware keys — explicit.",[1665,3198,3200],{"id":3199},"is-it-safe-to-cache-responses-that-contain-personal-data","Is it safe to cache responses that contain personal data?",[10,3202,3203,3204,3206,3207,3209],{},"Only with care. The cache file sits unencrypted in the user's cache directory, readable by the user's account. Respect ",[14,3205,1659],{},", keep TTLs short for sensitive endpoints, create the file with owner-only permissions, and offer ",[14,3208,3184],{},". Never cache responses from authentication endpoints.",[1665,3211,3213],{"id":3212},"how-do-i-cache-post-requests-that-are-really-queries","How do I cache POST requests that are really queries?",[10,3215,3216],{},"Some APIs (search, GraphQL) use POST for reads. Cache them only if you are certain they have no side effects, and include a hash of the request body in the key. Make it opt-in per call rather than automatic.",[1665,3218,3220],{"id":3219},"why-not-let-the-servers-cache-control-headers-set-the-ttl","Why not let the server's Cache-Control headers set the TTL?",[10,3222,3223,3224,3227],{},"You can: parse ",[14,3225,3226],{},"max-age"," and use it when present, falling back to your per-endpoint default. Many internal APIs send no caching headers at all, which is why the explicit TTL is the primary control here.",[33,3229,3231],{"id":3230},"related","Related",[38,3233,3234,3240,3246,3252,3258],{},[41,3235,3236,3237],{},"Up: ",[27,3238,3239],{"href":29},"Local state and SQLite in Python CLIs",[41,3241,3242],{},[27,3243,3245],{"href":3244},"\u002Fcli-runtime-systems-integration\u002Flocal-state-and-sqlite-in-python-clis\u002Fstoring-cli-state-in-sqlite\u002F","Storing CLI state in SQLite",[41,3247,3248],{},[27,3249,3251],{"href":3250},"\u002Fcli-runtime-systems-integration\u002Fcalling-http-apis-from-python-clis\u002Fretries-and-backoff-for-cli-http-calls\u002F","Retries and backoff for CLI HTTP calls",[41,3253,3254],{},[27,3255,3257],{"href":3256},"\u002Fcli-runtime-systems-integration\u002Fconcurrency-and-async-in-python-clis\u002Frate-limiting-concurrent-requests-in-clis\u002F","Rate limiting concurrent requests in CLIs",[41,3259,3260],{},[27,3261,3263],{"href":3262},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcli-startup-performance-and-lazy-loading\u002Fcaching-expensive-work-between-cli-runs\u002F","Caching expensive work between CLI runs",[3265,3266,3267],"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 pre.shiki code .s4XuR, html code.shiki .s4XuR{--shiki-default:#E36209;--shiki-dark:#FFAB70}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);}",{"title":137,"searchDepth":151,"depth":151,"links":3269},[3270,3271,3272,3276,3277,3278,3279,3285],{"id":35,"depth":151,"text":36},{"id":76,"depth":151,"text":77},{"id":129,"depth":151,"text":130,"children":3273},[3274,3275],{"id":1667,"depth":169,"text":1668},{"id":1683,"depth":169,"text":1684},{"id":2225,"depth":151,"text":2226},{"id":2292,"depth":151,"text":2293},{"id":3167,"depth":151,"text":3168},{"id":3188,"depth":151,"text":3189,"children":3280},[3281,3282,3283,3284],{"id":3192,"depth":169,"text":3193},{"id":3199,"depth":169,"text":3200},{"id":3212,"depth":169,"text":3213},{"id":3219,"depth":169,"text":3220},{"id":3230,"depth":151,"text":3231},"2026-10-02","Cache API responses in SQLite from a Python CLI: TTLs, ETag revalidation, stale fallback when offline, size limits, refresh and no-cache flags, and tests.","intermediate",false,"md",{},"\u002Fcli-runtime-systems-integration\u002Flocal-state-and-sqlite-in-python-clis\u002Fcaching-http-responses-on-disk-in-a-cli",{"title":5,"description":3287},"cli-runtime-systems-integration\u002Flocal-state-and-sqlite-in-python-clis\u002Fcaching-http-responses-on-disk-in-a-cli\u002Findex",[3296,3297,3298,46,3299],"caching","http","sqlite","offline","-Y_VtZa8w8luYup-TfGo4HQSlALW86lYoT8Z1RmzcdU",[3302,3305,3308,3311,3314,3317,3320,3323,3326,3329,3332,3335,3338,3341,3344,3347,3350,3353,3356,3359,3362,3365,3368,3371,3374,3377,3380,3383,3386,3389,3392,3395,3398,3401,3404,3407,3410,3413,3416,3419,3422,3425,3428,3431,3434,3437,3440,3443,3446,3449,3452,3455,3458,3461,3464,3467,3470,3473,3476,3479,3482,3485,3488,3491,3494,3497,3500,3503,3506,3509,3512,3515,3518,3521,3524,3527,3530,3533,3536,3539,3542,3545,3548,3551,3554,3557,3560,3563,3566,3569,3572,3575,3578,3581,3584,3587,3590,3593,3596,3599,3602,3605,3608,3611,3614,3617,3620,3621,3624,3627,3630,3633,3636,3639,3642,3645,3648,3651,3654,3657,3660,3663,3666,3669,3672,3675,3678,3681,3684,3687,3690,3693,3696,3699,3702,3705,3708,3711,3714,3717,3719,3722,3725,3728,3731,3734,3737,3740,3743,3746,3749,3752,3755,3758,3761,3764,3767,3770,3773,3776,3779,3782,3785,3788,3791,3794,3797,3800,3803,3806,3809,3812,3815,3818,3821,3824,3827,3830,3833,3836,3839,3842,3845,3848,3851,3854,3857,3860,3863,3866,3869,3872,3875,3878,3881,3884,3887,3890,3893,3896,3899,3902,3905,3908,3911,3914,3917,3920,3923,3926,3929,3932,3935,3938,3941,3944,3947,3950,3953,3956,3959,3962,3965,3968,3971,3974,3977,3980,3983,3986,3989,3992,3995,3998,4001,4004,4007,4010,4013,4016,4019,4022,4025,4028,4031,4034,4037,4040,4043,4046,4049,4052,4055,4058,4061,4064,4067,4070,4073,4076,4079,4082,4085,4088,4091,4094,4097,4100,4103,4106,4109,4112,4115,4118,4121,4124,4127,4130,4133,4136,4139,4142],{"path":3303,"title":3304},"\u002Fabout","About Python CLI Toolcraft",{"path":3306,"title":3307},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies","Advanced Argument Validation Strategies",{"path":3309,"title":3310},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies\u002Fparsing-nested-json-arguments-in-python-clis","Parsing Nested JSON Args in Python CLIs",{"path":3312,"title":3313},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies\u002Fvalidating-dates-and-durations-in-cli-arguments","Validating Dates and Durations in Python CLI Arguments",{"path":3315,"title":3316},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies\u002Fvalidating-dependent-and-conflicting-options","Validating Dependent and Conflicting CLI Options",{"path":3318,"title":3319},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies\u002Fvalidating-file-and-directory-paths-in-clis","Validating File and Directory Paths in CLIs",{"path":3321,"title":3322},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies\u002Fvalidating-urls-hosts-and-ports","Validating URLs, Hosts and Ports in Python CLI Arguments",{"path":3324,"title":3325},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies\u002Fwriting-custom-click-parameter-types","Writing Custom Click Parameter Types",{"path":3327,"title":3328},"\u002Fadvanced-input-parsing-user-experience\u002Fbuilding-terminal-uis-with-textual\u002Fbrowsing-records-with-a-textual-datatable","Browsing Records with a Textual DataTable Picker",{"path":3330,"title":3331},"\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":3333,"title":3334},"\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":3336,"title":3337},"\u002Fadvanced-input-parsing-user-experience\u002Fbuilding-terminal-uis-with-textual","Building Terminal UIs with Textual for Python CLIs",{"path":3339,"title":3340},"\u002Fadvanced-input-parsing-user-experience\u002Fbuilding-terminal-uis-with-textual\u002Frunning-background-work-in-textual-with-workers","Running Background Work in Textual with Workers",{"path":3342,"title":3343},"\u002Fadvanced-input-parsing-user-experience\u002Fbuilding-terminal-uis-with-textual\u002Fstyling-textual-apps-with-tcss","Styling Textual Apps with TCSS",{"path":3345,"title":3346},"\u002Fadvanced-input-parsing-user-experience\u002Fbuilding-terminal-uis-with-textual\u002Ftesting-textual-apps-with-pilot","Testing Textual Apps with Pilot",{"path":3348,"title":3349},"\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":3351,"title":3352},"\u002Fadvanced-input-parsing-user-experience\u002Fcli-help-output-and-documentation\u002Fdocumenting-environment-variables-in-help","Documenting Environment Variables in CLI Help",{"path":3354,"title":3355},"\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":3357,"title":3358},"\u002Fadvanced-input-parsing-user-experience\u002Fcli-help-output-and-documentation","CLI Help Output and Documentation",{"path":3360,"title":3361},"\u002Fadvanced-input-parsing-user-experience\u002Fcli-help-output-and-documentation\u002Frich-formatted-help-with-rich-click","Rich-Formatted Help for Click CLIs with rich-click",{"path":3363,"title":3364},"\u002Fadvanced-input-parsing-user-experience\u002Fcli-help-output-and-documentation\u002Fversioning-and-deprecating-cli-flags","Versioning and Deprecating CLI Flags",{"path":3366,"title":3367},"\u002Fadvanced-input-parsing-user-experience\u002Fcli-help-output-and-documentation\u002Fwriting-help-text-users-actually-read","Writing Help Text Users Actually Read",{"path":3369,"title":3370},"\u002Fadvanced-input-parsing-user-experience\u002Fcross-platform-terminal-compatibility\u002Fadapting-output-to-terminal-width","Adapting Python CLI Output to Terminal Width",{"path":3372,"title":3373},"\u002Fadvanced-input-parsing-user-experience\u002Fcross-platform-terminal-compatibility\u002Fdetecting-ci-environments-and-non-interactive-shells","Detecting CI Environments and Non-Interactive Shells",{"path":3375,"title":3376},"\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":3378,"title":3379},"\u002Fadvanced-input-parsing-user-experience\u002Fcross-platform-terminal-compatibility\u002Fhandling-ansi-escape-codes-on-windows-consoles","Handling ANSI Escape Codes on Windows Consoles",{"path":3381,"title":3382},"\u002Fadvanced-input-parsing-user-experience\u002Fcross-platform-terminal-compatibility","Cross-Platform Terminal Compatibility for Python CLIs",{"path":3384,"title":3385},"\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":3387,"title":3388},"\u002Fadvanced-input-parsing-user-experience\u002Fcross-platform-terminal-compatibility\u002Fsupporting-dumb-terminals-and-screen-readers","Supporting Dumb Terminals and Screen Readers in a Python CLI",{"path":3390,"title":3391},"\u002Fadvanced-input-parsing-user-experience\u002Ferror-handling-and-exit-codes\u002Fchoosing-exit-codes-for-cli-tools","Choosing Exit Codes for CLI Tools",{"path":3393,"title":3394},"\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":3396,"title":3397},"\u002Fadvanced-input-parsing-user-experience\u002Ferror-handling-and-exit-codes\u002Fdid-you-mean-suggestions-for-mistyped-input","Did You Mean…? Suggestions for Mistyped CLI Input",{"path":3399,"title":3400},"\u002Fadvanced-input-parsing-user-experience\u002Ferror-handling-and-exit-codes\u002Ffriendly-error-messages-and-tracebacks","Friendly Error Messages and Tracebacks",{"path":3402,"title":3403},"\u002Fadvanced-input-parsing-user-experience\u002Ferror-handling-and-exit-codes\u002Fhandling-keyboard-interrupt-cleanly","Handling Keyboard Interrupt Cleanly",{"path":3405,"title":3406},"\u002Fadvanced-input-parsing-user-experience\u002Ferror-handling-and-exit-codes","Error Handling and Exit Codes for CLIs",{"path":3408,"title":3409},"\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":3411,"title":3412},"\u002Fadvanced-input-parsing-user-experience\u002Ferror-handling-and-exit-codes\u002Fwriting-crash-reports-users-can-send","Writing Crash Reports Users Can Send",{"path":3414,"title":3415},"\u002Fadvanced-input-parsing-user-experience\u002Fhandling-configuration-files-env-vars\u002Fconfig-precedence-flags-env-files-defaults","Config Precedence: Flags, Env, Files, Defaults",{"path":3417,"title":3418},"\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":3420,"title":3421},"\u002Fadvanced-input-parsing-user-experience\u002Fhandling-configuration-files-env-vars","Handling Config Files and Env Vars in CLIs",{"path":3423,"title":3424},"\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":3426,"title":3427},"\u002Fadvanced-input-parsing-user-experience\u002Fhandling-configuration-files-env-vars\u002Freading-toml-config-with-tomllib","Reading TOML Config with tomllib in Python CLIs",{"path":3429,"title":3430},"\u002Fadvanced-input-parsing-user-experience\u002Fhandling-configuration-files-env-vars\u002Ftyped-settings-with-pydantic-settings","Typed Settings with pydantic-settings in Python CLIs",{"path":3432,"title":3433},"\u002Fadvanced-input-parsing-user-experience\u002Fhandling-configuration-files-env-vars\u002Fvalidating-config-files-with-json-schema","Validating Config Files with JSON Schema in a Python CLI",{"path":3435,"title":3436},"\u002Fadvanced-input-parsing-user-experience\u002Fhandling-configuration-files-env-vars\u002Fwriting-a-config-init-and-edit-command","Writing a Config Init and Edit Command for a Python CLI",{"path":3438,"title":3439},"\u002Fadvanced-input-parsing-user-experience","Advanced Input Parsing for Python CLIs",{"path":3441,"title":3442},"\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":3444,"title":3445},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich\u002Fbuilding-interactive-prompts-and-menus","Building Interactive Prompts and Menus in Python CLIs",{"path":3447,"title":3448},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich\u002Fbuilding-tree-views-with-rich","Building Tree Views with Rich in a Python CLI",{"path":3450,"title":3451},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich","Interactive Terminal UI with Rich",{"path":3453,"title":3454},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich\u002Flive-dashboards-with-rich-live","Live Dashboards with Rich Live in Python CLIs",{"path":3456,"title":3457},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich\u002Frendering-markdown-and-syntax-highlighting-with-rich","Rendering Markdown and Syntax Highlighting with Rich",{"path":3459,"title":3460},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich\u002Frendering-tables-and-json-with-rich","Rendering Tables and JSON with Rich",{"path":3462,"title":3463},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich\u002Ftheming-rich-output-consistently","Theming Rich Output Consistently in Python CLIs",{"path":3465,"title":3466},"\u002Fadvanced-input-parsing-user-experience\u002Foutput-formats-for-data-clis\u002Fadding-a-format-flag-for-table-json-and-csv","Adding a Format Flag for Table, JSON and CSV Output",{"path":3468,"title":3469},"\u002Fadvanced-input-parsing-user-experience\u002Foutput-formats-for-data-clis\u002Fcustom-output-templates-with-a-format-string","Custom Output Templates with a Format String in Python CLIs",{"path":3471,"title":3472},"\u002Fadvanced-input-parsing-user-experience\u002Foutput-formats-for-data-clis\u002Fexporting-cli-results-to-files","Exporting CLI Results to Files from a Python CLI",{"path":3474,"title":3475},"\u002Fadvanced-input-parsing-user-experience\u002Foutput-formats-for-data-clis","Output Formats for Data-Heavy Python CLIs",{"path":3477,"title":3478},"\u002Fadvanced-input-parsing-user-experience\u002Foutput-formats-for-data-clis\u002Fselecting-fields-and-columns-from-cli-output","Selecting Fields and Columns from Python CLI Output",{"path":3480,"title":3481},"\u002Fadvanced-input-parsing-user-experience\u002Foutput-formats-for-data-clis\u002Fwriting-csv-and-tsv-output-correctly","Writing CSV and TSV Output Correctly from a Python CLI",{"path":3483,"title":3484},"\u002Fadvanced-input-parsing-user-experience\u002Fshell-completion-for-python-clis\u002Fargcomplete-for-argparse-clis","Tab Completion for argparse CLIs with argcomplete",{"path":3486,"title":3487},"\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":3489,"title":3490},"\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":3492,"title":3493},"\u002Fadvanced-input-parsing-user-experience\u002Fshell-completion-for-python-clis","Shell Completion for Python CLIs",{"path":3495,"title":3496},"\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":3498,"title":3499},"\u002Fadvanced-input-parsing-user-experience\u002Fshell-completion-for-python-clis\u002Fshipping-completion-scripts-with-packages","Shipping Shell Completion Scripts with a Python CLI",{"path":3501,"title":3502},"\u002Fadvanced-input-parsing-user-experience\u002Fshell-completion-for-python-clis\u002Ftesting-shell-completion-in-python-clis","Testing Shell Completion in Python CLIs",{"path":3504,"title":3505},"\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":3507,"title":3508},"\u002Fadvanced-input-parsing-user-experience\u002Fstructured-logging-for-cli-apps\u002Fadding-verbose-and-quiet-logging-flags","Adding Verbose and Quiet Logging Flags",{"path":3510,"title":3511},"\u002Fadvanced-input-parsing-user-experience\u002Fstructured-logging-for-cli-apps","Structured Logging for CLI Apps",{"path":3513,"title":3514},"\u002Fadvanced-input-parsing-user-experience\u002Fstructured-logging-for-cli-apps\u002Flogging-with-structlog-in-a-cli","Logging with structlog in a Python CLI",{"path":3516,"title":3517},"\u002Fadvanced-input-parsing-user-experience\u002Fstructured-logging-for-cli-apps\u002Fseparating-logs-from-program-output","Separating Logs from Program Output in a Python CLI",{"path":3519,"title":3520},"\u002Fadvanced-input-parsing-user-experience\u002Fstructured-logging-for-cli-apps\u002Fstructured-json-logging-in-python-clis","Structured JSON Logging in Python CLIs",{"path":3522,"title":3523},"\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":3525,"title":3526},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes\u002Fdetecting-tty-and-adapting-output","Detecting a TTY and Adapting Output",{"path":3528,"title":3529},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes\u002Femitting-json-output-for-scripting","Emitting JSON Output for Scripting",{"path":3531,"title":3532},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes\u002Fhandling-broken-pipe-and-sigpipe","Handling Broken Pipe and SIGPIPE",{"path":3534,"title":3535},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes","Working with stdin, stdout and Pipes",{"path":3537,"title":3538},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes\u002Fnull-delimited-input-and-xargs-compatibility","Null-Delimited Input and xargs Compatibility in Python CLIs",{"path":3540,"title":3541},"\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":3543,"title":3544},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes\u002Freading-piped-input-in-python-clis","Reading Piped Input in Python CLIs",{"path":3546,"title":3547},"\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":3549,"title":3550},"\u002Fcli-runtime-systems-integration\u002Fcalling-http-apis-from-python-clis\u002Fdownloading-files-with-progress-in-python","Downloading Files with Progress in Python CLIs",{"path":3552,"title":3553},"\u002Fcli-runtime-systems-integration\u002Fcalling-http-apis-from-python-clis","Calling HTTP APIs from Python CLIs",{"path":3555,"title":3556},"\u002Fcli-runtime-systems-integration\u002Fcalling-http-apis-from-python-clis\u002Fmocking-http-in-cli-tests-with-respx","Mocking HTTP in Python CLI Tests with respx",{"path":3558,"title":3559},"\u002Fcli-runtime-systems-integration\u002Fcalling-http-apis-from-python-clis\u002Foauth-device-flow-login-for-clis","OAuth Device Flow Login for Python CLIs",{"path":3561,"title":3562},"\u002Fcli-runtime-systems-integration\u002Fcalling-http-apis-from-python-clis\u002Fpaginating-api-results-in-a-cli","Paginating API Results in a Python CLI",{"path":3564,"title":3565},"\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":3567,"title":3568},"\u002Fcli-runtime-systems-integration\u002Fcalling-http-apis-from-python-clis\u002Fuploading-files-with-multipart-and-progress","Uploading Files with Multipart and Progress in a Python CLI",{"path":3570,"title":3571},"\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":3573,"title":3574},"\u002Fcli-runtime-systems-integration\u002Fconcurrency-and-async-in-python-clis","Concurrency and Async in Python CLIs",{"path":3576,"title":3577},"\u002Fcli-runtime-systems-integration\u002Fconcurrency-and-async-in-python-clis\u002Fmultiprocessing-for-cpu-bound-cli-tasks","Multiprocessing for CPU-Bound CLI Tasks",{"path":3579,"title":3580},"\u002Fcli-runtime-systems-integration\u002Fconcurrency-and-async-in-python-clis\u002Fparallelising-cli-work-with-thread-pools","Parallelising CLI Work with Thread Pools",{"path":3582,"title":3583},"\u002Fcli-runtime-systems-integration\u002Fconcurrency-and-async-in-python-clis\u002Frate-limiting-concurrent-requests-in-clis","Rate-Limiting Concurrent Requests in Python CLIs",{"path":3585,"title":3586},"\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":3588,"title":3589},"\u002Fcli-runtime-systems-integration\u002Fconcurrency-and-async-in-python-clis\u002Fshowing-progress-for-concurrent-tasks","Showing Progress for Concurrent Tasks in a Python CLI",{"path":3591,"title":3592},"\u002Fcli-runtime-systems-integration\u002Fconcurrency-and-async-in-python-clis\u002Fstructured-concurrency-with-taskgroups-in-clis","Structured Concurrency with TaskGroups in Python CLIs",{"path":3594,"title":3595},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes\u002Fcross-platform-paths-with-pathlib","Cross-Platform Paths with pathlib in CLIs",{"path":3597,"title":3598},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes\u002Ffile-locking-for-concurrent-cli-runs","File Locking for Concurrent CLI Runs in Python",{"path":3600,"title":3601},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes\u002Fhandling-file-permissions-and-umask-in-clis","Handling File Permissions and umask in Python CLIs",{"path":3603,"title":3604},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes","Filesystem Paths and Atomic Writes for CLIs",{"path":3606,"title":3607},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes\u002Fsafe-temporary-files-and-directories","Safe Temporary Files and Directories in CLIs",{"path":3609,"title":3610},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes\u002Fstoring-app-data-with-platformdirs","Storing CLI App Data with platformdirs",{"path":3612,"title":3613},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes\u002Fwalking-directory-trees-with-ignore-rules","Walking Directory Trees with Ignore Rules in a Python CLI",{"path":3615,"title":3616},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes\u002Fwriting-files-atomically-in-python-clis","Writing Files Atomically in Python CLIs",{"path":3618,"title":3619},"\u002Fcli-runtime-systems-integration","CLI Runtime & Systems Integration for Python",{"path":3292,"title":5},{"path":3622,"title":3623},"\u002Fcli-runtime-systems-integration\u002Flocal-state-and-sqlite-in-python-clis","Local State and SQLite in Python CLIs",{"path":3625,"title":3626},"\u002Fcli-runtime-systems-integration\u002Flocal-state-and-sqlite-in-python-clis\u002Fmigrating-a-cli-sqlite-schema","Migrating a CLI’s SQLite Schema Between Releases",{"path":3628,"title":3629},"\u002Fcli-runtime-systems-integration\u002Flocal-state-and-sqlite-in-python-clis\u002Frecording-and-querying-cli-run-history","Recording and Querying CLI Run History in SQLite",{"path":3631,"title":3632},"\u002Fcli-runtime-systems-integration\u002Flocal-state-and-sqlite-in-python-clis\u002Fstoring-cli-state-in-sqlite","Storing CLI State in SQLite with a Small Repository Class",{"path":3634,"title":3635},"\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":3637,"title":3638},"\u002Fcli-runtime-systems-integration\u002Flong-running-and-watch-mode-clis\u002Fhandling-sigterm-and-graceful-shutdown","Handling SIGTERM and Graceful Shutdown in CLIs",{"path":3640,"title":3641},"\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":3643,"title":3644},"\u002Fcli-runtime-systems-integration\u002Flong-running-and-watch-mode-clis","Long-Running and Watch-Mode Python CLIs",{"path":3646,"title":3647},"\u002Fcli-runtime-systems-integration\u002Flong-running-and-watch-mode-clis\u002Freloading-config-on-sighup","Reloading Configuration on SIGHUP in a Python CLI",{"path":3649,"title":3650},"\u002Fcli-runtime-systems-integration\u002Flong-running-and-watch-mode-clis\u002Frunning-a-cli-as-a-systemd-service","Running a Python CLI as a systemd Service",{"path":3652,"title":3653},"\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":3655,"title":3656},"\u002Fcli-runtime-systems-integration\u002Flong-running-and-watch-mode-clis\u002Fsending-cli-logs-to-journald-and-syslog","Sending Python CLI Logs to journald and syslog",{"path":3658,"title":3659},"\u002Fcli-runtime-systems-integration\u002Frunning-subprocesses-from-python-clis\u002Favoiding-shell-injection-in-python-clis","Avoiding Shell Injection in Python CLIs",{"path":3661,"title":3662},"\u002Fcli-runtime-systems-integration\u002Frunning-subprocesses-from-python-clis\u002Fcalling-external-commands-safely-with-subprocess","Calling External Commands Safely with subprocess",{"path":3664,"title":3665},"\u002Fcli-runtime-systems-integration\u002Frunning-subprocesses-from-python-clis\u002Fhandling-subprocess-timeouts-and-exit-codes","Handling Subprocess Timeouts and Exit Codes",{"path":3667,"title":3668},"\u002Fcli-runtime-systems-integration\u002Frunning-subprocesses-from-python-clis","Running Subprocesses from Python CLIs",{"path":3670,"title":3671},"\u002Fcli-runtime-systems-integration\u002Frunning-subprocesses-from-python-clis\u002Flaunching-the-users-editor-from-a-cli","Launching the User’s Editor from a Python CLI",{"path":3673,"title":3674},"\u002Fcli-runtime-systems-integration\u002Frunning-subprocesses-from-python-clis\u002Fpiping-between-subprocesses-in-python","Piping Between Subprocesses in Python Without a Shell",{"path":3676,"title":3677},"\u002Fcli-runtime-systems-integration\u002Frunning-subprocesses-from-python-clis\u002Fstreaming-subprocess-output-in-real-time","Streaming Subprocess Output in Real Time",{"path":3679,"title":3680},"\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":3682,"title":3683},"\u002Fcli-runtime-systems-integration\u002Fsecrets-and-credentials-in-python-clis","Secrets and Credentials in Python CLIs",{"path":3685,"title":3686},"\u002Fcli-runtime-systems-integration\u002Fsecrets-and-credentials-in-python-clis\u002Fprompting-for-passwords-securely","Prompting for Passwords Securely in Python CLIs",{"path":3688,"title":3689},"\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":3691,"title":3692},"\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":3694,"title":3695},"\u002Fcli-runtime-systems-integration\u002Fsecrets-and-credentials-in-python-clis\u002Frefreshing-expired-tokens-automatically","Refreshing Expired Tokens Automatically in a Python CLI",{"path":3697,"title":3698},"\u002Fcli-runtime-systems-integration\u002Fsecrets-and-credentials-in-python-clis\u002Fstoring-tokens-with-keyring","Storing CLI Tokens Securely with keyring",{"path":3700,"title":3701},"\u002Fcli-runtime-systems-integration\u002Fsecrets-and-credentials-in-python-clis\u002Fsupporting-multiple-profiles-and-accounts","Supporting Multiple Profiles and Accounts in CLIs",{"path":3703,"title":3704},"\u002Fcli-runtime-systems-integration\u002Fupdate-checks-and-self-updating-clis\u002Fchecking-pypi-for-a-newer-version","Checking PyPI for a Newer Version of Your Python CLI",{"path":3706,"title":3707},"\u002Fcli-runtime-systems-integration\u002Fupdate-checks-and-self-updating-clis","Update Checks, Upgrade Commands and Telemetry for Python CLIs",{"path":3709,"title":3710},"\u002Fcli-runtime-systems-integration\u002Fupdate-checks-and-self-updating-clis\u002Fopt-in-usage-telemetry-for-python-clis","Opt-In Usage Telemetry for Python CLIs Done Responsibly",{"path":3712,"title":3713},"\u002Fcli-runtime-systems-integration\u002Fupdate-checks-and-self-updating-clis\u002Fself-upgrading-a-cli-installed-with-pipx-or-uv","Self-Upgrading a Python CLI Installed with pipx or uv",{"path":3715,"title":3716},"\u002Fcli-runtime-systems-integration\u002Fupdate-checks-and-self-updating-clis\u002Fshowing-non-blocking-update-notices","Showing Non-Blocking Update Notices in a Python CLI",{"path":1902,"title":3718},"Python CLI Toolcraft",{"path":3720,"title":3721},"\u002Fmodern-python-cli-frameworks-architecture\u002Falternative-python-cli-frameworks\u002Fbuilding-a-cli-with-cleo","Building a Python CLI with Cleo Command Classes",{"path":3723,"title":3724},"\u002Fmodern-python-cli-frameworks-architecture\u002Falternative-python-cli-frameworks\u002Fbuilding-a-cli-with-cyclopts","Building a Type-Hinted Python CLI with Cyclopts",{"path":3726,"title":3727},"\u002Fmodern-python-cli-frameworks-architecture\u002Falternative-python-cli-frameworks","Beyond Click and Typer: Alternative Python CLI Frameworks",{"path":3729,"title":3730},"\u002Fmodern-python-cli-frameworks-architecture\u002Falternative-python-cli-frameworks\u002Fquick-clis-from-functions-with-python-fire","Quick CLIs from Functions with Python Fire",{"path":3732,"title":3733},"\u002Fmodern-python-cli-frameworks-architecture\u002Falternative-python-cli-frameworks\u002Fusage-string-driven-clis-with-docopt-ng","Usage-String Driven Python CLIs with docopt-ng",{"path":3735,"title":3736},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcli-startup-performance-and-lazy-loading\u002Favoiding-import-time-side-effects","Avoiding Import-Time Side Effects in a Python CLI",{"path":3738,"title":3739},"\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":3741,"title":3742},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcli-startup-performance-and-lazy-loading\u002Fguarding-startup-with-import-tests","Guarding CLI Startup with Import Tests",{"path":3744,"title":3745},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcli-startup-performance-and-lazy-loading","CLI Startup Performance and Lazy Loading",{"path":3747,"title":3748},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcli-startup-performance-and-lazy-loading\u002Flazy-loading-subcommands-for-faster-startup","Lazy Loading Subcommands for Faster Startup",{"path":3750,"title":3751},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcli-startup-performance-and-lazy-loading\u002Fprofiling-python-cli-startup-time","Profiling Python CLI Startup Time",{"path":3753,"title":3754},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcli-startup-performance-and-lazy-loading\u002Freducing-cli-dependency-weight","Reducing CLI Dependency Weight",{"path":3756,"title":3757},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse\u002Fargparse-subparsers-for-subcommands","argparse Subparsers for Subcommands",{"path":3759,"title":3760},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse\u002Fargparse-vs-click-vs-typer-comparison","argparse vs Click vs Typer Compared",{"path":3762,"title":3763},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse\u002Fargument-groups-and-help-formatting-in-argparse","Argument Groups and Help Formatting in argparse",{"path":3765,"title":3766},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse","Command-Line Parsing with argparse",{"path":3768,"title":3769},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse\u002Fmigrating-from-argparse-to-typer","Migrating from argparse to Typer",{"path":3771,"title":3772},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse\u002Fmutually-exclusive-options-in-argparse","Mutually Exclusive Options in argparse",{"path":3774,"title":3775},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse\u002Freading-arguments-from-files-with-fromfile-prefix-chars","Reading Arguments from Files with argparse’s fromfile_prefix_chars",{"path":3777,"title":3778},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse\u002Fwriting-custom-argparse-actions","Writing Custom argparse Actions in Python",{"path":3780,"title":3781},"\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":3783,"title":3784},"\u002Fmodern-python-cli-frameworks-architecture\u002Fdesigning-cli-interfaces-and-conventions\u002Fdesigning-idempotent-commands","Designing Idempotent Commands in a Python CLI",{"path":3786,"title":3787},"\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":3789,"title":3790},"\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":3792,"title":3793},"\u002Fmodern-python-cli-frameworks-architecture\u002Fdesigning-cli-interfaces-and-conventions","Designing CLI Interfaces and Conventions in Python",{"path":3795,"title":3796},"\u002Fmodern-python-cli-frameworks-architecture\u002Fdesigning-cli-interfaces-and-conventions\u002Fnaming-commands-and-flags-consistently","Naming Commands and Flags Consistently in Python CLIs",{"path":3798,"title":3799},"\u002Fmodern-python-cli-frameworks-architecture\u002Fdesigning-cli-interfaces-and-conventions\u002Fpositional-arguments-vs-options","Positional Arguments vs Options: Designing a CLI Signature",{"path":3801,"title":3802},"\u002Fmodern-python-cli-frameworks-architecture","Python CLI Frameworks and Architecture",{"path":3804,"title":3805},"\u002Fmodern-python-cli-frameworks-architecture\u002Fplugin-architectures-for-extensible-clis\u002Fdiscovering-plugins-with-entry-points","Discovering Plugins with Entry Points in Python CLIs",{"path":3807,"title":3808},"\u002Fmodern-python-cli-frameworks-architecture\u002Fplugin-architectures-for-extensible-clis\u002Fhook-based-plugins-with-pluggy","Hook-Based Plugins for Python CLIs with pluggy",{"path":3810,"title":3811},"\u002Fmodern-python-cli-frameworks-architecture\u002Fplugin-architectures-for-extensible-clis","Plugin Architectures for Extensible CLIs",{"path":3813,"title":3814},"\u002Fmodern-python-cli-frameworks-architecture\u002Fplugin-architectures-for-extensible-clis\u002Fisolating-plugin-failures","Isolating Plugin Failures in an Extensible Python CLI",{"path":3816,"title":3817},"\u002Fmodern-python-cli-frameworks-architecture\u002Fplugin-architectures-for-extensible-clis\u002Ftesting-plugins-against-the-host-cli","Testing Plugins Against the Host CLI",{"path":3819,"title":3820},"\u002Fmodern-python-cli-frameworks-architecture\u002Fplugin-architectures-for-extensible-clis\u002Fversioning-a-plugin-api","Versioning a Plugin API for a Python CLI",{"path":3822,"title":3823},"\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":3825,"title":3826},"\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":3828,"title":3829},"\u002Fmodern-python-cli-frameworks-architecture\u002Fstructuring-multi-command-python-clis\u002Fdependency-injection-patterns-for-cli-commands","Dependency Injection Patterns for CLI Commands",{"path":3831,"title":3832},"\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":3834,"title":3835},"\u002Fmodern-python-cli-frameworks-architecture\u002Fstructuring-multi-command-python-clis","Structuring Multi-Command Python CLIs",{"path":3837,"title":3838},"\u002Fmodern-python-cli-frameworks-architecture\u002Fstructuring-multi-command-python-clis\u002Foffering-a-python-api-alongside-your-cli","Offering a Python API Alongside Your CLI",{"path":3840,"title":3841},"\u002Fmodern-python-cli-frameworks-architecture\u002Fstructuring-multi-command-python-clis\u002Fregistering-commands-from-modules-automatically","Registering CLI Commands from Modules Automatically",{"path":3843,"title":3844},"\u002Fmodern-python-cli-frameworks-architecture\u002Fstructuring-multi-command-python-clis\u002Fsharing-common-options-across-commands","Sharing Common Options Across Python CLI Commands",{"path":3846,"title":3847},"\u002Fmodern-python-cli-frameworks-architecture\u002Fstructuring-multi-command-python-clis\u002Fsharing-state-with-click-context-objects","Sharing State with Click Context Objects",{"path":3849,"title":3850},"\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":3852,"title":3853},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications","Testing Python CLI Applications",{"path":3855,"title":3856},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Fmeasuring-cli-test-coverage","Measuring CLI Test Coverage",{"path":3858,"title":3859},"\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":3861,"title":3862},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Fproperty-based-testing-cli-arguments-with-hypothesis","Property-Based Testing CLI Arguments with Hypothesis",{"path":3864,"title":3865},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Fsnapshot-testing-cli-output","Snapshot Testing CLI Output",{"path":3867,"title":3868},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Ftesting-click-commands-with-clirunner","Testing Click Commands with CliRunner",{"path":3870,"title":3871},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Ftesting-commands-that-call-subprocesses","Testing Python CLI Commands That Call Subprocesses",{"path":3873,"title":3874},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Ftesting-interactive-prompts-and-stdin","Testing Interactive Prompts and stdin",{"path":3876,"title":3877},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Ftranscript-tests-for-cli-commands","Transcript Tests for Python CLI Commands",{"path":3879,"title":3880},"\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":3882,"title":3883},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftyper-vs-click-when-to-use-each\u002Fbuilding-dynamic-commands-in-click","Building Dynamic Commands in Click",{"path":3885,"title":3886},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftyper-vs-click-when-to-use-each\u002Fchoices-and-enums-in-typer-and-click","Choices and Enums in Typer and Click Options",{"path":3888,"title":3889},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftyper-vs-click-when-to-use-each\u002Fclick-option-callbacks-and-eager-options","Click Option Callbacks and Eager Options Explained",{"path":3891,"title":3892},"\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":3894,"title":3895},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftyper-vs-click-when-to-use-each","Typer vs Click: When to Use Each",{"path":3897,"title":3898},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftyper-vs-click-when-to-use-each\u002Frich-markup-and-help-panels-in-typer","Rich Markup and Help Panels in Typer",{"path":3900,"title":3901},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftyper-vs-click-when-to-use-each\u002Ftyper-callback-functions-explained","Typer callback functions explained",{"path":3903,"title":3904},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftyper-vs-click-when-to-use-each\u002Fusing-annotated-options-in-typer","Using Annotated Options in Typer",{"path":3906,"title":3907},"\u002Fproject-setup-dependency-management\u002Fci-cd-pipelines-for-python-clis\u002Fautomating-releases-from-git-tags","Automating Python CLI Releases from Git Tags",{"path":3909,"title":3910},"\u002Fproject-setup-dependency-management\u002Fci-cd-pipelines-for-python-clis\u002Fcaching-uv-dependencies-in-ci","Caching uv Dependencies in CI for Python CLIs",{"path":3912,"title":3913},"\u002Fproject-setup-dependency-management\u002Fci-cd-pipelines-for-python-clis","CI\u002FCD Pipelines for Python CLIs",{"path":3915,"title":3916},"\u002Fproject-setup-dependency-management\u002Fci-cd-pipelines-for-python-clis\u002Fpublishing-a-cli-docker-image-from-ci","Publishing a Python CLI as a Docker Image from CI",{"path":3918,"title":3919},"\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":3921,"title":3922},"\u002Fproject-setup-dependency-management\u002Fci-cd-pipelines-for-python-clis\u002Frunning-cli-tests-on-windows-and-macos-runners","Running Python CLI Tests on Windows and macOS Runners",{"path":3924,"title":3925},"\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":3927,"title":3928},"\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":3930,"title":3931},"\u002Fproject-setup-dependency-management\u002Fcli-project-scaffolding-with-cookiecutter\u002Fbuilding-a-cookiecutter-template-for-typer-clis","Building a Cookiecutter Template for Typer CLIs",{"path":3933,"title":3934},"\u002Fproject-setup-dependency-management\u002Fcli-project-scaffolding-with-cookiecutter\u002Fcopier-vs-cookiecutter-for-cli-templates","Copier vs Cookiecutter for CLI Templates",{"path":3936,"title":3937},"\u002Fproject-setup-dependency-management\u002Fcli-project-scaffolding-with-cookiecutter","CLI Project Scaffolding with Cookiecutter",{"path":3939,"title":3940},"\u002Fproject-setup-dependency-management\u002Fcli-project-scaffolding-with-cookiecutter\u002Fpost-generation-hooks-in-cli-templates","Post-Generation Hooks in Python CLI Templates",{"path":3942,"title":3943},"\u002Fproject-setup-dependency-management\u002Fcli-project-scaffolding-with-cookiecutter\u002Ftemplate-variables-and-conditional-files","Template Variables and Conditional Files in CLI Templates",{"path":3945,"title":3946},"\u002Fproject-setup-dependency-management\u002Fcli-project-scaffolding-with-cookiecutter\u002Ftesting-a-project-template-with-pytest","Testing a CLI Project Template with pytest",{"path":3948,"title":3949},"\u002Fproject-setup-dependency-management\u002Fcli-project-scaffolding-with-cookiecutter\u002Fupdating-generated-projects-with-copier-update","Updating Generated CLI Projects with copier update",{"path":3951,"title":3952},"\u002Fproject-setup-dependency-management\u002Fdistributing-clis-as-standalone-binaries\u002Fbuilding-cross-platform-release-binaries-in-ci","Building Cross-Platform Release Binaries in CI",{"path":3954,"title":3955},"\u002Fproject-setup-dependency-management\u002Fdistributing-clis-as-standalone-binaries\u002Fbundling-a-python-cli-with-pyinstaller","Bundling a Python CLI with PyInstaller",{"path":3957,"title":3958},"\u002Fproject-setup-dependency-management\u002Fdistributing-clis-as-standalone-binaries\u002Fcode-signing-and-notarizing-cli-binaries","Code Signing and Notarizing Python CLI Binaries",{"path":3960,"title":3961},"\u002Fproject-setup-dependency-management\u002Fdistributing-clis-as-standalone-binaries\u002Fhomebrew-and-scoop-packaging-for-python-clis","Homebrew and Scoop Packaging for Python CLIs",{"path":3963,"title":3964},"\u002Fproject-setup-dependency-management\u002Fdistributing-clis-as-standalone-binaries","Distributing CLIs as Standalone Binaries",{"path":3966,"title":3967},"\u002Fproject-setup-dependency-management\u002Fdistributing-clis-as-standalone-binaries\u002Fnuitka-vs-pyinstaller-for-python-clis","Nuitka vs PyInstaller for Python CLI Binaries",{"path":3969,"title":3970},"\u002Fproject-setup-dependency-management\u002Fdistributing-clis-as-standalone-binaries\u002Freducing-pyinstaller-binary-size","Reducing the Size of a PyInstaller CLI Binary",{"path":3972,"title":3973},"\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":3975,"title":3976},"\u002Fproject-setup-dependency-management","Project Setup & Dependency Management",{"path":3978,"title":3979},"\u002Fproject-setup-dependency-management\u002Flinting-and-type-checking-cli-code\u002Fconfiguring-ruff-for-a-cli-project","Configuring Ruff for a Python CLI Project",{"path":3981,"title":3982},"\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":3984,"title":3985},"\u002Fproject-setup-dependency-management\u002Flinting-and-type-checking-cli-code\u002Ffinding-unused-code-and-dependencies-with-vulture-and-deptry","Finding Unused Code and Dependencies with vulture and deptry",{"path":3987,"title":3988},"\u002Fproject-setup-dependency-management\u002Flinting-and-type-checking-cli-code","Linting and Type-Checking Python CLI Code",{"path":3990,"title":3991},"\u002Fproject-setup-dependency-management\u002Flinting-and-type-checking-cli-code\u002Frunning-pyright-in-strict-mode-on-a-cli","Running Pyright in Strict Mode on a Python CLI",{"path":3993,"title":3994},"\u002Fproject-setup-dependency-management\u002Flinting-and-type-checking-cli-code\u002Frunning-ruff-and-mypy-in-ci-with-annotations","Running Ruff and mypy in CI with Inline Annotations",{"path":3996,"title":3997},"\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":3999,"title":4000},"\u002Fproject-setup-dependency-management\u002Fmanaging-cli-versioning-changelogs\u002Fautomating-changelogs-with-conventional-commits","Automating Changelogs with Conventional Commits",{"path":4002,"title":4003},"\u002Fproject-setup-dependency-management\u002Fmanaging-cli-versioning-changelogs\u002Fbumping-versions-consistently-across-a-cli-project","Bumping Versions Consistently Across a Python CLI Project",{"path":4005,"title":4006},"\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":4008,"title":4009},"\u002Fproject-setup-dependency-management\u002Fmanaging-cli-versioning-changelogs\u002Fexposing-version-info-and-build-metadata","Exposing Version Info and Build Metadata",{"path":4011,"title":4012},"\u002Fproject-setup-dependency-management\u002Fmanaging-cli-versioning-changelogs","Managing CLI Versioning & Changelogs",{"path":4014,"title":4015},"\u002Fproject-setup-dependency-management\u002Fmanaging-cli-versioning-changelogs\u002Fsemantic-versioning-policy-for-cli-tools","A Semantic Versioning Policy for CLI Tools",{"path":4017,"title":4018},"\u002Fproject-setup-dependency-management\u002Fmanaging-cli-versioning-changelogs\u002Fshipping-pre-releases-and-release-candidates","Shipping Pre-Releases and Release Candidates of a Python CLI",{"path":4020,"title":4021},"\u002Fproject-setup-dependency-management\u002Fpackaging-python-clis-for-distribution\u002Fbuilding-wheels-and-sdists-for-python-clis","Building Wheels and sdists for Python CLIs",{"path":4023,"title":4024},"\u002Fproject-setup-dependency-management\u002Fpackaging-python-clis-for-distribution\u002Fbundling-data-files-with-importlib-resources","Bundling Data Files with importlib.resources in CLIs",{"path":4026,"title":4027},"\u002Fproject-setup-dependency-management\u002Fpackaging-python-clis-for-distribution\u002Fchoosing-a-build-backend-for-a-python-cli","Choosing a Build Backend for a Python CLI",{"path":4029,"title":4030},"\u002Fproject-setup-dependency-management\u002Fpackaging-python-clis-for-distribution","Packaging Python CLIs for Distribution",{"path":4032,"title":4033},"\u002Fproject-setup-dependency-management\u002Fpackaging-python-clis-for-distribution\u002Finstalling-and-distributing-clis-with-pipx","Installing and Distributing CLIs with pipx",{"path":4035,"title":4036},"\u002Fproject-setup-dependency-management\u002Fpackaging-python-clis-for-distribution\u002Foptional-dependencies-and-extras-for-clis","Optional Dependencies and Extras for Python CLIs",{"path":4038,"title":4039},"\u002Fproject-setup-dependency-management\u002Fpackaging-python-clis-for-distribution\u002Fpublishing-a-python-cli-to-pypi","Publishing a Python CLI to PyPI",{"path":4041,"title":4042},"\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":4044,"title":4045},"\u002Fproject-setup-dependency-management\u002Fpoetry-workflows-for-cli-development\u002Fdynamic-versioning-with-poetry-plugins","Dynamic Versioning for a Poetry CLI from Git Tags",{"path":4047,"title":4048},"\u002Fproject-setup-dependency-management\u002Fpoetry-workflows-for-cli-development","Poetry Workflows for CLI Development",{"path":4050,"title":4051},"\u002Fproject-setup-dependency-management\u002Fpoetry-workflows-for-cli-development\u002Fmanaging-poetry-lock-files-for-cli-tools","Managing Poetry Lock Files for CLI Tools",{"path":4053,"title":4054},"\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":4056,"title":4057},"\u002Fproject-setup-dependency-management\u002Fpoetry-workflows-for-cli-development\u002Fpoetry-dependency-groups-for-cli-tooling","Poetry Dependency Groups for CLI Tooling",{"path":4059,"title":4060},"\u002Fproject-setup-dependency-management\u002Fpoetry-workflows-for-cli-development\u002Fpoetry-entry-points-and-scripts-for-clis","Poetry Entry Points and Scripts for CLIs",{"path":4062,"title":4063},"\u002Fproject-setup-dependency-management\u002Fpoetry-workflows-for-cli-development\u002Fpublishing-a-cli-with-poetry","Building and Publishing a Python CLI with Poetry",{"path":4065,"title":4066},"\u002Fproject-setup-dependency-management\u002Fpre-commit-hooks-for-cli-projects","Pre-commit Hooks for CLI Projects",{"path":4068,"title":4069},"\u002Fproject-setup-dependency-management\u002Fpre-commit-hooks-for-cli-projects\u002Fkeeping-hook-versions-current-with-autoupdate","Keeping pre-commit Hook Versions Current with autoupdate",{"path":4071,"title":4072},"\u002Fproject-setup-dependency-management\u002Fpre-commit-hooks-for-cli-projects\u002Frunning-pre-commit-in-ci","Running pre-commit in CI for a Python CLI Repository",{"path":4074,"title":4075},"\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":4077,"title":4078},"\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":4080,"title":4081},"\u002Fproject-setup-dependency-management\u002Fpre-commit-hooks-for-cli-projects\u002Fspeeding-up-slow-pre-commit-hooks","Speeding Up Slow pre-commit Hooks in a CLI Repository",{"path":4083,"title":4084},"\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":4086,"title":4087},"\u002Fproject-setup-dependency-management\u002Fsecuring-a-python-cli-supply-chain\u002Fauditing-dependencies-with-pip-audit","Auditing a Python CLI’s Dependencies with pip-audit",{"path":4089,"title":4090},"\u002Fproject-setup-dependency-management\u002Fsecuring-a-python-cli-supply-chain\u002Fgenerating-an-sbom-for-a-python-cli","Generating an SBOM for a Python CLI Release",{"path":4092,"title":4093},"\u002Fproject-setup-dependency-management\u002Fsecuring-a-python-cli-supply-chain","Securing the Supply Chain of a Python CLI",{"path":4095,"title":4096},"\u002Fproject-setup-dependency-management\u002Fsecuring-a-python-cli-supply-chain\u002Fpinning-dependencies-with-hashes","Pinning a Python CLI’s Dependencies with Hashes",{"path":4098,"title":4099},"\u002Fproject-setup-dependency-management\u002Fsecuring-a-python-cli-supply-chain\u002Fpublishing-attestations-and-verifying-releases","Publishing Attestations and Verifying Python CLI Releases",{"path":4101,"title":4102},"\u002Fproject-setup-dependency-management\u002Fuv-for-python-cli-dependency-management\u002Fbuilding-and-publishing-a-cli-with-uv","Building and Publishing a Python CLI with uv",{"path":4104,"title":4105},"\u002Fproject-setup-dependency-management\u002Fuv-for-python-cli-dependency-management","uv for Python CLI Dependency Management",{"path":4107,"title":4108},"\u002Fproject-setup-dependency-management\u002Fuv-for-python-cli-dependency-management\u002Flocking-and-syncing-cli-dependencies-with-uv","Locking and Syncing a Python CLI’s Dependencies with uv",{"path":4110,"title":4111},"\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":4113,"title":4114},"\u002Fproject-setup-dependency-management\u002Fuv-for-python-cli-dependency-management\u002Fusing-private-package-indexes-with-uv","Using Private Package Indexes with uv for Internal CLIs",{"path":4116,"title":4117},"\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":4119,"title":4120},"\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":4122,"title":4123},"\u002Fproject-setup-dependency-management\u002Fuv-for-python-cli-dependency-management\u002Fuv-workspaces-for-multi-package-clis","uv Workspaces for Multi-Package Python CLIs",{"path":4125,"title":4126},"\u002Fproject-setup-dependency-management\u002Fvirtual-environments-isolation-best-practices\u002Fdebugging-wrong-python-and-wrong-venv-problems","Debugging Wrong-Python and Wrong-Venv Problems in CLIs",{"path":4128,"title":4129},"\u002Fproject-setup-dependency-management\u002Fvirtual-environments-isolation-best-practices\u002Fexternally-managed-environments-and-pep-668","PEP 668 and Python CLIs: the externally-managed-environment Error",{"path":4131,"title":4132},"\u002Fproject-setup-dependency-management\u002Fvirtual-environments-isolation-best-practices","Python CLI Env Isolation Best Practices",{"path":4134,"title":4135},"\u002Fproject-setup-dependency-management\u002Fvirtual-environments-isolation-best-practices\u002Fisolating-cli-tools-from-project-dependencies","Isolating CLI Tools from Your Project’s Dependencies",{"path":4137,"title":4138},"\u002Fproject-setup-dependency-management\u002Fvirtual-environments-isolation-best-practices\u002Fmanaging-virtual-environments-for-cross-platform-clis","Managing Python CLI Virtual Environments",{"path":4140,"title":4141},"\u002Fproject-setup-dependency-management\u002Fvirtual-environments-isolation-best-practices\u002Fpinning-the-python-version-for-a-cli","Pinning the Python Version for a CLI",{"path":4143,"title":4144},"\u002Fproject-setup-dependency-management\u002Fvirtual-environments-isolation-best-practices\u002Fsupporting-multiple-python-versions-with-nox","Supporting Multiple Python Versions with nox",1790967539846]