[{"data":1,"prerenderedAt":3151},["ShallowReactive",2],{"page-\u002Fcli-runtime-systems-integration\u002Flong-running-and-watch-mode-clis\u002Fbuilding-a-watch-mode-with-watchfiles\u002F":3,"content-directory":2604},{"id":4,"title":5,"body":6,"date":2590,"description":2591,"difficulty":2592,"draft":2593,"extension":2594,"meta":2595,"navigation":140,"path":2596,"seo":2597,"stem":2598,"tags":2599,"updated":2590,"__hash__":2603},"content\u002Fcli-runtime-systems-integration\u002Flong-running-and-watch-mode-clis\u002Fbuilding-a-watch-mode-with-watchfiles\u002Findex.md","Building a Watch Mode with watchfiles in Python",{"type":7,"value":8,"toc":2572},"minimark",[9,31,36,62,66,77,81,95,99,1007,1662,1667,1704,1707,1713,1719,1725,1731,1748,1752,1755,1815,1819,1825,2456,2463,2467,2473,2477,2485,2500,2504,2511,2515,2522,2526,2532,2536,2568],[10,11,12,13,17,18,20,21,24,25,30],"p",{},"Your CLI builds something from source files — a documentation site, a set of rendered templates, generated code, a bundle of config — and developers run it dozens of times an hour while editing. A ",[14,15,16],"code",{},"--watch"," flag that rebuilds automatically on save is one of the highest-value features a developer tool can offer. Written naively, it is also one of the most irritating: rebuilding five times per save, rebuilding forever because the build's own output triggers the watcher, exiting on the first syntax error, or burning a CPU core polling the disk. This guide builds a ",[14,19,16],{}," mode on the ",[14,22,23],{},"watchfiles"," package that batches changes, ignores what it should, survives broken input, prints useful output and can be tested deterministically. It belongs to the ",[26,27,29],"a",{"href":28},"\u002Fcli-runtime-systems-integration\u002Flong-running-and-watch-mode-clis\u002F","long-running and watch-mode topic",".",[32,33,35],"h2",{"id":34},"prerequisites","Prerequisites",[37,38,39,50,56],"ul",{},[40,41,42,43,45,46,49],"li",{},"Python 3.10+, Typer and ",[14,44,23],{}," 1.x (",[14,47,48],{},"uv add watchfiles","). It ships prebuilt wheels for Linux, macOS and Windows.",[40,51,52,53,30],{},"A build function you can call repeatedly: ",[14,54,55],{},"build(src: Path, out: Path) -> Result",[40,57,58,59,30],{},"Familiarity with the loop and stop-event ideas on ",[26,60,61],{"href":28},"the topic overview",[32,63,65],{"id":64},"how-change-detection-works","How change detection works",[10,67,68,69,72,73,76],{},"Modern operating systems notify programs when files change — inotify on Linux, FSEvents on macOS, ",[14,70,71],{},"ReadDirectoryChangesW"," on Windows — so a watcher does not need to poll. The catch is that one logical \"save\" is rarely one event. Editors write to a temporary file and rename it over the original, touch backup and swap files, and update metadata separately. A single ",[14,74,75],{},"Ctrl+S"," in some editors produces five or more events within a few milliseconds.",[78,79],"inline-diagram",{"name":80},"lr-watch-flow",[10,82,83,85,86,89,90,94],{},[14,84,23],{}," wraps the native APIs through Rust's ",[14,87,88],{},"notify"," library and ",[91,92,93],"strong",{},"debounces",": it waits until events stop arriving for a short step (50 ms by default), up to a maximum window, then yields everything collected as one set. Your loop sees one batch per save, not five events.",[32,96,98],{"id":97},"the-recipe","The recipe",[100,101,106],"pre",{"className":102,"code":103,"language":104,"meta":105,"style":105},"language-python shiki shiki-themes github-light github-dark","# src\u002Fmytool\u002Fwatching.py\nfrom __future__ import annotations\n\nimport threading\nimport time\nfrom collections.abc import Callable\nfrom datetime import datetime\nfrom pathlib import Path\n\nfrom watchfiles import Change, DefaultFilter, watch\n\nEcho = Callable[[str], None]\n\n\ndef _stamp() -> str:\n    return datetime.now().strftime(\"%H:%M:%S\")\n\n\ndef _describe(changes: set[tuple[Change, str]], root: Path) -> str:\n    paths = sorted({Path(p) for _, p in changes})\n    shown = \", \".join(str(p.relative_to(root)) if p.is_relative_to(root) else str(p) for p in paths[:3])\n    more = f\" (+{len(paths) - 3} more)\" if len(paths) > 3 else \"\"\n    return shown + more\n\n\ndef watch_and_rebuild(src: Path, out: Path, build: Callable[[set[Path] | None], int], *,\n                      echo: Echo, stop: threading.Event | None = None,\n                      extensions: tuple[str, ...] = (\".md\", \".html\", \".toml\")) -> None:\n    src, out = src.resolve(), out.resolve()\n\n    class SourceOnly(DefaultFilter):\n        def __call__(self, change: Change, path: str) -> bool:\n            return super().__call__(change, path) and path.endswith(extensions)\n\n    watch_filter = SourceOnly(ignore_paths=[out])     # our own output never triggers a build\n\n    def run(changed: set[Path] | None) -> None:\n        start = time.perf_counter()\n        try:\n            count = build(changed)\n        except Exception as exc:                        # a broken file must not end the watch\n            echo(f\"[{_stamp()}] error: {exc} — still watching\")\n            return\n        echo(f\"[{_stamp()}] built {count} file(s) in {time.perf_counter() - start:.2f}s\")\n\n    run(None)                                           # full build first\n    echo(f\"[{_stamp()}] watching {src} (Ctrl+C to stop)\")\n    for changes in watch(src, watch_filter=watch_filter, stop_event=stop, debounce=400):\n        echo(f\"[{_stamp()}] changed: {_describe(changes, src)}\")\n        deleted = {Path(p) for c, p in changes if c == Change.deleted}\n        run(None if deleted else {Path(p) for _, p in changes})\n","python","",[14,107,108,117,135,142,151,159,172,185,198,203,216,221,245,250,255,273,289,294,299,319,345,395,444,458,463,468,498,515,557,568,573,591,613,637,642,665,670,692,703,711,722,740,776,782,831,836,850,881,921,951,982],{"__ignoreMap":105},[109,110,113],"span",{"class":111,"line":112},"line",1,[109,114,116],{"class":115},"sJ8bj","# src\u002Fmytool\u002Fwatching.py\n",[109,118,120,124,128,131],{"class":111,"line":119},2,[109,121,123],{"class":122},"szBVR","from",[109,125,127],{"class":126},"sj4cs"," __future__",[109,129,130],{"class":122}," import",[109,132,134],{"class":133},"sVt8B"," annotations\n",[109,136,138],{"class":111,"line":137},3,[109,139,141],{"emptyLinePlaceholder":140},true,"\n",[109,143,145,148],{"class":111,"line":144},4,[109,146,147],{"class":122},"import",[109,149,150],{"class":133}," threading\n",[109,152,154,156],{"class":111,"line":153},5,[109,155,147],{"class":122},[109,157,158],{"class":133}," time\n",[109,160,162,164,167,169],{"class":111,"line":161},6,[109,163,123],{"class":122},[109,165,166],{"class":133}," collections.abc ",[109,168,147],{"class":122},[109,170,171],{"class":133}," Callable\n",[109,173,175,177,180,182],{"class":111,"line":174},7,[109,176,123],{"class":122},[109,178,179],{"class":133}," datetime ",[109,181,147],{"class":122},[109,183,184],{"class":133}," datetime\n",[109,186,188,190,193,195],{"class":111,"line":187},8,[109,189,123],{"class":122},[109,191,192],{"class":133}," pathlib ",[109,194,147],{"class":122},[109,196,197],{"class":133}," Path\n",[109,199,201],{"class":111,"line":200},9,[109,202,141],{"emptyLinePlaceholder":140},[109,204,206,208,211,213],{"class":111,"line":205},10,[109,207,123],{"class":122},[109,209,210],{"class":133}," watchfiles ",[109,212,147],{"class":122},[109,214,215],{"class":133}," Change, DefaultFilter, watch\n",[109,217,219],{"class":111,"line":218},11,[109,220,141],{"emptyLinePlaceholder":140},[109,222,224,227,230,233,236,239,242],{"class":111,"line":223},12,[109,225,226],{"class":133},"Echo ",[109,228,229],{"class":122},"=",[109,231,232],{"class":133}," Callable[[",[109,234,235],{"class":126},"str",[109,237,238],{"class":133},"], ",[109,240,241],{"class":126},"None",[109,243,244],{"class":133},"]\n",[109,246,248],{"class":111,"line":247},13,[109,249,141],{"emptyLinePlaceholder":140},[109,251,253],{"class":111,"line":252},14,[109,254,141],{"emptyLinePlaceholder":140},[109,256,258,261,265,268,270],{"class":111,"line":257},15,[109,259,260],{"class":122},"def",[109,262,264],{"class":263},"sScJk"," _stamp",[109,266,267],{"class":133},"() -> ",[109,269,235],{"class":126},[109,271,272],{"class":133},":\n",[109,274,276,279,282,286],{"class":111,"line":275},16,[109,277,278],{"class":122},"    return",[109,280,281],{"class":133}," datetime.now().strftime(",[109,283,285],{"class":284},"sZZnC","\"%H:%M:%S\"",[109,287,288],{"class":133},")\n",[109,290,292],{"class":111,"line":291},17,[109,293,141],{"emptyLinePlaceholder":140},[109,295,297],{"class":111,"line":296},18,[109,298,141],{"emptyLinePlaceholder":140},[109,300,302,304,307,310,312,315,317],{"class":111,"line":301},19,[109,303,260],{"class":122},[109,305,306],{"class":263}," _describe",[109,308,309],{"class":133},"(changes: set[tuple[Change, ",[109,311,235],{"class":126},[109,313,314],{"class":133},"]], root: Path) -> ",[109,316,235],{"class":126},[109,318,272],{"class":133},[109,320,322,325,327,330,333,336,339,342],{"class":111,"line":321},20,[109,323,324],{"class":133},"    paths ",[109,326,229],{"class":122},[109,328,329],{"class":126}," sorted",[109,331,332],{"class":133},"({Path(p) ",[109,334,335],{"class":122},"for",[109,337,338],{"class":133}," _, p ",[109,340,341],{"class":122},"in",[109,343,344],{"class":133}," changes})\n",[109,346,348,351,353,356,359,361,364,367,370,373,376,379,381,384,386,389,392],{"class":111,"line":347},21,[109,349,350],{"class":133},"    shown ",[109,352,229],{"class":122},[109,354,355],{"class":284}," \", \"",[109,357,358],{"class":133},".join(",[109,360,235],{"class":126},[109,362,363],{"class":133},"(p.relative_to(root)) ",[109,365,366],{"class":122},"if",[109,368,369],{"class":133}," p.is_relative_to(root) ",[109,371,372],{"class":122},"else",[109,374,375],{"class":126}," str",[109,377,378],{"class":133},"(p) ",[109,380,335],{"class":122},[109,382,383],{"class":133}," p ",[109,385,341],{"class":122},[109,387,388],{"class":133}," paths[:",[109,390,391],{"class":126},"3",[109,393,394],{"class":133},"])\n",[109,396,398,401,403,406,409,412,415,418,421,424,427,430,432,435,438,441],{"class":111,"line":397},22,[109,399,400],{"class":133},"    more ",[109,402,229],{"class":122},[109,404,405],{"class":122}," f",[109,407,408],{"class":284},"\" (+",[109,410,411],{"class":126},"{len",[109,413,414],{"class":133},"(paths) ",[109,416,417],{"class":122},"-",[109,419,420],{"class":126}," 3}",[109,422,423],{"class":284}," more)\"",[109,425,426],{"class":122}," if",[109,428,429],{"class":126}," len",[109,431,414],{"class":133},[109,433,434],{"class":122},">",[109,436,437],{"class":126}," 3",[109,439,440],{"class":122}," else",[109,442,443],{"class":284}," \"\"\n",[109,445,447,449,452,455],{"class":111,"line":446},23,[109,448,278],{"class":122},[109,450,451],{"class":133}," shown ",[109,453,454],{"class":122},"+",[109,456,457],{"class":133}," more\n",[109,459,461],{"class":111,"line":460},24,[109,462,141],{"emptyLinePlaceholder":140},[109,464,466],{"class":111,"line":465},25,[109,467,141],{"emptyLinePlaceholder":140},[109,469,471,473,476,479,482,485,487,490,492,495],{"class":111,"line":470},26,[109,472,260],{"class":122},[109,474,475],{"class":263}," watch_and_rebuild",[109,477,478],{"class":133},"(src: Path, out: Path, build: Callable[[set[Path] ",[109,480,481],{"class":122},"|",[109,483,484],{"class":126}," None",[109,486,238],{"class":133},[109,488,489],{"class":126},"int",[109,491,238],{"class":133},[109,493,494],{"class":122},"*",[109,496,497],{"class":133},",\n",[109,499,501,504,506,508,511,513],{"class":111,"line":500},27,[109,502,503],{"class":133},"                      echo: Echo, stop: threading.Event ",[109,505,481],{"class":122},[109,507,484],{"class":126},[109,509,510],{"class":122}," =",[109,512,484],{"class":126},[109,514,497],{"class":133},[109,516,518,521,523,526,529,532,534,537,540,542,545,547,550,553,555],{"class":111,"line":517},28,[109,519,520],{"class":133},"                      extensions: tuple[",[109,522,235],{"class":126},[109,524,525],{"class":133},", ",[109,527,528],{"class":126},"...",[109,530,531],{"class":133},"] ",[109,533,229],{"class":122},[109,535,536],{"class":133}," (",[109,538,539],{"class":284},"\".md\"",[109,541,525],{"class":133},[109,543,544],{"class":284},"\".html\"",[109,546,525],{"class":133},[109,548,549],{"class":284},"\".toml\"",[109,551,552],{"class":133},")) -> ",[109,554,241],{"class":126},[109,556,272],{"class":133},[109,558,560,563,565],{"class":111,"line":559},29,[109,561,562],{"class":133},"    src, out ",[109,564,229],{"class":122},[109,566,567],{"class":133}," src.resolve(), out.resolve()\n",[109,569,571],{"class":111,"line":570},30,[109,572,141],{"emptyLinePlaceholder":140},[109,574,576,579,582,585,588],{"class":111,"line":575},31,[109,577,578],{"class":122},"    class",[109,580,581],{"class":263}," SourceOnly",[109,583,584],{"class":133},"(",[109,586,587],{"class":263},"DefaultFilter",[109,589,590],{"class":133},"):\n",[109,592,594,597,600,603,605,608,611],{"class":111,"line":593},32,[109,595,596],{"class":122},"        def",[109,598,599],{"class":126}," __call__",[109,601,602],{"class":133},"(self, change: Change, path: ",[109,604,235],{"class":126},[109,606,607],{"class":133},") -> ",[109,609,610],{"class":126},"bool",[109,612,272],{"class":133},[109,614,616,619,622,625,628,631,634],{"class":111,"line":615},33,[109,617,618],{"class":122},"            return",[109,620,621],{"class":126}," super",[109,623,624],{"class":133},"().",[109,626,627],{"class":126},"__call__",[109,629,630],{"class":133},"(change, path) ",[109,632,633],{"class":122},"and",[109,635,636],{"class":133}," path.endswith(extensions)\n",[109,638,640],{"class":111,"line":639},34,[109,641,141],{"emptyLinePlaceholder":140},[109,643,645,648,650,653,657,659,662],{"class":111,"line":644},35,[109,646,647],{"class":133},"    watch_filter ",[109,649,229],{"class":122},[109,651,652],{"class":133}," SourceOnly(",[109,654,656],{"class":655},"s4XuR","ignore_paths",[109,658,229],{"class":122},[109,660,661],{"class":133},"[out])     ",[109,663,664],{"class":115},"# our own output never triggers a build\n",[109,666,668],{"class":111,"line":667},36,[109,669,141],{"emptyLinePlaceholder":140},[109,671,673,676,679,682,684,686,688,690],{"class":111,"line":672},37,[109,674,675],{"class":122},"    def",[109,677,678],{"class":263}," run",[109,680,681],{"class":133},"(changed: set[Path] ",[109,683,481],{"class":122},[109,685,484],{"class":126},[109,687,607],{"class":133},[109,689,241],{"class":126},[109,691,272],{"class":133},[109,693,695,698,700],{"class":111,"line":694},38,[109,696,697],{"class":133},"        start ",[109,699,229],{"class":122},[109,701,702],{"class":133}," time.perf_counter()\n",[109,704,706,709],{"class":111,"line":705},39,[109,707,708],{"class":122},"        try",[109,710,272],{"class":133},[109,712,714,717,719],{"class":111,"line":713},40,[109,715,716],{"class":133},"            count ",[109,718,229],{"class":122},[109,720,721],{"class":133}," build(changed)\n",[109,723,725,728,731,734,737],{"class":111,"line":724},41,[109,726,727],{"class":122},"        except",[109,729,730],{"class":126}," Exception",[109,732,733],{"class":122}," as",[109,735,736],{"class":133}," exc:                        ",[109,738,739],{"class":115},"# a broken file must not end the watch\n",[109,741,743,746,749,752,755,758,761,764,766,769,771,774],{"class":111,"line":742},42,[109,744,745],{"class":133},"            echo(",[109,747,748],{"class":122},"f",[109,750,751],{"class":284},"\"[",[109,753,754],{"class":126},"{",[109,756,757],{"class":133},"_stamp()",[109,759,760],{"class":126},"}",[109,762,763],{"class":284},"] error: ",[109,765,754],{"class":126},[109,767,768],{"class":133},"exc",[109,770,760],{"class":126},[109,772,773],{"class":284}," — still watching\"",[109,775,288],{"class":133},[109,777,779],{"class":111,"line":778},43,[109,780,781],{"class":122},"            return\n",[109,783,785,788,790,792,794,796,798,801,803,806,808,811,813,816,818,821,824,826,829],{"class":111,"line":784},44,[109,786,787],{"class":133},"        echo(",[109,789,748],{"class":122},[109,791,751],{"class":284},[109,793,754],{"class":126},[109,795,757],{"class":133},[109,797,760],{"class":126},[109,799,800],{"class":284},"] built ",[109,802,754],{"class":126},[109,804,805],{"class":133},"count",[109,807,760],{"class":126},[109,809,810],{"class":284}," file(s) in ",[109,812,754],{"class":126},[109,814,815],{"class":133},"time.perf_counter() ",[109,817,417],{"class":122},[109,819,820],{"class":133}," start",[109,822,823],{"class":122},":.2f",[109,825,760],{"class":126},[109,827,828],{"class":284},"s\"",[109,830,288],{"class":133},[109,832,834],{"class":111,"line":833},45,[109,835,141],{"emptyLinePlaceholder":140},[109,837,839,842,844,847],{"class":111,"line":838},46,[109,840,841],{"class":133},"    run(",[109,843,241],{"class":126},[109,845,846],{"class":133},")                                           ",[109,848,849],{"class":115},"# full build first\n",[109,851,853,856,858,860,862,864,866,869,871,874,876,879],{"class":111,"line":852},47,[109,854,855],{"class":133},"    echo(",[109,857,748],{"class":122},[109,859,751],{"class":284},[109,861,754],{"class":126},[109,863,757],{"class":133},[109,865,760],{"class":126},[109,867,868],{"class":284},"] watching ",[109,870,754],{"class":126},[109,872,873],{"class":133},"src",[109,875,760],{"class":126},[109,877,878],{"class":284}," (Ctrl+C to stop)\"",[109,880,288],{"class":133},[109,882,884,887,890,892,895,898,900,903,906,908,911,914,916,919],{"class":111,"line":883},48,[109,885,886],{"class":122},"    for",[109,888,889],{"class":133}," changes ",[109,891,341],{"class":122},[109,893,894],{"class":133}," watch(src, ",[109,896,897],{"class":655},"watch_filter",[109,899,229],{"class":122},[109,901,902],{"class":133},"watch_filter, ",[109,904,905],{"class":655},"stop_event",[109,907,229],{"class":122},[109,909,910],{"class":133},"stop, ",[109,912,913],{"class":655},"debounce",[109,915,229],{"class":122},[109,917,918],{"class":126},"400",[109,920,590],{"class":133},[109,922,924,926,928,930,932,934,936,939,941,944,946,949],{"class":111,"line":923},49,[109,925,787],{"class":133},[109,927,748],{"class":122},[109,929,751],{"class":284},[109,931,754],{"class":126},[109,933,757],{"class":133},[109,935,760],{"class":126},[109,937,938],{"class":284},"] changed: ",[109,940,754],{"class":126},[109,942,943],{"class":133},"_describe(changes, src)",[109,945,760],{"class":126},[109,947,948],{"class":284},"\"",[109,950,288],{"class":133},[109,952,954,957,959,962,964,967,969,971,973,976,979],{"class":111,"line":953},50,[109,955,956],{"class":133},"        deleted ",[109,958,229],{"class":122},[109,960,961],{"class":133}," {Path(p) ",[109,963,335],{"class":122},[109,965,966],{"class":133}," c, p ",[109,968,341],{"class":122},[109,970,889],{"class":133},[109,972,366],{"class":122},[109,974,975],{"class":133}," c ",[109,977,978],{"class":122},"==",[109,980,981],{"class":133}," Change.deleted}\n",[109,983,985,988,990,992,995,997,999,1001,1003,1005],{"class":111,"line":984},51,[109,986,987],{"class":133},"        run(",[109,989,241],{"class":126},[109,991,426],{"class":122},[109,993,994],{"class":133}," deleted ",[109,996,372],{"class":122},[109,998,961],{"class":133},[109,1000,335],{"class":122},[109,1002,338],{"class":133},[109,1004,341],{"class":122},[109,1006,344],{"class":133},[100,1008,1010],{"className":102,"code":1009,"language":104,"meta":105,"style":105},"# src\u002Fmytool\u002Fcli.py\nfrom pathlib import Path\n\nimport typer\n\nfrom mytool.watching import watch_and_rebuild\n\napp = typer.Typer()\n\n\ndef build_site(src: Path, out: Path, changed: set[Path] | None) -> int:\n    \"\"\"Render Markdown to HTML; only the changed files when we know them.\"\"\"\n    targets = sorted(changed) if changed else sorted(src.rglob(\"*.md\"))\n    for md in targets:\n        if md.suffix != \".md\":\n            continue\n        text = md.read_text(encoding=\"utf-8\")\n        if \"{{\" in text and \"}}\" not in text:\n            raise ValueError(f\"{md.name}: unclosed template tag\")\n        dest = out \u002F md.relative_to(src).with_suffix(\".html\")\n        dest.parent.mkdir(parents=True, exist_ok=True)\n        dest.write_text(f\"\u003Carticle>{text}\u003C\u002Farticle>\\n\", encoding=\"utf-8\")\n    return len(targets)\n\n\n@app.callback()\ndef main() -> None:\n    \"\"\"Static site tools.\"\"\"\n\n\n@app.command()\ndef build(\n    src: Path = typer.Argument(Path(\"docs\"), exists=True, file_okay=False),\n    out: Path = typer.Option(Path(\"site\"), \"--out\", \"-o\"),\n    watch: bool = typer.Option(False, \"--watch\", \"-w\", help=\"Rebuild when sources change.\"),\n) -> None:\n    \"\"\"Build the site once, or keep rebuilding with --watch.\"\"\"\n    src, out = src.resolve(), out.resolve()\n    if not watch:\n        n = build_site(src, out, None)\n        typer.echo(f\"built {n} file(s)\", err=True)\n        return\n    try:\n        watch_and_rebuild(src, out, lambda changed: build_site(src, out, changed),\n                          echo=lambda msg: typer.echo(msg, err=True))\n    except KeyboardInterrupt:\n        typer.echo(\"stopped watching\", err=True)\n\n\nif __name__ == \"__main__\":\n    app()\n",[14,1011,1012,1017,1027,1031,1038,1042,1054,1058,1068,1072,1076,1096,1101,1131,1143,1159,1164,1184,1219,1245,1265,1289,1324,1333,1337,1341,1349,1362,1367,1371,1375,1382,1392,1428,1453,1489,1497,1502,1510,1520,1534,1565,1570,1577,1588,1607,1617,1634,1638,1642,1657],{"__ignoreMap":105},[109,1013,1014],{"class":111,"line":112},[109,1015,1016],{"class":115},"# src\u002Fmytool\u002Fcli.py\n",[109,1018,1019,1021,1023,1025],{"class":111,"line":119},[109,1020,123],{"class":122},[109,1022,192],{"class":133},[109,1024,147],{"class":122},[109,1026,197],{"class":133},[109,1028,1029],{"class":111,"line":137},[109,1030,141],{"emptyLinePlaceholder":140},[109,1032,1033,1035],{"class":111,"line":144},[109,1034,147],{"class":122},[109,1036,1037],{"class":133}," typer\n",[109,1039,1040],{"class":111,"line":153},[109,1041,141],{"emptyLinePlaceholder":140},[109,1043,1044,1046,1049,1051],{"class":111,"line":161},[109,1045,123],{"class":122},[109,1047,1048],{"class":133}," mytool.watching ",[109,1050,147],{"class":122},[109,1052,1053],{"class":133}," watch_and_rebuild\n",[109,1055,1056],{"class":111,"line":174},[109,1057,141],{"emptyLinePlaceholder":140},[109,1059,1060,1063,1065],{"class":111,"line":187},[109,1061,1062],{"class":133},"app ",[109,1064,229],{"class":122},[109,1066,1067],{"class":133}," typer.Typer()\n",[109,1069,1070],{"class":111,"line":200},[109,1071,141],{"emptyLinePlaceholder":140},[109,1073,1074],{"class":111,"line":205},[109,1075,141],{"emptyLinePlaceholder":140},[109,1077,1078,1080,1083,1086,1088,1090,1092,1094],{"class":111,"line":218},[109,1079,260],{"class":122},[109,1081,1082],{"class":263}," build_site",[109,1084,1085],{"class":133},"(src: Path, out: Path, changed: set[Path] ",[109,1087,481],{"class":122},[109,1089,484],{"class":126},[109,1091,607],{"class":133},[109,1093,489],{"class":126},[109,1095,272],{"class":133},[109,1097,1098],{"class":111,"line":223},[109,1099,1100],{"class":284},"    \"\"\"Render Markdown to HTML; only the changed files when we know them.\"\"\"\n",[109,1102,1103,1106,1108,1110,1113,1115,1118,1120,1122,1125,1128],{"class":111,"line":247},[109,1104,1105],{"class":133},"    targets ",[109,1107,229],{"class":122},[109,1109,329],{"class":126},[109,1111,1112],{"class":133},"(changed) ",[109,1114,366],{"class":122},[109,1116,1117],{"class":133}," changed ",[109,1119,372],{"class":122},[109,1121,329],{"class":126},[109,1123,1124],{"class":133},"(src.rglob(",[109,1126,1127],{"class":284},"\"*.md\"",[109,1129,1130],{"class":133},"))\n",[109,1132,1133,1135,1138,1140],{"class":111,"line":252},[109,1134,886],{"class":122},[109,1136,1137],{"class":133}," md ",[109,1139,341],{"class":122},[109,1141,1142],{"class":133}," targets:\n",[109,1144,1145,1148,1151,1154,1157],{"class":111,"line":257},[109,1146,1147],{"class":122},"        if",[109,1149,1150],{"class":133}," md.suffix ",[109,1152,1153],{"class":122},"!=",[109,1155,1156],{"class":284}," \".md\"",[109,1158,272],{"class":133},[109,1160,1161],{"class":111,"line":275},[109,1162,1163],{"class":122},"            continue\n",[109,1165,1166,1169,1171,1174,1177,1179,1182],{"class":111,"line":291},[109,1167,1168],{"class":133},"        text ",[109,1170,229],{"class":122},[109,1172,1173],{"class":133}," md.read_text(",[109,1175,1176],{"class":655},"encoding",[109,1178,229],{"class":122},[109,1180,1181],{"class":284},"\"utf-8\"",[109,1183,288],{"class":133},[109,1185,1186,1188,1191,1194,1196,1199,1202,1204,1206,1209,1211,1214,1216],{"class":111,"line":296},[109,1187,1147],{"class":122},[109,1189,1190],{"class":284}," \"",[109,1192,1193],{"class":126},"{{",[109,1195,948],{"class":284},[109,1197,1198],{"class":122}," in",[109,1200,1201],{"class":133}," text ",[109,1203,633],{"class":122},[109,1205,1190],{"class":284},[109,1207,1208],{"class":126},"}}",[109,1210,948],{"class":284},[109,1212,1213],{"class":122}," not",[109,1215,1198],{"class":122},[109,1217,1218],{"class":133}," text:\n",[109,1220,1221,1224,1227,1229,1231,1233,1235,1238,1240,1243],{"class":111,"line":301},[109,1222,1223],{"class":122},"            raise",[109,1225,1226],{"class":126}," ValueError",[109,1228,584],{"class":133},[109,1230,748],{"class":122},[109,1232,948],{"class":284},[109,1234,754],{"class":126},[109,1236,1237],{"class":133},"md.name",[109,1239,760],{"class":126},[109,1241,1242],{"class":284},": unclosed template tag\"",[109,1244,288],{"class":133},[109,1246,1247,1250,1252,1255,1258,1261,1263],{"class":111,"line":321},[109,1248,1249],{"class":133},"        dest ",[109,1251,229],{"class":122},[109,1253,1254],{"class":133}," out ",[109,1256,1257],{"class":122},"\u002F",[109,1259,1260],{"class":133}," md.relative_to(src).with_suffix(",[109,1262,544],{"class":284},[109,1264,288],{"class":133},[109,1266,1267,1270,1273,1275,1278,1280,1283,1285,1287],{"class":111,"line":347},[109,1268,1269],{"class":133},"        dest.parent.mkdir(",[109,1271,1272],{"class":655},"parents",[109,1274,229],{"class":122},[109,1276,1277],{"class":126},"True",[109,1279,525],{"class":133},[109,1281,1282],{"class":655},"exist_ok",[109,1284,229],{"class":122},[109,1286,1277],{"class":126},[109,1288,288],{"class":133},[109,1290,1291,1294,1296,1299,1301,1304,1306,1309,1312,1314,1316,1318,1320,1322],{"class":111,"line":397},[109,1292,1293],{"class":133},"        dest.write_text(",[109,1295,748],{"class":122},[109,1297,1298],{"class":284},"\"\u003Carticle>",[109,1300,754],{"class":126},[109,1302,1303],{"class":133},"text",[109,1305,760],{"class":126},[109,1307,1308],{"class":284},"\u003C\u002Farticle>",[109,1310,1311],{"class":126},"\\n",[109,1313,948],{"class":284},[109,1315,525],{"class":133},[109,1317,1176],{"class":655},[109,1319,229],{"class":122},[109,1321,1181],{"class":284},[109,1323,288],{"class":133},[109,1325,1326,1328,1330],{"class":111,"line":446},[109,1327,278],{"class":122},[109,1329,429],{"class":126},[109,1331,1332],{"class":133},"(targets)\n",[109,1334,1335],{"class":111,"line":460},[109,1336,141],{"emptyLinePlaceholder":140},[109,1338,1339],{"class":111,"line":465},[109,1340,141],{"emptyLinePlaceholder":140},[109,1342,1343,1346],{"class":111,"line":470},[109,1344,1345],{"class":263},"@app.callback",[109,1347,1348],{"class":133},"()\n",[109,1350,1351,1353,1356,1358,1360],{"class":111,"line":500},[109,1352,260],{"class":122},[109,1354,1355],{"class":263}," main",[109,1357,267],{"class":133},[109,1359,241],{"class":126},[109,1361,272],{"class":133},[109,1363,1364],{"class":111,"line":517},[109,1365,1366],{"class":284},"    \"\"\"Static site tools.\"\"\"\n",[109,1368,1369],{"class":111,"line":559},[109,1370,141],{"emptyLinePlaceholder":140},[109,1372,1373],{"class":111,"line":570},[109,1374,141],{"emptyLinePlaceholder":140},[109,1376,1377,1380],{"class":111,"line":575},[109,1378,1379],{"class":263},"@app.command",[109,1381,1348],{"class":133},[109,1383,1384,1386,1389],{"class":111,"line":593},[109,1385,260],{"class":122},[109,1387,1388],{"class":263}," build",[109,1390,1391],{"class":133},"(\n",[109,1393,1394,1397,1399,1402,1405,1408,1411,1413,1415,1417,1420,1422,1425],{"class":111,"line":615},[109,1395,1396],{"class":133},"    src: Path ",[109,1398,229],{"class":122},[109,1400,1401],{"class":133}," typer.Argument(Path(",[109,1403,1404],{"class":284},"\"docs\"",[109,1406,1407],{"class":133},"), ",[109,1409,1410],{"class":655},"exists",[109,1412,229],{"class":122},[109,1414,1277],{"class":126},[109,1416,525],{"class":133},[109,1418,1419],{"class":655},"file_okay",[109,1421,229],{"class":122},[109,1423,1424],{"class":126},"False",[109,1426,1427],{"class":133},"),\n",[109,1429,1430,1433,1435,1438,1441,1443,1446,1448,1451],{"class":111,"line":639},[109,1431,1432],{"class":133},"    out: Path ",[109,1434,229],{"class":122},[109,1436,1437],{"class":133}," typer.Option(Path(",[109,1439,1440],{"class":284},"\"site\"",[109,1442,1407],{"class":133},[109,1444,1445],{"class":284},"\"--out\"",[109,1447,525],{"class":133},[109,1449,1450],{"class":284},"\"-o\"",[109,1452,1427],{"class":133},[109,1454,1455,1458,1460,1462,1465,1467,1469,1472,1474,1477,1479,1482,1484,1487],{"class":111,"line":644},[109,1456,1457],{"class":133},"    watch: ",[109,1459,610],{"class":126},[109,1461,510],{"class":122},[109,1463,1464],{"class":133}," typer.Option(",[109,1466,1424],{"class":126},[109,1468,525],{"class":133},[109,1470,1471],{"class":284},"\"--watch\"",[109,1473,525],{"class":133},[109,1475,1476],{"class":284},"\"-w\"",[109,1478,525],{"class":133},[109,1480,1481],{"class":655},"help",[109,1483,229],{"class":122},[109,1485,1486],{"class":284},"\"Rebuild when sources change.\"",[109,1488,1427],{"class":133},[109,1490,1491,1493,1495],{"class":111,"line":667},[109,1492,607],{"class":133},[109,1494,241],{"class":126},[109,1496,272],{"class":133},[109,1498,1499],{"class":111,"line":672},[109,1500,1501],{"class":284},"    \"\"\"Build the site once, or keep rebuilding with --watch.\"\"\"\n",[109,1503,1504,1506,1508],{"class":111,"line":694},[109,1505,562],{"class":133},[109,1507,229],{"class":122},[109,1509,567],{"class":133},[109,1511,1512,1515,1517],{"class":111,"line":705},[109,1513,1514],{"class":122},"    if",[109,1516,1213],{"class":122},[109,1518,1519],{"class":133}," watch:\n",[109,1521,1522,1525,1527,1530,1532],{"class":111,"line":713},[109,1523,1524],{"class":133},"        n ",[109,1526,229],{"class":122},[109,1528,1529],{"class":133}," build_site(src, out, ",[109,1531,241],{"class":126},[109,1533,288],{"class":133},[109,1535,1536,1539,1541,1544,1546,1549,1551,1554,1556,1559,1561,1563],{"class":111,"line":724},[109,1537,1538],{"class":133},"        typer.echo(",[109,1540,748],{"class":122},[109,1542,1543],{"class":284},"\"built ",[109,1545,754],{"class":126},[109,1547,1548],{"class":133},"n",[109,1550,760],{"class":126},[109,1552,1553],{"class":284}," file(s)\"",[109,1555,525],{"class":133},[109,1557,1558],{"class":655},"err",[109,1560,229],{"class":122},[109,1562,1277],{"class":126},[109,1564,288],{"class":133},[109,1566,1567],{"class":111,"line":742},[109,1568,1569],{"class":122},"        return\n",[109,1571,1572,1575],{"class":111,"line":778},[109,1573,1574],{"class":122},"    try",[109,1576,272],{"class":133},[109,1578,1579,1582,1585],{"class":111,"line":784},[109,1580,1581],{"class":133},"        watch_and_rebuild(src, out, ",[109,1583,1584],{"class":122},"lambda",[109,1586,1587],{"class":133}," changed: build_site(src, out, changed),\n",[109,1589,1590,1593,1596,1599,1601,1603,1605],{"class":111,"line":833},[109,1591,1592],{"class":655},"                          echo",[109,1594,1595],{"class":122},"=lambda",[109,1597,1598],{"class":133}," msg: typer.echo(msg, ",[109,1600,1558],{"class":655},[109,1602,229],{"class":122},[109,1604,1277],{"class":126},[109,1606,1130],{"class":133},[109,1608,1609,1612,1615],{"class":111,"line":838},[109,1610,1611],{"class":122},"    except",[109,1613,1614],{"class":126}," KeyboardInterrupt",[109,1616,272],{"class":133},[109,1618,1619,1621,1624,1626,1628,1630,1632],{"class":111,"line":852},[109,1620,1538],{"class":133},[109,1622,1623],{"class":284},"\"stopped watching\"",[109,1625,525],{"class":133},[109,1627,1558],{"class":655},[109,1629,229],{"class":122},[109,1631,1277],{"class":126},[109,1633,288],{"class":133},[109,1635,1636],{"class":111,"line":883},[109,1637,141],{"emptyLinePlaceholder":140},[109,1639,1640],{"class":111,"line":923},[109,1641,141],{"emptyLinePlaceholder":140},[109,1643,1644,1646,1649,1652,1655],{"class":111,"line":953},[109,1645,366],{"class":122},[109,1647,1648],{"class":126}," __name__",[109,1650,1651],{"class":122}," ==",[109,1653,1654],{"class":284}," \"__main__\"",[109,1656,272],{"class":133},[109,1658,1659],{"class":111,"line":984},[109,1660,1661],{"class":133},"    app()\n",[1663,1664,1666],"h3",{"id":1665},"the-decisions-that-make-it-pleasant","The decisions that make it pleasant",[10,1668,1669,1672,1673,1676,1677,1680,1681,1684,1685,1687,1688,525,1691,525,1694,525,1697,525,1700,1703],{},[91,1670,1671],{},"Ignore your own output."," If ",[14,1674,1675],{},"site\u002F"," sits inside ",[14,1678,1679],{},"docs\u002F",", or the build writes caches next to sources, every build produces events that trigger the next build — an infinite loop that pins the CPU. ",[14,1682,1683],{},"ignore_paths=[out]"," removes that failure mode entirely. ",[14,1686,587],{}," already ignores ",[14,1689,1690],{},".git",[14,1692,1693],{},".venv",[14,1695,1696],{},"node_modules",[14,1698,1699],{},"__pycache__",[14,1701,1702],{},".pyc"," files and editor swap files.",[78,1705],{"name":1706},"lr-watch-filter",[10,1708,1709,1712],{},[91,1710,1711],{},"Filter by extension."," Restricting to the file types the build actually reads keeps unrelated edits — a README, a notes file — from triggering rebuilds.",[10,1714,1715,1718],{},[91,1716,1717],{},"Build everything first."," The initial full build guarantees the output is current before watching begins, so the first save does not reveal a stale site.",[10,1720,1721,1724],{},[91,1722,1723],{},"Rebuild incrementally when it is safe."," Passing the set of changed paths lets the build skip untouched files, which is what keeps rebuilds under a second on large projects. Deletions and renames are harder to handle incrementally — the old output must be removed — so a batch containing a deletion falls back to a full rebuild. When in doubt, full rebuilds are correct; incremental ones are an optimisation.",[10,1726,1727,1730],{},[91,1728,1729],{},"Errors are output, not exits."," A developer mid-edit will save broken files constantly. The watch loop catches exceptions from the build, prints them with a timestamp, and waits for the next save. Exiting on the first error would make watch mode useless.",[10,1732,1733,1736,1737,1740,1741,1743,1744,1747],{},[91,1734,1735],{},"Stop events for tests and embedding."," ",[14,1738,1739],{},"watch()"," accepts a ",[14,1742,905],{},", which ends the iteration cleanly when set. The CLI does not need it — Ctrl+C raises ",[14,1745,1746],{},"KeyboardInterrupt"," out of the generator — but tests and any code embedding the watcher do.",[32,1749,1751],{"id":1750},"ux-considerations","UX considerations",[78,1753],{"name":1754},"lr-watch-terminal",[37,1756,1757,1763,1769,1778,1788,1798],{},[40,1758,1759,1762],{},[91,1760,1761],{},"Timestamp every line."," When a developer glances at the terminal, the time tells them whether the last build reflects their latest save.",[40,1764,1765,1768],{},[91,1766,1767],{},"Name what changed."," \"changed: docs\u002Fintro.md\" confirms the watcher saw the right file — the most common watch-mode confusion is editing a file outside the watched directory.",[40,1770,1771,1774,1775,30],{},[91,1772,1773],{},"Keep it quiet."," One line for the change and one for the result is enough. Stream full build logs only with ",[14,1776,1777],{},"--verbose",[40,1779,1780,1783,1784,1787],{},[91,1781,1782],{},"Clear the screen optionally."," Some tools clear the terminal before each rebuild so only current errors are visible. Offer it as ",[14,1785,1786],{},"--clear","; do not force it, because it destroys scrollback people may want.",[40,1789,1790,1793,1794,1797],{},[91,1791,1792],{},"Combine with a server carefully."," If the command also serves the output (",[14,1795,1796],{},"--serve","), run the HTTP server in a thread and the watch loop in the main thread, so Ctrl+C reaches the watcher.",[40,1799,1800,1803,1804,1806,1807,1810,1811,1814],{},[91,1801,1802],{},"Mention polling for odd filesystems."," Network drives, Docker bind mounts on macOS and some WSL paths do not deliver native events. ",[14,1805,23],{}," supports ",[14,1808,1809],{},"force_polling=True"," (or the ",[14,1812,1813],{},"WATCHFILES_FORCE_POLLING"," environment variable); document it for users who see no rebuilds.",[32,1816,1818],{"id":1817},"testing-the-behaviour","Testing the behaviour",[10,1820,1821,1822,1824],{},"Watch mode is testable without sleeps-and-hope: run the watcher in a background thread with a ",[14,1823,905],{},", make a real file change, wait for the build callback, then stop:",[100,1826,1828],{"className":102,"code":1827,"language":104,"meta":105,"style":105},"# tests\u002Ftest_watch.py\nimport threading\nfrom pathlib import Path\n\nfrom mytool.watching import watch_and_rebuild\n\n\ndef run_watcher(src: Path, out: Path):\n    builds: list[set[Path] | None] = []\n    built = threading.Event()\n    stop = threading.Event()\n    messages: list[str] = []\n\n    def build(changed):\n        builds.append(changed)\n        built.set()\n        if changed and any(p.name == \"broken.md\" for p in changed):\n            raise ValueError(\"unclosed tag\")\n        return len(changed or [])\n\n    t = threading.Thread(target=watch_and_rebuild, args=(src, out, build),\n                         kwargs={\"echo\": messages.append, \"stop\": stop}, daemon=True)\n    t.start()\n    return builds, built, stop, messages, t\n\n\ndef test_initial_build_then_rebuild_on_change(tmp_path):\n    src, out = tmp_path \u002F \"docs\", tmp_path \u002F \"site\"\n    src.mkdir()\n    (src \u002F \"a.md\").write_text(\"hello\")\n    builds, built, stop, messages, t = run_watcher(src, out)\n    assert built.wait(5) and builds[0] is None          # full initial build\n    built.clear()\n    (src \u002F \"a.md\").write_text(\"hello again\")\n    assert built.wait(5)\n    assert builds[-1] == {(src \u002F \"a.md\").resolve()}\n    stop.set()\n    t.join(5)\n\n\ndef test_output_dir_is_ignored_and_errors_do_not_stop(tmp_path):\n    src = tmp_path \u002F \"docs\"\n    out = src \u002F \"_site\"                                   # output inside the source tree\n    out.mkdir(parents=True)\n    builds, built, stop, messages, t = run_watcher(src, out)\n    assert built.wait(5)\n    built.clear()\n    (out \u002F \"index.html\").write_text(\"generated\")          # must NOT trigger a build\n    assert not built.wait(1.5)\n    (src \u002F \"broken.md\").write_text(\"{{ oops\")\n    assert built.wait(5)\n    assert any(\"still watching\" in m for m in messages)\n    assert t.is_alive()                                   # the error did not end the watch\n    stop.set()\n    t.join(5)\n",[14,1829,1830,1835,1841,1851,1855,1865,1869,1873,1883,1899,1909,1918,1931,1935,1944,1949,1954,1983,1996,2012,2016,2042,2072,2077,2084,2088,2092,2102,2124,2129,2147,2157,2189,2194,2209,2219,2244,2249,2258,2262,2266,2275,2289,2307,2320,2328,2338,2342,2363,2376,2395,2405,2431,2442,2447],{"__ignoreMap":105},[109,1831,1832],{"class":111,"line":112},[109,1833,1834],{"class":115},"# tests\u002Ftest_watch.py\n",[109,1836,1837,1839],{"class":111,"line":119},[109,1838,147],{"class":122},[109,1840,150],{"class":133},[109,1842,1843,1845,1847,1849],{"class":111,"line":137},[109,1844,123],{"class":122},[109,1846,192],{"class":133},[109,1848,147],{"class":122},[109,1850,197],{"class":133},[109,1852,1853],{"class":111,"line":144},[109,1854,141],{"emptyLinePlaceholder":140},[109,1856,1857,1859,1861,1863],{"class":111,"line":153},[109,1858,123],{"class":122},[109,1860,1048],{"class":133},[109,1862,147],{"class":122},[109,1864,1053],{"class":133},[109,1866,1867],{"class":111,"line":161},[109,1868,141],{"emptyLinePlaceholder":140},[109,1870,1871],{"class":111,"line":174},[109,1872,141],{"emptyLinePlaceholder":140},[109,1874,1875,1877,1880],{"class":111,"line":187},[109,1876,260],{"class":122},[109,1878,1879],{"class":263}," run_watcher",[109,1881,1882],{"class":133},"(src: Path, out: Path):\n",[109,1884,1885,1888,1890,1892,1894,1896],{"class":111,"line":200},[109,1886,1887],{"class":133},"    builds: list[set[Path] ",[109,1889,481],{"class":122},[109,1891,484],{"class":126},[109,1893,531],{"class":133},[109,1895,229],{"class":122},[109,1897,1898],{"class":133}," []\n",[109,1900,1901,1904,1906],{"class":111,"line":205},[109,1902,1903],{"class":133},"    built ",[109,1905,229],{"class":122},[109,1907,1908],{"class":133}," threading.Event()\n",[109,1910,1911,1914,1916],{"class":111,"line":218},[109,1912,1913],{"class":133},"    stop ",[109,1915,229],{"class":122},[109,1917,1908],{"class":133},[109,1919,1920,1923,1925,1927,1929],{"class":111,"line":223},[109,1921,1922],{"class":133},"    messages: list[",[109,1924,235],{"class":126},[109,1926,531],{"class":133},[109,1928,229],{"class":122},[109,1930,1898],{"class":133},[109,1932,1933],{"class":111,"line":247},[109,1934,141],{"emptyLinePlaceholder":140},[109,1936,1937,1939,1941],{"class":111,"line":252},[109,1938,675],{"class":122},[109,1940,1388],{"class":263},[109,1942,1943],{"class":133},"(changed):\n",[109,1945,1946],{"class":111,"line":257},[109,1947,1948],{"class":133},"        builds.append(changed)\n",[109,1950,1951],{"class":111,"line":275},[109,1952,1953],{"class":133},"        built.set()\n",[109,1955,1956,1958,1960,1962,1965,1968,1970,1973,1976,1978,1980],{"class":111,"line":291},[109,1957,1147],{"class":122},[109,1959,1117],{"class":133},[109,1961,633],{"class":122},[109,1963,1964],{"class":126}," any",[109,1966,1967],{"class":133},"(p.name ",[109,1969,978],{"class":122},[109,1971,1972],{"class":284}," \"broken.md\"",[109,1974,1975],{"class":122}," for",[109,1977,383],{"class":133},[109,1979,341],{"class":122},[109,1981,1982],{"class":133}," changed):\n",[109,1984,1985,1987,1989,1991,1994],{"class":111,"line":296},[109,1986,1223],{"class":122},[109,1988,1226],{"class":126},[109,1990,584],{"class":133},[109,1992,1993],{"class":284},"\"unclosed tag\"",[109,1995,288],{"class":133},[109,1997,1998,2001,2003,2006,2009],{"class":111,"line":301},[109,1999,2000],{"class":122},"        return",[109,2002,429],{"class":126},[109,2004,2005],{"class":133},"(changed ",[109,2007,2008],{"class":122},"or",[109,2010,2011],{"class":133}," [])\n",[109,2013,2014],{"class":111,"line":321},[109,2015,141],{"emptyLinePlaceholder":140},[109,2017,2018,2021,2023,2026,2029,2031,2034,2037,2039],{"class":111,"line":347},[109,2019,2020],{"class":133},"    t ",[109,2022,229],{"class":122},[109,2024,2025],{"class":133}," threading.Thread(",[109,2027,2028],{"class":655},"target",[109,2030,229],{"class":122},[109,2032,2033],{"class":133},"watch_and_rebuild, ",[109,2035,2036],{"class":655},"args",[109,2038,229],{"class":122},[109,2040,2041],{"class":133},"(src, out, build),\n",[109,2043,2044,2047,2049,2051,2054,2057,2060,2063,2066,2068,2070],{"class":111,"line":397},[109,2045,2046],{"class":655},"                         kwargs",[109,2048,229],{"class":122},[109,2050,754],{"class":133},[109,2052,2053],{"class":284},"\"echo\"",[109,2055,2056],{"class":133},": messages.append, ",[109,2058,2059],{"class":284},"\"stop\"",[109,2061,2062],{"class":133},": stop}, ",[109,2064,2065],{"class":655},"daemon",[109,2067,229],{"class":122},[109,2069,1277],{"class":126},[109,2071,288],{"class":133},[109,2073,2074],{"class":111,"line":446},[109,2075,2076],{"class":133},"    t.start()\n",[109,2078,2079,2081],{"class":111,"line":460},[109,2080,278],{"class":122},[109,2082,2083],{"class":133}," builds, built, stop, messages, t\n",[109,2085,2086],{"class":111,"line":465},[109,2087,141],{"emptyLinePlaceholder":140},[109,2089,2090],{"class":111,"line":470},[109,2091,141],{"emptyLinePlaceholder":140},[109,2093,2094,2096,2099],{"class":111,"line":500},[109,2095,260],{"class":122},[109,2097,2098],{"class":263}," test_initial_build_then_rebuild_on_change",[109,2100,2101],{"class":133},"(tmp_path):\n",[109,2103,2104,2106,2108,2111,2113,2116,2119,2121],{"class":111,"line":517},[109,2105,562],{"class":133},[109,2107,229],{"class":122},[109,2109,2110],{"class":133}," tmp_path ",[109,2112,1257],{"class":122},[109,2114,2115],{"class":284}," \"docs\"",[109,2117,2118],{"class":133},", tmp_path ",[109,2120,1257],{"class":122},[109,2122,2123],{"class":284}," \"site\"\n",[109,2125,2126],{"class":111,"line":559},[109,2127,2128],{"class":133},"    src.mkdir()\n",[109,2130,2131,2134,2136,2139,2142,2145],{"class":111,"line":570},[109,2132,2133],{"class":133},"    (src ",[109,2135,1257],{"class":122},[109,2137,2138],{"class":284}," \"a.md\"",[109,2140,2141],{"class":133},").write_text(",[109,2143,2144],{"class":284},"\"hello\"",[109,2146,288],{"class":133},[109,2148,2149,2152,2154],{"class":111,"line":575},[109,2150,2151],{"class":133},"    builds, built, stop, messages, t ",[109,2153,229],{"class":122},[109,2155,2156],{"class":133}," run_watcher(src, out)\n",[109,2158,2159,2162,2165,2168,2171,2173,2176,2179,2181,2184,2186],{"class":111,"line":593},[109,2160,2161],{"class":122},"    assert",[109,2163,2164],{"class":133}," built.wait(",[109,2166,2167],{"class":126},"5",[109,2169,2170],{"class":133},") ",[109,2172,633],{"class":122},[109,2174,2175],{"class":133}," builds[",[109,2177,2178],{"class":126},"0",[109,2180,531],{"class":133},[109,2182,2183],{"class":122},"is",[109,2185,484],{"class":126},[109,2187,2188],{"class":115},"          # full initial build\n",[109,2190,2191],{"class":111,"line":615},[109,2192,2193],{"class":133},"    built.clear()\n",[109,2195,2196,2198,2200,2202,2204,2207],{"class":111,"line":639},[109,2197,2133],{"class":133},[109,2199,1257],{"class":122},[109,2201,2138],{"class":284},[109,2203,2141],{"class":133},[109,2205,2206],{"class":284},"\"hello again\"",[109,2208,288],{"class":133},[109,2210,2211,2213,2215,2217],{"class":111,"line":644},[109,2212,2161],{"class":122},[109,2214,2164],{"class":133},[109,2216,2167],{"class":126},[109,2218,288],{"class":133},[109,2220,2221,2223,2225,2227,2230,2232,2234,2237,2239,2241],{"class":111,"line":667},[109,2222,2161],{"class":122},[109,2224,2175],{"class":133},[109,2226,417],{"class":122},[109,2228,2229],{"class":126},"1",[109,2231,531],{"class":133},[109,2233,978],{"class":122},[109,2235,2236],{"class":133}," {(src ",[109,2238,1257],{"class":122},[109,2240,2138],{"class":284},[109,2242,2243],{"class":133},").resolve()}\n",[109,2245,2246],{"class":111,"line":672},[109,2247,2248],{"class":133},"    stop.set()\n",[109,2250,2251,2254,2256],{"class":111,"line":694},[109,2252,2253],{"class":133},"    t.join(",[109,2255,2167],{"class":126},[109,2257,288],{"class":133},[109,2259,2260],{"class":111,"line":705},[109,2261,141],{"emptyLinePlaceholder":140},[109,2263,2264],{"class":111,"line":713},[109,2265,141],{"emptyLinePlaceholder":140},[109,2267,2268,2270,2273],{"class":111,"line":724},[109,2269,260],{"class":122},[109,2271,2272],{"class":263}," test_output_dir_is_ignored_and_errors_do_not_stop",[109,2274,2101],{"class":133},[109,2276,2277,2280,2282,2284,2286],{"class":111,"line":742},[109,2278,2279],{"class":133},"    src ",[109,2281,229],{"class":122},[109,2283,2110],{"class":133},[109,2285,1257],{"class":122},[109,2287,2288],{"class":284}," \"docs\"\n",[109,2290,2291,2294,2296,2299,2301,2304],{"class":111,"line":778},[109,2292,2293],{"class":133},"    out ",[109,2295,229],{"class":122},[109,2297,2298],{"class":133}," src ",[109,2300,1257],{"class":122},[109,2302,2303],{"class":284}," \"_site\"",[109,2305,2306],{"class":115},"                                   # output inside the source tree\n",[109,2308,2309,2312,2314,2316,2318],{"class":111,"line":784},[109,2310,2311],{"class":133},"    out.mkdir(",[109,2313,1272],{"class":655},[109,2315,229],{"class":122},[109,2317,1277],{"class":126},[109,2319,288],{"class":133},[109,2321,2322,2324,2326],{"class":111,"line":833},[109,2323,2151],{"class":133},[109,2325,229],{"class":122},[109,2327,2156],{"class":133},[109,2329,2330,2332,2334,2336],{"class":111,"line":838},[109,2331,2161],{"class":122},[109,2333,2164],{"class":133},[109,2335,2167],{"class":126},[109,2337,288],{"class":133},[109,2339,2340],{"class":111,"line":852},[109,2341,2193],{"class":133},[109,2343,2344,2347,2349,2352,2354,2357,2360],{"class":111,"line":883},[109,2345,2346],{"class":133},"    (out ",[109,2348,1257],{"class":122},[109,2350,2351],{"class":284}," \"index.html\"",[109,2353,2141],{"class":133},[109,2355,2356],{"class":284},"\"generated\"",[109,2358,2359],{"class":133},")          ",[109,2361,2362],{"class":115},"# must NOT trigger a build\n",[109,2364,2365,2367,2369,2371,2374],{"class":111,"line":923},[109,2366,2161],{"class":122},[109,2368,1213],{"class":122},[109,2370,2164],{"class":133},[109,2372,2373],{"class":126},"1.5",[109,2375,288],{"class":133},[109,2377,2378,2380,2382,2384,2386,2388,2390,2393],{"class":111,"line":953},[109,2379,2133],{"class":133},[109,2381,1257],{"class":122},[109,2383,1972],{"class":284},[109,2385,2141],{"class":133},[109,2387,948],{"class":284},[109,2389,1193],{"class":126},[109,2391,2392],{"class":284}," oops\"",[109,2394,288],{"class":133},[109,2396,2397,2399,2401,2403],{"class":111,"line":984},[109,2398,2161],{"class":122},[109,2400,2164],{"class":133},[109,2402,2167],{"class":126},[109,2404,288],{"class":133},[109,2406,2408,2410,2412,2414,2417,2419,2422,2424,2426,2428],{"class":111,"line":2407},52,[109,2409,2161],{"class":122},[109,2411,1964],{"class":126},[109,2413,584],{"class":133},[109,2415,2416],{"class":284},"\"still watching\"",[109,2418,1198],{"class":122},[109,2420,2421],{"class":133}," m ",[109,2423,335],{"class":122},[109,2425,2421],{"class":133},[109,2427,341],{"class":122},[109,2429,2430],{"class":133}," messages)\n",[109,2432,2434,2436,2439],{"class":111,"line":2433},53,[109,2435,2161],{"class":122},[109,2437,2438],{"class":133}," t.is_alive()                                   ",[109,2440,2441],{"class":115},"# the error did not end the watch\n",[109,2443,2445],{"class":111,"line":2444},54,[109,2446,2248],{"class":133},[109,2448,2450,2452,2454],{"class":111,"line":2449},55,[109,2451,2253],{"class":133},[109,2453,2167],{"class":126},[109,2455,288],{"class":133},[10,2457,2458,2459,2462],{},"These tests touch the real filesystem and real OS notifications, so they are a little slower than pure unit tests — a few seconds in total — but they catch exactly the regressions that matter: a lost ignore rule and an exception escaping the loop. If a CI environment lacks native events, set ",[14,2460,2461],{},"WATCHFILES_FORCE_POLLING=1"," for the test job.",[32,2464,2466],{"id":2465},"conclusion","Conclusion",[10,2468,2469,2470,2472],{},"A good watch mode is a loop with four properties: one rebuild per save (debouncing), no rebuilds from its own output (ignore paths), no exit on broken input (catch and report), and output that tells the developer what changed and when. ",[14,2471,23],{}," provides the first two almost for free, and the rest is a dozen lines of careful loop. Test it with a stop event and real file writes, and it becomes a feature your users reach for every day.",[32,2474,2476],{"id":2475},"frequently-asked-questions","Frequently asked questions",[1663,2478,2480,2481,2484],{"id":2479},"why-not-use-watchdog","Why not use ",[14,2482,2483],{},"watchdog","?",[10,2486,2487,2489,2490,2492,2493,2496,2497,30],{},[14,2488,2483],{}," is mature and widely used, but its callback-and-observer API needs more code for debouncing, and it has historically had more platform quirks. ",[14,2491,23],{}," gives you batched changes as a simple generator (and an async ",[14,2494,2495],{},"awatch","), which fits CLI loops naturally. Either works; pick one and hide it behind a function like ",[14,2498,2499],{},"watch_and_rebuild",[1663,2501,2503],{"id":2502},"can-the-watcher-also-restart-a-server-or-subprocess","Can the watcher also restart a server or subprocess?",[10,2505,2506,2507,2510],{},"Yes: ",[14,2508,2509],{},"watchfiles.run_process(path, target=...)"," restarts a function or command whenever files change, which is exactly what development servers need. For a build-then-serve tool, keep the server running and only rebuild; restarting is for code that cannot reload itself.",[1663,2512,2514],{"id":2513},"how-do-i-watch-config-files-outside-the-source-tree","How do I watch config files outside the source tree?",[10,2516,2517,2518,2521],{},"Pass several paths to ",[14,2519,2520],{},"watch(src, config_file.parent, ...)"," and filter by exact path for the config. When the config changes, rebuild everything, since it can affect every output file.",[1663,2523,2525],{"id":2524},"does-watch-mode-work-inside-docker-on-macos","Does watch mode work inside Docker on macOS?",[10,2527,2528,2529,2531],{},"Bind mounts from macOS hosts do not always forward file events into the Linux VM. If rebuilds do not fire, enable polling with ",[14,2530,2461],{},"; it costs some CPU but works everywhere.",[32,2533,2535],{"id":2534},"related","Related",[37,2537,2538,2544,2550,2556,2562],{},[40,2539,2540,2541],{},"Up: ",[26,2542,2543],{"href":28},"Long-running and watch-mode CLIs",[40,2545,2546],{},[26,2547,2549],{"href":2548},"\u002Fcli-runtime-systems-integration\u002Flong-running-and-watch-mode-clis\u002Fhandling-sigterm-and-graceful-shutdown\u002F","Handling SIGTERM and graceful shutdown",[40,2551,2552],{},[26,2553,2555],{"href":2554},"\u002Fcli-runtime-systems-integration\u002Flong-running-and-watch-mode-clis\u002Fhealth-checks-and-heartbeats-for-long-running-clis\u002F","Health checks and heartbeats for long-running CLIs",[40,2557,2558],{},[26,2559,2561],{"href":2560},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcli-startup-performance-and-lazy-loading\u002Fcaching-expensive-work-between-cli-runs\u002F","Caching expensive work between CLI runs",[40,2563,2564],{},[26,2565,2567],{"href":2566},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes\u002Fdetecting-tty-and-adapting-output\u002F","Detecting a TTY and adapting output",[2569,2570,2571],"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 .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}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":105,"searchDepth":119,"depth":119,"links":2573},[2574,2575,2576,2579,2580,2581,2582,2589],{"id":34,"depth":119,"text":35},{"id":64,"depth":119,"text":65},{"id":97,"depth":119,"text":98,"children":2577},[2578],{"id":1665,"depth":137,"text":1666},{"id":1750,"depth":119,"text":1751},{"id":1817,"depth":119,"text":1818},{"id":2465,"depth":119,"text":2466},{"id":2475,"depth":119,"text":2476,"children":2583},[2584,2586,2587,2588],{"id":2479,"depth":137,"text":2585},"Why not use watchdog?",{"id":2502,"depth":137,"text":2503},{"id":2513,"depth":137,"text":2514},{"id":2524,"depth":137,"text":2525},{"id":2534,"depth":119,"text":2535},"2026-09-18","Add --watch to a Python CLI with watchfiles: debounced rebuilds, ignoring your own output, surviving errors, clear timestamped output and stop-event tests.","intermediate",false,"md",{},"\u002Fcli-runtime-systems-integration\u002Flong-running-and-watch-mode-clis\u002Fbuilding-a-watch-mode-with-watchfiles",{"title":5,"description":2591},"cli-runtime-systems-integration\u002Flong-running-and-watch-mode-clis\u002Fbuilding-a-watch-mode-with-watchfiles\u002Findex",[2600,23,2601,2602],"watch-mode","developer-experience","filesystem","8Vcs7TX3Z2wGjUuO5LDbsq32WGr798rCbe0bXGvJy08",[2605,2608,2611,2614,2617,2620,2623,2626,2629,2632,2635,2638,2641,2644,2647,2650,2653,2656,2659,2662,2665,2668,2671,2674,2677,2680,2683,2686,2689,2692,2695,2698,2701,2704,2707,2710,2713,2716,2719,2722,2725,2728,2731,2734,2737,2740,2743,2746,2749,2752,2755,2758,2761,2764,2767,2770,2773,2776,2779,2782,2785,2788,2791,2794,2797,2800,2803,2806,2809,2812,2815,2818,2821,2824,2827,2828,2831,2834,2837,2840,2843,2846,2849,2852,2855,2858,2861,2864,2867,2870,2873,2876,2878,2881,2884,2887,2890,2893,2896,2899,2902,2905,2908,2911,2914,2917,2920,2923,2926,2929,2932,2935,2938,2941,2944,2947,2950,2953,2956,2959,2962,2965,2968,2971,2974,2977,2980,2983,2986,2989,2992,2995,2998,3001,3004,3007,3010,3013,3016,3019,3022,3025,3028,3031,3034,3037,3040,3043,3046,3049,3052,3055,3058,3061,3064,3067,3070,3073,3076,3079,3082,3085,3088,3091,3094,3097,3100,3103,3106,3109,3112,3115,3118,3121,3124,3127,3130,3133,3136,3139,3142,3145,3148],{"path":2606,"title":2607},"\u002Fabout","About Python CLI Toolcraft",{"path":2609,"title":2610},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies","Advanced Argument Validation Strategies",{"path":2612,"title":2613},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies\u002Fparsing-nested-json-arguments-in-python-clis","Parsing Nested JSON Args in Python CLIs",{"path":2615,"title":2616},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies\u002Fvalidating-dependent-and-conflicting-options","Validating Dependent and Conflicting CLI Options",{"path":2618,"title":2619},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies\u002Fvalidating-file-and-directory-paths-in-clis","Validating File and Directory Paths in CLIs",{"path":2621,"title":2622},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies\u002Fwriting-custom-click-parameter-types","Writing Custom Click Parameter Types",{"path":2624,"title":2625},"\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":2627,"title":2628},"\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":2630,"title":2631},"\u002Fadvanced-input-parsing-user-experience\u002Fbuilding-terminal-uis-with-textual","Building Terminal UIs with Textual for Python CLIs",{"path":2633,"title":2634},"\u002Fadvanced-input-parsing-user-experience\u002Fbuilding-terminal-uis-with-textual\u002Ftesting-textual-apps-with-pilot","Testing Textual Apps with Pilot",{"path":2636,"title":2637},"\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":2639,"title":2640},"\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":2642,"title":2643},"\u002Fadvanced-input-parsing-user-experience\u002Fcli-help-output-and-documentation","CLI Help Output and Documentation",{"path":2645,"title":2646},"\u002Fadvanced-input-parsing-user-experience\u002Fcli-help-output-and-documentation\u002Fversioning-and-deprecating-cli-flags","Versioning and Deprecating CLI Flags",{"path":2648,"title":2649},"\u002Fadvanced-input-parsing-user-experience\u002Fcli-help-output-and-documentation\u002Fwriting-help-text-users-actually-read","Writing Help Text Users Actually Read",{"path":2651,"title":2652},"\u002Fadvanced-input-parsing-user-experience\u002Fcross-platform-terminal-compatibility\u002Fadapting-output-to-terminal-width","Adapting Python CLI Output to Terminal Width",{"path":2654,"title":2655},"\u002Fadvanced-input-parsing-user-experience\u002Fcross-platform-terminal-compatibility\u002Fdetecting-ci-environments-and-non-interactive-shells","Detecting CI Environments and Non-Interactive Shells",{"path":2657,"title":2658},"\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":2660,"title":2661},"\u002Fadvanced-input-parsing-user-experience\u002Fcross-platform-terminal-compatibility","Cross-Platform Terminal Compatibility for Python CLIs",{"path":2663,"title":2664},"\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":2666,"title":2667},"\u002Fadvanced-input-parsing-user-experience\u002Ferror-handling-and-exit-codes\u002Fchoosing-exit-codes-for-cli-tools","Choosing Exit Codes for CLI Tools",{"path":2669,"title":2670},"\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":2672,"title":2673},"\u002Fadvanced-input-parsing-user-experience\u002Ferror-handling-and-exit-codes\u002Ffriendly-error-messages-and-tracebacks","Friendly Error Messages and Tracebacks",{"path":2675,"title":2676},"\u002Fadvanced-input-parsing-user-experience\u002Ferror-handling-and-exit-codes\u002Fhandling-keyboard-interrupt-cleanly","Handling Keyboard Interrupt Cleanly",{"path":2678,"title":2679},"\u002Fadvanced-input-parsing-user-experience\u002Ferror-handling-and-exit-codes","Error Handling and Exit Codes for CLIs",{"path":2681,"title":2682},"\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":2684,"title":2685},"\u002Fadvanced-input-parsing-user-experience\u002Fhandling-configuration-files-env-vars\u002Fconfig-precedence-flags-env-files-defaults","Config Precedence: Flags, Env, Files, Defaults",{"path":2687,"title":2688},"\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":2690,"title":2691},"\u002Fadvanced-input-parsing-user-experience\u002Fhandling-configuration-files-env-vars","Handling Config Files and Env Vars in CLIs",{"path":2693,"title":2694},"\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":2696,"title":2697},"\u002Fadvanced-input-parsing-user-experience\u002Fhandling-configuration-files-env-vars\u002Freading-toml-config-with-tomllib","Reading TOML Config with tomllib in Python CLIs",{"path":2699,"title":2700},"\u002Fadvanced-input-parsing-user-experience\u002Fhandling-configuration-files-env-vars\u002Ftyped-settings-with-pydantic-settings","Typed Settings with pydantic-settings in Python CLIs",{"path":2702,"title":2703},"\u002Fadvanced-input-parsing-user-experience","Advanced Input Parsing for Python CLIs",{"path":2705,"title":2706},"\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":2708,"title":2709},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich\u002Fbuilding-interactive-prompts-and-menus","Building Interactive Prompts and Menus in Python CLIs",{"path":2711,"title":2712},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich","Interactive Terminal UI with Rich",{"path":2714,"title":2715},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich\u002Flive-dashboards-with-rich-live","Live Dashboards with Rich Live in Python CLIs",{"path":2717,"title":2718},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich\u002Frendering-tables-and-json-with-rich","Rendering Tables and JSON with Rich",{"path":2720,"title":2721},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich\u002Ftheming-rich-output-consistently","Theming Rich Output Consistently in Python CLIs",{"path":2723,"title":2724},"\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":2726,"title":2727},"\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":2729,"title":2730},"\u002Fadvanced-input-parsing-user-experience\u002Fshell-completion-for-python-clis","Shell Completion for Python CLIs",{"path":2732,"title":2733},"\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":2735,"title":2736},"\u002Fadvanced-input-parsing-user-experience\u002Fshell-completion-for-python-clis\u002Ftesting-shell-completion-in-python-clis","Testing Shell Completion in Python CLIs",{"path":2738,"title":2739},"\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":2741,"title":2742},"\u002Fadvanced-input-parsing-user-experience\u002Fstructured-logging-for-cli-apps\u002Fadding-verbose-and-quiet-logging-flags","Adding Verbose and Quiet Logging Flags",{"path":2744,"title":2745},"\u002Fadvanced-input-parsing-user-experience\u002Fstructured-logging-for-cli-apps","Structured Logging for CLI Apps",{"path":2747,"title":2748},"\u002Fadvanced-input-parsing-user-experience\u002Fstructured-logging-for-cli-apps\u002Fstructured-json-logging-in-python-clis","Structured JSON Logging in Python CLIs",{"path":2750,"title":2751},"\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":2753,"title":2754},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes\u002Fdetecting-tty-and-adapting-output","Detecting a TTY and Adapting Output",{"path":2756,"title":2757},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes\u002Femitting-json-output-for-scripting","Emitting JSON Output for Scripting",{"path":2759,"title":2760},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes\u002Fhandling-broken-pipe-and-sigpipe","Handling Broken Pipe and SIGPIPE",{"path":2762,"title":2763},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes","Working with stdin, stdout and Pipes",{"path":2765,"title":2766},"\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":2768,"title":2769},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes\u002Freading-piped-input-in-python-clis","Reading Piped Input in Python CLIs",{"path":2771,"title":2772},"\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":2774,"title":2775},"\u002Fcli-runtime-systems-integration\u002Fcalling-http-apis-from-python-clis\u002Fdownloading-files-with-progress-in-python","Downloading Files with Progress in Python CLIs",{"path":2777,"title":2778},"\u002Fcli-runtime-systems-integration\u002Fcalling-http-apis-from-python-clis","Calling HTTP APIs from Python CLIs",{"path":2780,"title":2781},"\u002Fcli-runtime-systems-integration\u002Fcalling-http-apis-from-python-clis\u002Foauth-device-flow-login-for-clis","OAuth Device Flow Login for Python CLIs",{"path":2783,"title":2784},"\u002Fcli-runtime-systems-integration\u002Fcalling-http-apis-from-python-clis\u002Fpaginating-api-results-in-a-cli","Paginating API Results in a Python CLI",{"path":2786,"title":2787},"\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":2789,"title":2790},"\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":2792,"title":2793},"\u002Fcli-runtime-systems-integration\u002Fconcurrency-and-async-in-python-clis","Concurrency and Async in Python CLIs",{"path":2795,"title":2796},"\u002Fcli-runtime-systems-integration\u002Fconcurrency-and-async-in-python-clis\u002Fmultiprocessing-for-cpu-bound-cli-tasks","Multiprocessing for CPU-Bound CLI Tasks",{"path":2798,"title":2799},"\u002Fcli-runtime-systems-integration\u002Fconcurrency-and-async-in-python-clis\u002Fparallelising-cli-work-with-thread-pools","Parallelising CLI Work with Thread Pools",{"path":2801,"title":2802},"\u002Fcli-runtime-systems-integration\u002Fconcurrency-and-async-in-python-clis\u002Frate-limiting-concurrent-requests-in-clis","Rate-Limiting Concurrent Requests in Python CLIs",{"path":2804,"title":2805},"\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":2807,"title":2808},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes\u002Fcross-platform-paths-with-pathlib","Cross-Platform Paths with pathlib in CLIs",{"path":2810,"title":2811},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes\u002Ffile-locking-for-concurrent-cli-runs","File Locking for Concurrent CLI Runs in Python",{"path":2813,"title":2814},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes","Filesystem Paths and Atomic Writes for CLIs",{"path":2816,"title":2817},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes\u002Fsafe-temporary-files-and-directories","Safe Temporary Files and Directories in CLIs",{"path":2819,"title":2820},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes\u002Fstoring-app-data-with-platformdirs","Storing CLI App Data with platformdirs",{"path":2822,"title":2823},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes\u002Fwriting-files-atomically-in-python-clis","Writing Files Atomically in Python CLIs",{"path":2825,"title":2826},"\u002Fcli-runtime-systems-integration","CLI Runtime & Systems Integration for Python",{"path":2596,"title":5},{"path":2829,"title":2830},"\u002Fcli-runtime-systems-integration\u002Flong-running-and-watch-mode-clis\u002Fhandling-sigterm-and-graceful-shutdown","Handling SIGTERM and Graceful Shutdown in CLIs",{"path":2832,"title":2833},"\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":2835,"title":2836},"\u002Fcli-runtime-systems-integration\u002Flong-running-and-watch-mode-clis","Long-Running and Watch-Mode Python CLIs",{"path":2838,"title":2839},"\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":2841,"title":2842},"\u002Fcli-runtime-systems-integration\u002Frunning-subprocesses-from-python-clis\u002Favoiding-shell-injection-in-python-clis","Avoiding Shell Injection in Python CLIs",{"path":2844,"title":2845},"\u002Fcli-runtime-systems-integration\u002Frunning-subprocesses-from-python-clis\u002Fcalling-external-commands-safely-with-subprocess","Calling External Commands Safely with subprocess",{"path":2847,"title":2848},"\u002Fcli-runtime-systems-integration\u002Frunning-subprocesses-from-python-clis\u002Fhandling-subprocess-timeouts-and-exit-codes","Handling Subprocess Timeouts and Exit Codes",{"path":2850,"title":2851},"\u002Fcli-runtime-systems-integration\u002Frunning-subprocesses-from-python-clis","Running Subprocesses from Python CLIs",{"path":2853,"title":2854},"\u002Fcli-runtime-systems-integration\u002Frunning-subprocesses-from-python-clis\u002Fstreaming-subprocess-output-in-real-time","Streaming Subprocess Output in Real Time",{"path":2856,"title":2857},"\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":2859,"title":2860},"\u002Fcli-runtime-systems-integration\u002Fsecrets-and-credentials-in-python-clis","Secrets and Credentials in Python CLIs",{"path":2862,"title":2863},"\u002Fcli-runtime-systems-integration\u002Fsecrets-and-credentials-in-python-clis\u002Fprompting-for-passwords-securely","Prompting for Passwords Securely in Python CLIs",{"path":2865,"title":2866},"\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":2868,"title":2869},"\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":2871,"title":2872},"\u002Fcli-runtime-systems-integration\u002Fsecrets-and-credentials-in-python-clis\u002Fstoring-tokens-with-keyring","Storing CLI Tokens Securely with keyring",{"path":2874,"title":2875},"\u002Fcli-runtime-systems-integration\u002Fsecrets-and-credentials-in-python-clis\u002Fsupporting-multiple-profiles-and-accounts","Supporting Multiple Profiles and Accounts in CLIs",{"path":1257,"title":2877},"Python CLI Toolcraft",{"path":2879,"title":2880},"\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":2882,"title":2883},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcli-startup-performance-and-lazy-loading","CLI Startup Performance and Lazy Loading",{"path":2885,"title":2886},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcli-startup-performance-and-lazy-loading\u002Flazy-loading-subcommands-for-faster-startup","Lazy Loading Subcommands for Faster Startup",{"path":2888,"title":2889},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcli-startup-performance-and-lazy-loading\u002Fprofiling-python-cli-startup-time","Profiling Python CLI Startup Time",{"path":2891,"title":2892},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcli-startup-performance-and-lazy-loading\u002Freducing-cli-dependency-weight","Reducing CLI Dependency Weight",{"path":2894,"title":2895},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse\u002Fargparse-subparsers-for-subcommands","argparse Subparsers for Subcommands",{"path":2897,"title":2898},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse\u002Fargparse-vs-click-vs-typer-comparison","argparse vs Click vs Typer Compared",{"path":2900,"title":2901},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse","Command-Line Parsing with argparse",{"path":2903,"title":2904},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse\u002Fmigrating-from-argparse-to-typer","Migrating from argparse to Typer",{"path":2906,"title":2907},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse\u002Fmutually-exclusive-options-in-argparse","Mutually Exclusive Options in argparse",{"path":2909,"title":2910},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse\u002Fwriting-custom-argparse-actions","Writing Custom argparse Actions in Python",{"path":2912,"title":2913},"\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":2915,"title":2916},"\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":2918,"title":2919},"\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":2921,"title":2922},"\u002Fmodern-python-cli-frameworks-architecture\u002Fdesigning-cli-interfaces-and-conventions","Designing CLI Interfaces and Conventions in Python",{"path":2924,"title":2925},"\u002Fmodern-python-cli-frameworks-architecture\u002Fdesigning-cli-interfaces-and-conventions\u002Fnaming-commands-and-flags-consistently","Naming Commands and Flags Consistently in Python CLIs",{"path":2927,"title":2928},"\u002Fmodern-python-cli-frameworks-architecture","Python CLI Frameworks and Architecture",{"path":2930,"title":2931},"\u002Fmodern-python-cli-frameworks-architecture\u002Fplugin-architectures-for-extensible-clis\u002Fdiscovering-plugins-with-entry-points","Discovering Plugins with Entry Points in Python CLIs",{"path":2933,"title":2934},"\u002Fmodern-python-cli-frameworks-architecture\u002Fplugin-architectures-for-extensible-clis\u002Fhook-based-plugins-with-pluggy","Hook-Based Plugins for Python CLIs with pluggy",{"path":2936,"title":2937},"\u002Fmodern-python-cli-frameworks-architecture\u002Fplugin-architectures-for-extensible-clis","Plugin Architectures for Extensible CLIs",{"path":2939,"title":2940},"\u002Fmodern-python-cli-frameworks-architecture\u002Fplugin-architectures-for-extensible-clis\u002Fversioning-a-plugin-api","Versioning a Plugin API for a Python CLI",{"path":2942,"title":2943},"\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":2945,"title":2946},"\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":2948,"title":2949},"\u002Fmodern-python-cli-frameworks-architecture\u002Fstructuring-multi-command-python-clis\u002Fdependency-injection-patterns-for-cli-commands","Dependency Injection Patterns for CLI Commands",{"path":2951,"title":2952},"\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":2954,"title":2955},"\u002Fmodern-python-cli-frameworks-architecture\u002Fstructuring-multi-command-python-clis","Structuring Multi-Command Python CLIs",{"path":2957,"title":2958},"\u002Fmodern-python-cli-frameworks-architecture\u002Fstructuring-multi-command-python-clis\u002Fsharing-common-options-across-commands","Sharing Common Options Across Python CLI Commands",{"path":2960,"title":2961},"\u002Fmodern-python-cli-frameworks-architecture\u002Fstructuring-multi-command-python-clis\u002Fsharing-state-with-click-context-objects","Sharing State with Click Context Objects",{"path":2963,"title":2964},"\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":2966,"title":2967},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications","Testing Python CLI Applications",{"path":2969,"title":2970},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Fmeasuring-cli-test-coverage","Measuring CLI Test Coverage",{"path":2972,"title":2973},"\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":2975,"title":2976},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Fproperty-based-testing-cli-arguments-with-hypothesis","Property-Based Testing CLI Arguments with Hypothesis",{"path":2978,"title":2979},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Fsnapshot-testing-cli-output","Snapshot Testing CLI Output",{"path":2981,"title":2982},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Ftesting-click-commands-with-clirunner","Testing Click Commands with CliRunner",{"path":2984,"title":2985},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Ftesting-interactive-prompts-and-stdin","Testing Interactive Prompts and stdin",{"path":2987,"title":2988},"\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":2990,"title":2991},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftyper-vs-click-when-to-use-each\u002Fbuilding-dynamic-commands-in-click","Building Dynamic Commands in Click",{"path":2993,"title":2994},"\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":2996,"title":2997},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftyper-vs-click-when-to-use-each","Typer vs Click: When to Use Each",{"path":2999,"title":3000},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftyper-vs-click-when-to-use-each\u002Ftyper-callback-functions-explained","Typer callback functions explained",{"path":3002,"title":3003},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftyper-vs-click-when-to-use-each\u002Fusing-annotated-options-in-typer","Using Annotated Options in Typer",{"path":3005,"title":3006},"\u002Fproject-setup-dependency-management\u002Fci-cd-pipelines-for-python-clis\u002Fautomating-releases-from-git-tags","Automating Python CLI Releases from Git Tags",{"path":3008,"title":3009},"\u002Fproject-setup-dependency-management\u002Fci-cd-pipelines-for-python-clis\u002Fcaching-uv-dependencies-in-ci","Caching uv Dependencies in CI for Python CLIs",{"path":3011,"title":3012},"\u002Fproject-setup-dependency-management\u002Fci-cd-pipelines-for-python-clis","CI\u002FCD Pipelines for Python CLIs",{"path":3014,"title":3015},"\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":3017,"title":3018},"\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":3020,"title":3021},"\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":3023,"title":3024},"\u002Fproject-setup-dependency-management\u002Fcli-project-scaffolding-with-cookiecutter\u002Fbuilding-a-cookiecutter-template-for-typer-clis","Building a Cookiecutter Template for Typer CLIs",{"path":3026,"title":3027},"\u002Fproject-setup-dependency-management\u002Fcli-project-scaffolding-with-cookiecutter\u002Fcopier-vs-cookiecutter-for-cli-templates","Copier vs Cookiecutter for CLI Templates",{"path":3029,"title":3030},"\u002Fproject-setup-dependency-management\u002Fcli-project-scaffolding-with-cookiecutter","CLI Project Scaffolding with Cookiecutter",{"path":3032,"title":3033},"\u002Fproject-setup-dependency-management\u002Fcli-project-scaffolding-with-cookiecutter\u002Fpost-generation-hooks-in-cli-templates","Post-Generation Hooks in Python CLI Templates",{"path":3035,"title":3036},"\u002Fproject-setup-dependency-management\u002Fdistributing-clis-as-standalone-binaries\u002Fbuilding-cross-platform-release-binaries-in-ci","Building Cross-Platform Release Binaries in CI",{"path":3038,"title":3039},"\u002Fproject-setup-dependency-management\u002Fdistributing-clis-as-standalone-binaries\u002Fbundling-a-python-cli-with-pyinstaller","Bundling a Python CLI with PyInstaller",{"path":3041,"title":3042},"\u002Fproject-setup-dependency-management\u002Fdistributing-clis-as-standalone-binaries\u002Fhomebrew-and-scoop-packaging-for-python-clis","Homebrew and Scoop Packaging for Python CLIs",{"path":3044,"title":3045},"\u002Fproject-setup-dependency-management\u002Fdistributing-clis-as-standalone-binaries","Distributing CLIs as Standalone Binaries",{"path":3047,"title":3048},"\u002Fproject-setup-dependency-management\u002Fdistributing-clis-as-standalone-binaries\u002Fnuitka-vs-pyinstaller-for-python-clis","Nuitka vs PyInstaller for Python CLI Binaries",{"path":3050,"title":3051},"\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":3053,"title":3054},"\u002Fproject-setup-dependency-management","Project Setup & Dependency Management",{"path":3056,"title":3057},"\u002Fproject-setup-dependency-management\u002Flinting-and-type-checking-cli-code\u002Fconfiguring-ruff-for-a-cli-project","Configuring Ruff for a Python CLI Project",{"path":3059,"title":3060},"\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":3062,"title":3063},"\u002Fproject-setup-dependency-management\u002Flinting-and-type-checking-cli-code","Linting and Type-Checking Python CLI Code",{"path":3065,"title":3066},"\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":3068,"title":3069},"\u002Fproject-setup-dependency-management\u002Fmanaging-cli-versioning-changelogs\u002Fautomating-changelogs-with-conventional-commits","Automating Changelogs with Conventional Commits",{"path":3071,"title":3072},"\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":3074,"title":3075},"\u002Fproject-setup-dependency-management\u002Fmanaging-cli-versioning-changelogs\u002Fexposing-version-info-and-build-metadata","Exposing Version Info and Build Metadata",{"path":3077,"title":3078},"\u002Fproject-setup-dependency-management\u002Fmanaging-cli-versioning-changelogs","Managing CLI Versioning & Changelogs",{"path":3080,"title":3081},"\u002Fproject-setup-dependency-management\u002Fmanaging-cli-versioning-changelogs\u002Fsemantic-versioning-policy-for-cli-tools","A Semantic Versioning Policy for CLI Tools",{"path":3083,"title":3084},"\u002Fproject-setup-dependency-management\u002Fpackaging-python-clis-for-distribution\u002Fbuilding-wheels-and-sdists-for-python-clis","Building Wheels and sdists for Python CLIs",{"path":3086,"title":3087},"\u002Fproject-setup-dependency-management\u002Fpackaging-python-clis-for-distribution\u002Fbundling-data-files-with-importlib-resources","Bundling Data Files with importlib.resources in CLIs",{"path":3089,"title":3090},"\u002Fproject-setup-dependency-management\u002Fpackaging-python-clis-for-distribution","Packaging Python CLIs for Distribution",{"path":3092,"title":3093},"\u002Fproject-setup-dependency-management\u002Fpackaging-python-clis-for-distribution\u002Finstalling-and-distributing-clis-with-pipx","Installing and Distributing CLIs with pipx",{"path":3095,"title":3096},"\u002Fproject-setup-dependency-management\u002Fpackaging-python-clis-for-distribution\u002Fpublishing-a-python-cli-to-pypi","Publishing a Python CLI to PyPI",{"path":3098,"title":3099},"\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":3101,"title":3102},"\u002Fproject-setup-dependency-management\u002Fpoetry-workflows-for-cli-development","Poetry Workflows for CLI Development",{"path":3104,"title":3105},"\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":3107,"title":3108},"\u002Fproject-setup-dependency-management\u002Fpoetry-workflows-for-cli-development\u002Fpoetry-dependency-groups-for-cli-tooling","Poetry Dependency Groups for CLI Tooling",{"path":3110,"title":3111},"\u002Fproject-setup-dependency-management\u002Fpoetry-workflows-for-cli-development\u002Fpoetry-entry-points-and-scripts-for-clis","Poetry Entry Points and Scripts for CLIs",{"path":3113,"title":3114},"\u002Fproject-setup-dependency-management\u002Fpre-commit-hooks-for-cli-projects","Pre-commit Hooks for CLI Projects",{"path":3116,"title":3117},"\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":3119,"title":3120},"\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":3122,"title":3123},"\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":3125,"title":3126},"\u002Fproject-setup-dependency-management\u002Fuv-for-python-cli-dependency-management","uv for Python CLI Dependency Management",{"path":3128,"title":3129},"\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":3131,"title":3132},"\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":3134,"title":3135},"\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":3137,"title":3138},"\u002Fproject-setup-dependency-management\u002Fuv-for-python-cli-dependency-management\u002Fuv-workspaces-for-multi-package-clis","uv Workspaces for Multi-Package Python CLIs",{"path":3140,"title":3141},"\u002Fproject-setup-dependency-management\u002Fvirtual-environments-isolation-best-practices","Python CLI Env Isolation Best Practices",{"path":3143,"title":3144},"\u002Fproject-setup-dependency-management\u002Fvirtual-environments-isolation-best-practices\u002Fmanaging-virtual-environments-for-cross-platform-clis","Managing Python CLI Virtual Environments",{"path":3146,"title":3147},"\u002Fproject-setup-dependency-management\u002Fvirtual-environments-isolation-best-practices\u002Fpinning-the-python-version-for-a-cli","Pinning the Python Version for a CLI",{"path":3149,"title":3150},"\u002Fproject-setup-dependency-management\u002Fvirtual-environments-isolation-best-practices\u002Fsupporting-multiple-python-versions-with-nox","Supporting Multiple Python Versions with nox",1789736905049]