[{"data":1,"prerenderedAt":1494},["ShallowReactive",2],{"page-\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies\u002Fvalidating-file-and-directory-paths-in-clis\u002F":3,"content-directory":1248},{"id":4,"title":5,"body":6,"date":1233,"description":1234,"difficulty":1235,"draft":1236,"extension":1237,"meta":1238,"navigation":476,"path":1239,"seo":1240,"stem":1241,"tags":1242,"updated":1233,"__hash__":1247},"content\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies\u002Fvalidating-file-and-directory-paths-in-clis\u002Findex.md","Validating File and Directory Paths in CLIs",{"type":7,"value":8,"toc":1210},"minimark",[9,13,18,80,84,99,103,107,282,285,291,298,348,359,363,370,530,545,548,552,555,558,626,642,645,649,652,658,687,694,697,703,713,717,727,742,748,761,765,772,1055,1058,1062,1065,1069,1081,1089,1093,1096,1100,1106,1110,1117,1124,1139,1143,1158,1162,1167,1171,1206],[10,11,12],"p",{},"Paths account for more command-line validation than everything else combined, and both frameworks\nhave enough built in that you should rarely write the checks by hand. What is left over is the\ninteresting part: paths that do not exist yet, paths that must stay inside a root, and errors that\ntell the user which path the tool actually looked at.",[14,15,17],"h2",{"id":16},"tldr","TL;DR",[19,20,21,47,60,70,77],"ul",{},[22,23,24,25,29,30,29,33,29,36,29,39,42,43,46],"li",{},"Use the built-in checks: ",[26,27,28],"code",{},"exists",", ",[26,31,32],{},"file_okay",[26,34,35],{},"dir_okay",[26,37,38],{},"readable",[26,40,41],{},"writable",",\n",[26,44,45],{},"resolve_path",".",[22,48,49,50,54,55,59],{},"For a path you will ",[51,52,53],"em",{},"create",", check the ",[56,57,58],"strong",{},"parent",", not the path.",[22,61,62,65,66,69],{},[26,63,64],{},"resolve()"," then ",[26,67,68],{},"is_relative_to(root)"," is the whole containment check — string prefixes are not.",[22,71,72,73,76],{},"Always print the ",[56,74,75],{},"resolved absolute path"," in errors; it ends the \"but it is right there\"\nconversation.",[22,78,79],{},"Use a distinct exit code for a missing input file (66 is conventional).",[14,81,83],{"id":82},"prerequisites","Prerequisites",[10,85,86,87,90,91,94,95,98],{},"A Typer or Click application, and ",[26,88,89],{},"pathlib",". Everything here works the same in ",[26,92,93],{},"argparse"," with a\n",[26,96,97],{},"type="," callable.",[14,100,102],{"id":101},"what-the-framework-already-checks","What the framework already checks",[104,105],"inline-diagram",{"name":106},"path-check-matrix",[108,109,114],"pre",{"className":110,"code":111,"language":112,"meta":113,"style":113},"language-python shiki shiki-themes github-light github-dark","@app.command()\ndef convert(\n    source: Annotated[Path, typer.Argument(\n        exists=True, dir_okay=False, readable=True,\n        help=\"File to convert.\",\n    )],\n    out_dir: Annotated[Path, typer.Option(\n        file_okay=False, writable=True, resolve_path=True,\n        help=\"Directory to write results into.\",\n    )] = Path(\".\"),\n) -> None:\n    ...\n","python","",[26,115,116,129,142,148,181,195,201,207,235,247,264,276],{"__ignoreMap":113},[117,118,121,125],"span",{"class":119,"line":120},"line",1,[117,122,124],{"class":123},"sScJk","@app.command",[117,126,128],{"class":127},"sVt8B","()\n",[117,130,132,136,139],{"class":119,"line":131},2,[117,133,135],{"class":134},"szBVR","def",[117,137,138],{"class":123}," convert",[117,140,141],{"class":127},"(\n",[117,143,145],{"class":119,"line":144},3,[117,146,147],{"class":127},"    source: Annotated[Path, typer.Argument(\n",[117,149,151,155,158,162,164,166,168,171,173,175,177,179],{"class":119,"line":150},4,[117,152,154],{"class":153},"s4XuR","        exists",[117,156,157],{"class":134},"=",[117,159,161],{"class":160},"sj4cs","True",[117,163,29],{"class":127},[117,165,35],{"class":153},[117,167,157],{"class":134},[117,169,170],{"class":160},"False",[117,172,29],{"class":127},[117,174,38],{"class":153},[117,176,157],{"class":134},[117,178,161],{"class":160},[117,180,42],{"class":127},[117,182,184,187,189,193],{"class":119,"line":183},5,[117,185,186],{"class":153},"        help",[117,188,157],{"class":134},[117,190,192],{"class":191},"sZZnC","\"File to convert.\"",[117,194,42],{"class":127},[117,196,198],{"class":119,"line":197},6,[117,199,200],{"class":127},"    )],\n",[117,202,204],{"class":119,"line":203},7,[117,205,206],{"class":127},"    out_dir: Annotated[Path, typer.Option(\n",[117,208,210,213,215,217,219,221,223,225,227,229,231,233],{"class":119,"line":209},8,[117,211,212],{"class":153},"        file_okay",[117,214,157],{"class":134},[117,216,170],{"class":160},[117,218,29],{"class":127},[117,220,41],{"class":153},[117,222,157],{"class":134},[117,224,161],{"class":160},[117,226,29],{"class":127},[117,228,45],{"class":153},[117,230,157],{"class":134},[117,232,161],{"class":160},[117,234,42],{"class":127},[117,236,238,240,242,245],{"class":119,"line":237},9,[117,239,186],{"class":153},[117,241,157],{"class":134},[117,243,244],{"class":191},"\"Directory to write results into.\"",[117,246,42],{"class":127},[117,248,250,253,255,258,261],{"class":119,"line":249},10,[117,251,252],{"class":127},"    )] ",[117,254,157],{"class":134},[117,256,257],{"class":127}," Path(",[117,259,260],{"class":191},"\".\"",[117,262,263],{"class":127},"),\n",[117,265,267,270,273],{"class":119,"line":266},11,[117,268,269],{"class":127},") -> ",[117,271,272],{"class":160},"None",[117,274,275],{"class":127},":\n",[117,277,279],{"class":119,"line":278},12,[117,280,281],{"class":160},"    ...\n",[10,283,284],{},"Five keywords, and the command body contains no path checks at all. A missing file, a directory\nwhere a file was expected, or a permission problem all produce a usage error naming the option and\nexit code 2 before your code runs.",[10,286,287,290],{},[26,288,289],{},"resolve_path=True"," is the one people miss. It expands the value to an absolute path, which matters\nwhenever you store it, log it, or compare it — a relative path recorded in a config file means\nsomething different the next time the tool runs from a different directory.",[10,292,293,294,297],{},"The Click spelling is the same set of arguments on ",[26,295,296],{},"click.Path",":",[108,299,301],{"className":110,"code":300,"language":112,"meta":113,"style":113},"@click.option(\"--out-dir\", type=click.Path(file_okay=False, writable=True, path_type=Path))\n",[26,302,303],{"__ignoreMap":113},[117,304,305,308,311,314,316,319,321,324,326,328,330,332,334,336,338,340,343,345],{"class":119,"line":120},[117,306,307],{"class":123},"@click.option",[117,309,310],{"class":127},"(",[117,312,313],{"class":191},"\"--out-dir\"",[117,315,29],{"class":127},[117,317,318],{"class":153},"type",[117,320,157],{"class":134},[117,322,323],{"class":127},"click.Path(",[117,325,32],{"class":153},[117,327,157],{"class":134},[117,329,170],{"class":160},[117,331,29],{"class":127},[117,333,41],{"class":153},[117,335,157],{"class":134},[117,337,161],{"class":160},[117,339,29],{"class":127},[117,341,342],{"class":153},"path_type",[117,344,157],{"class":134},[117,346,347],{"class":127},"Path))\n",[10,349,350,351,354,355,358],{},"Note ",[26,352,353],{},"path_type=Path",": without it Click hands you a ",[26,356,357],{},"str",", and you end up converting at every call\nsite.",[14,360,362],{"id":361},"paths-that-do-not-exist-yet","Paths that do not exist yet",[10,364,365,366,369],{},"The gap in the built-ins is an ",[51,367,368],{},"output"," path, where the file should not exist and the directory\nshould. That needs a small validator:",[108,371,373],{"className":110,"code":372,"language":112,"meta":113,"style":113},"def writable_target(path: Path) -> Path:\n    resolved = path.expanduser().resolve()\n    if resolved.exists():\n        raise typer.BadParameter(f\"{resolved} already exists (use --force to overwrite)\")\n    if not resolved.parent.is_dir():\n        raise typer.BadParameter(f\"{resolved.parent} does not exist\")\n    return resolved\n\n@app.command()\ndef export(\n    output: Annotated[Path, typer.Option(parser=writable_target, help=\"Where to write the export.\")],\n) -> None:\n    ...\n",[26,374,375,385,395,403,432,442,464,472,478,484,493,517,525],{"__ignoreMap":113},[117,376,377,379,382],{"class":119,"line":120},[117,378,135],{"class":134},[117,380,381],{"class":123}," writable_target",[117,383,384],{"class":127},"(path: Path) -> Path:\n",[117,386,387,390,392],{"class":119,"line":131},[117,388,389],{"class":127},"    resolved ",[117,391,157],{"class":134},[117,393,394],{"class":127}," path.expanduser().resolve()\n",[117,396,397,400],{"class":119,"line":144},[117,398,399],{"class":134},"    if",[117,401,402],{"class":127}," resolved.exists():\n",[117,404,405,408,411,414,417,420,423,426,429],{"class":119,"line":150},[117,406,407],{"class":134},"        raise",[117,409,410],{"class":127}," typer.BadParameter(",[117,412,413],{"class":134},"f",[117,415,416],{"class":191},"\"",[117,418,419],{"class":160},"{",[117,421,422],{"class":127},"resolved",[117,424,425],{"class":160},"}",[117,427,428],{"class":191}," already exists (use --force to overwrite)\"",[117,430,431],{"class":127},")\n",[117,433,434,436,439],{"class":119,"line":183},[117,435,399],{"class":134},[117,437,438],{"class":134}," not",[117,440,441],{"class":127}," resolved.parent.is_dir():\n",[117,443,444,446,448,450,452,454,457,459,462],{"class":119,"line":197},[117,445,407],{"class":134},[117,447,410],{"class":127},[117,449,413],{"class":134},[117,451,416],{"class":191},[117,453,419],{"class":160},[117,455,456],{"class":127},"resolved.parent",[117,458,425],{"class":160},[117,460,461],{"class":191}," does not exist\"",[117,463,431],{"class":127},[117,465,466,469],{"class":119,"line":203},[117,467,468],{"class":134},"    return",[117,470,471],{"class":127}," resolved\n",[117,473,474],{"class":119,"line":209},[117,475,477],{"emptyLinePlaceholder":476},true,"\n",[117,479,480,482],{"class":119,"line":237},[117,481,124],{"class":123},[117,483,128],{"class":127},[117,485,486,488,491],{"class":119,"line":249},[117,487,135],{"class":134},[117,489,490],{"class":123}," export",[117,492,141],{"class":127},[117,494,495,498,501,503,506,509,511,514],{"class":119,"line":266},[117,496,497],{"class":127},"    output: Annotated[Path, typer.Option(",[117,499,500],{"class":153},"parser",[117,502,157],{"class":134},[117,504,505],{"class":127},"writable_target, ",[117,507,508],{"class":153},"help",[117,510,157],{"class":134},[117,512,513],{"class":191},"\"Where to write the export.\"",[117,515,516],{"class":127},")],\n",[117,518,519,521,523],{"class":119,"line":278},[117,520,269],{"class":127},[117,522,272],{"class":160},[117,524,275],{"class":127},[117,526,528],{"class":119,"line":527},13,[117,529,281],{"class":160},[10,531,532,533,536,537,540,541,544],{},"Two details make it useful. ",[26,534,535],{},"expanduser()"," handles ",[26,538,539],{},"~\u002Fexports\u002Fdata.json",", which the shell expands\nonly when unquoted — a quoted path arrives with the tilde intact and fails confusingly without it.\nAnd the message names ",[26,542,543],{},"--force",", so the user learns the fix rather than the rule.",[10,546,547],{},"There is a theoretical race here — the file could appear between the check and the write — and for a\nCLI that is acceptable. What matters is catching the common mistake before twenty minutes of\nprocessing, not guaranteeing atomicity.",[14,549,551],{"id":550},"refusing-a-path-that-escapes-its-root","Refusing a path that escapes its root",[104,553],{"name":554},"path-safety-flow",[10,556,557],{},"When a path comes from a config file, an archive entry, or a remote payload, it may be trying to\nleave the directory you intended:",[108,559,561],{"className":110,"code":560,"language":112,"meta":113,"style":113},"def inside(root: Path, candidate: Path) -> Path:\n    resolved = (root \u002F candidate).resolve()\n    if not resolved.is_relative_to(root.resolve()):\n        raise InputDataError(f\"{candidate} escapes the output directory\")\n    return resolved\n",[26,562,563,573,588,597,620],{"__ignoreMap":113},[117,564,565,567,570],{"class":119,"line":120},[117,566,135],{"class":134},[117,568,569],{"class":123}," inside",[117,571,572],{"class":127},"(root: Path, candidate: Path) -> Path:\n",[117,574,575,577,579,582,585],{"class":119,"line":131},[117,576,389],{"class":127},[117,578,157],{"class":134},[117,580,581],{"class":127}," (root ",[117,583,584],{"class":134},"\u002F",[117,586,587],{"class":127}," candidate).resolve()\n",[117,589,590,592,594],{"class":119,"line":144},[117,591,399],{"class":134},[117,593,438],{"class":134},[117,595,596],{"class":127}," resolved.is_relative_to(root.resolve()):\n",[117,598,599,601,604,606,608,610,613,615,618],{"class":119,"line":150},[117,600,407],{"class":134},[117,602,603],{"class":127}," InputDataError(",[117,605,413],{"class":134},[117,607,416],{"class":191},[117,609,419],{"class":160},[117,611,612],{"class":127},"candidate",[117,614,425],{"class":160},[117,616,617],{"class":191}," escapes the output directory\"",[117,619,431],{"class":127},[117,621,622,624],{"class":119,"line":183},[117,623,468],{"class":134},[117,625,471],{"class":127},[10,627,628,630,631,634,635,638,639,46],{},[26,629,64],{}," before comparing is the entire check: it normalises ",[26,632,633],{},".."," segments and follows symlinks,\nwhich is what a string prefix test misses. ",[26,636,637],{},"Path.is_relative_to"," has been available since Python\n3.9 and is clearer than comparing ",[26,640,641],{},"parts",[10,643,644],{},"This matters most when extracting archives or writing files whose names came from data — the classic\npath traversal shape. If your tool never handles untrusted paths, you do not need it; if it does,\nthis is the check.",[14,646,648],{"id":647},"errors-people-can-act-on","Errors people can act on",[104,650],{"name":651},"path-error-checklist",[10,653,654,655,657],{},"The single most useful habit is printing the ",[56,656,422],{}," path rather than what the user typed:",[108,659,661],{"className":110,"code":660,"language":112,"meta":113,"style":113},"raise InputDataError(f\"cannot read {path.resolve()}: no such file\")\n",[26,662,663],{"__ignoreMap":113},[117,664,665,668,670,672,675,677,680,682,685],{"class":119,"line":120},[117,666,667],{"class":134},"raise",[117,669,603],{"class":127},[117,671,413],{"class":134},[117,673,674],{"class":191},"\"cannot read ",[117,676,419],{"class":160},[117,678,679],{"class":127},"path.resolve()",[117,681,425],{"class":160},[117,683,684],{"class":191},": no such file\"",[117,686,431],{"class":127},[10,688,689,690,693],{},"A user who typed ",[26,691,692],{},".\u002Fdata\u002Fjobs.json"," from the wrong directory sees an absolute path that is obviously\nnot where they thought, and the conversation ends there. Printing back what they typed tells them\nnothing they did not already believe.",[10,695,696],{},"Two more:",[10,698,699,702],{},[56,700,701],{},"Say which check failed."," \"not a file\" and \"not readable\" and \"does not exist\" are three different\nfixes. A generic \"invalid path\" makes the user try all three.",[10,704,705,708,709,712],{},[56,706,707],{},"Use a distinct exit code."," 66 (",[26,710,711],{},"EX_NOINPUT",") for a missing input file lets a wrapper script tell\n\"the file is not there yet\" from \"the tool failed\", which is a genuinely useful distinction in a\npipeline.",[14,714,716],{"id":715},"ux-considerations","UX considerations",[10,718,719,722,723,726],{},[56,720,721],{},"Fail before the work, not after."," Validating an output directory at the top of a command that\nruns for twenty minutes is the difference between an immediate error and a wasted afternoon. This is\nthe argument for ",[26,724,725],{},"writable=True"," on the option rather than a check at write time.",[10,728,729,736,737,46],{},[56,730,731,732,735],{},"Accept ",[26,733,734],{},"-"," where it makes sense."," A path argument that could be stdin or stdout should honour the\ndash convention, as described in\n",[738,739,741],"a",{"href":740},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes\u002Freading-piped-input-in-python-clis\u002F","reading piped input",[10,743,744,747],{},[56,745,746],{},"Do not resolve paths you show back in progress output."," An absolute path in every progress line\nis noise; show the relative form while working and the resolved form in errors.",[10,749,750,757,758,760],{},[56,751,752,753,756],{},"Be careful with ",[26,754,755],{},"~"," in configuration."," A path read from a file is not shell-expanded, so\n",[26,759,535],{}," is your job. It is a one-line fix and a recurring bug report without it.",[14,762,764],{"id":763},"testing-the-behaviour","Testing the behaviour",[10,766,767,768,771],{},"Path validation is cheap to test with ",[26,769,770],{},"tmp_path",", and the cases worth covering are the failures:",[108,773,775],{"className":110,"code":774,"language":112,"meta":113,"style":113},"def test_missing_input_exits_66(cli, tmp_path):\n    result = cli.invoke(app, [\"convert\", str(tmp_path \u002F \"nope.txt\")])\n\n    assert result.exit_code in (2, 66)\n    assert str(tmp_path) in result.stderr        # the resolved path is shown\n\ndef test_directory_where_a_file_is_expected(cli, tmp_path):\n    assert cli.invoke(app, [\"convert\", str(tmp_path)]).exit_code == 2\n\ndef test_existing_output_needs_force(cli, tmp_path):\n    target = tmp_path \u002F \"out.json\"\n    target.write_text(\"{}\")\n\n    result = cli.invoke(app, [\"export\", \"--output\", str(target)])\n\n    assert result.exit_code == 2\n    assert \"--force\" in result.stderr            # the message names the fix\n\n@pytest.mark.parametrize(\"candidate\", [\"..\u002Fescape.txt\", \"sub\u002F..\u002F..\u002Fescape.txt\"])\ndef test_paths_escaping_the_root_are_refused(tmp_path, candidate):\n    with pytest.raises(InputDataError):\n        inside(tmp_path, Path(candidate))\n",[26,776,777,787,815,819,843,862,866,875,896,900,909,924,938,942,966,971,982,999,1004,1029,1040,1049],{"__ignoreMap":113},[117,778,779,781,784],{"class":119,"line":120},[117,780,135],{"class":134},[117,782,783],{"class":123}," test_missing_input_exits_66",[117,785,786],{"class":127},"(cli, tmp_path):\n",[117,788,789,792,794,797,800,802,804,807,809,812],{"class":119,"line":131},[117,790,791],{"class":127},"    result ",[117,793,157],{"class":134},[117,795,796],{"class":127}," cli.invoke(app, [",[117,798,799],{"class":191},"\"convert\"",[117,801,29],{"class":127},[117,803,357],{"class":160},[117,805,806],{"class":127},"(tmp_path ",[117,808,584],{"class":134},[117,810,811],{"class":191}," \"nope.txt\"",[117,813,814],{"class":127},")])\n",[117,816,817],{"class":119,"line":144},[117,818,477],{"emptyLinePlaceholder":476},[117,820,821,824,827,830,833,836,838,841],{"class":119,"line":150},[117,822,823],{"class":134},"    assert",[117,825,826],{"class":127}," result.exit_code ",[117,828,829],{"class":134},"in",[117,831,832],{"class":127}," (",[117,834,835],{"class":160},"2",[117,837,29],{"class":127},[117,839,840],{"class":160},"66",[117,842,431],{"class":127},[117,844,845,847,850,853,855,858],{"class":119,"line":183},[117,846,823],{"class":134},[117,848,849],{"class":160}," str",[117,851,852],{"class":127},"(tmp_path) ",[117,854,829],{"class":134},[117,856,857],{"class":127}," result.stderr        ",[117,859,861],{"class":860},"sJ8bj","# the resolved path is shown\n",[117,863,864],{"class":119,"line":197},[117,865,477],{"emptyLinePlaceholder":476},[117,867,868,870,873],{"class":119,"line":203},[117,869,135],{"class":134},[117,871,872],{"class":123}," test_directory_where_a_file_is_expected",[117,874,786],{"class":127},[117,876,877,879,881,883,885,887,890,893],{"class":119,"line":209},[117,878,823],{"class":134},[117,880,796],{"class":127},[117,882,799],{"class":191},[117,884,29],{"class":127},[117,886,357],{"class":160},[117,888,889],{"class":127},"(tmp_path)]).exit_code ",[117,891,892],{"class":134},"==",[117,894,895],{"class":160}," 2\n",[117,897,898],{"class":119,"line":237},[117,899,477],{"emptyLinePlaceholder":476},[117,901,902,904,907],{"class":119,"line":249},[117,903,135],{"class":134},[117,905,906],{"class":123}," test_existing_output_needs_force",[117,908,786],{"class":127},[117,910,911,914,916,919,921],{"class":119,"line":266},[117,912,913],{"class":127},"    target ",[117,915,157],{"class":134},[117,917,918],{"class":127}," tmp_path ",[117,920,584],{"class":134},[117,922,923],{"class":191}," \"out.json\"\n",[117,925,926,929,931,934,936],{"class":119,"line":278},[117,927,928],{"class":127},"    target.write_text(",[117,930,416],{"class":191},[117,932,933],{"class":160},"{}",[117,935,416],{"class":191},[117,937,431],{"class":127},[117,939,940],{"class":119,"line":527},[117,941,477],{"emptyLinePlaceholder":476},[117,943,945,947,949,951,954,956,959,961,963],{"class":119,"line":944},14,[117,946,791],{"class":127},[117,948,157],{"class":134},[117,950,796],{"class":127},[117,952,953],{"class":191},"\"export\"",[117,955,29],{"class":127},[117,957,958],{"class":191},"\"--output\"",[117,960,29],{"class":127},[117,962,357],{"class":160},[117,964,965],{"class":127},"(target)])\n",[117,967,969],{"class":119,"line":968},15,[117,970,477],{"emptyLinePlaceholder":476},[117,972,974,976,978,980],{"class":119,"line":973},16,[117,975,823],{"class":134},[117,977,826],{"class":127},[117,979,892],{"class":134},[117,981,895],{"class":160},[117,983,985,987,990,993,996],{"class":119,"line":984},17,[117,986,823],{"class":134},[117,988,989],{"class":191}," \"--force\"",[117,991,992],{"class":134}," in",[117,994,995],{"class":127}," result.stderr            ",[117,997,998],{"class":860},"# the message names the fix\n",[117,1000,1002],{"class":119,"line":1001},18,[117,1003,477],{"emptyLinePlaceholder":476},[117,1005,1007,1010,1012,1015,1018,1021,1023,1026],{"class":119,"line":1006},19,[117,1008,1009],{"class":123},"@pytest.mark.parametrize",[117,1011,310],{"class":127},[117,1013,1014],{"class":191},"\"candidate\"",[117,1016,1017],{"class":127},", [",[117,1019,1020],{"class":191},"\"..\u002Fescape.txt\"",[117,1022,29],{"class":127},[117,1024,1025],{"class":191},"\"sub\u002F..\u002F..\u002Fescape.txt\"",[117,1027,1028],{"class":127},"])\n",[117,1030,1032,1034,1037],{"class":119,"line":1031},20,[117,1033,135],{"class":134},[117,1035,1036],{"class":123}," test_paths_escaping_the_root_are_refused",[117,1038,1039],{"class":127},"(tmp_path, candidate):\n",[117,1041,1043,1046],{"class":119,"line":1042},21,[117,1044,1045],{"class":134},"    with",[117,1047,1048],{"class":127}," pytest.raises(InputDataError):\n",[117,1050,1052],{"class":119,"line":1051},22,[117,1053,1054],{"class":127},"        inside(tmp_path, Path(candidate))\n",[10,1056,1057],{},"The parametrised containment test is worth keeping even if you think the input is trusted — trust\nchanges, and this is one of the few validation rules with a security consequence.",[14,1059,1061],{"id":1060},"conclusion","Conclusion",[10,1063,1064],{},"Let the framework check existence, kind and permissions; write a small validator for paths you will\ncreate; resolve before comparing when containment matters; and print the resolved path in every\nerror. Between them these remove nearly all hand-written path handling from command bodies, and the\nhandful of lines that remain are the ones worth reading.",[14,1066,1068],{"id":1067},"frequently-asked-questions","Frequently asked questions",[1070,1071,1073,1074,1077,1078,1080],"h3",{"id":1072},"should-i-use-path-or-str-for-path-parameters","Should I use ",[26,1075,1076],{},"Path"," or ",[26,1079,357],{}," for path parameters?",[10,1082,1083,1085,1086,1088],{},[26,1084,1076],{},", always — both frameworks will produce one for you, and it removes an entire category of\nstring-manipulation bugs around separators and joining. In Click, remember ",[26,1087,353],{},";\nTyper infers it from the annotation.",[1070,1090,1092],{"id":1091},"what-about-paths-with-spaces-or-unusual-characters","What about paths with spaces or unusual characters?",[10,1094,1095],{},"They arrive correctly: the shell handles quoting, and Python gives you the decoded string. Problems\nhere are nearly always your own code building a command line for a subprocess — pass a list of\narguments rather than a formatted string and the issue disappears.",[1070,1097,1099],{"id":1098},"how-do-i-validate-that-a-directory-is-writable-without-creating-a-file","How do I validate that a directory is writable without creating a file?",[10,1101,1102,1105],{},[26,1103,1104],{},"os.access(path, os.W_OK)"," is what the frameworks use, and it is advisory — the definitive test is\nattempting the write. For a long-running command, an early advisory check plus a clear error at\nwrite time is the right combination.",[1070,1107,1109],{"id":1108},"should-the-tool-create-a-missing-output-directory","Should the tool create a missing output directory?",[10,1111,1112,1113,1116],{},"Only if the user asked, with a flag or a documented default. Silently creating directories surprises\npeople, especially when a typo produces a new directory tree instead of an error. ",[26,1114,1115],{},"--create-dirs"," is\nthe common convention.",[1070,1118,1120,1121,1123],{"id":1119},"does-resolve-fail-on-a-path-that-does-not-exist","Does ",[26,1122,64],{}," fail on a path that does not exist?",[10,1125,1126,1127,1130,1131,1134,1135,1138],{},"Not since Python 3.6 — it resolves as far as it can with ",[26,1128,1129],{},"strict=False",", which is the default. Pass\n",[26,1132,1133],{},"strict=True"," when you specifically want it to raise for a missing path, though the framework's\n",[26,1136,1137],{},"exists=True"," is usually the better place for that check.",[1070,1140,1142],{"id":1141},"how-do-i-handle-a-path-argument-that-may-be-a-glob","How do I handle a path argument that may be a glob?",[10,1144,1145,1146,1149,1150,1153,1154,1157],{},"Let the shell expand it and accept a list. ",[26,1147,1148],{},"mytool convert *.csv"," arrives as many arguments on Unix,\nso a ",[26,1151,1152],{},"list[Path]"," parameter is all you need. Expanding globs yourself is only necessary on Windows,\nwhere the shell does not — and if you do, do it explicitly with ",[26,1155,1156],{},"Path.glob"," rather than shelling\nout, and document that the pattern is interpreted by the tool.",[1070,1159,1161],{"id":1160},"should-symlinks-be-followed","Should symlinks be followed?",[10,1163,1164,1166],{},[26,1165,64],{}," follows them, which is what you want for containment checks and usually what you want\nfor reading. Where it matters is deletion and overwriting: a symlink pointing outside the intended\ndirectory turns an innocuous write into a surprise. If your tool deletes or replaces files, decide\ndeliberately and say so in the help text.",[14,1168,1170],{"id":1169},"related","Related",[19,1172,1173,1180,1187,1193,1200],{},[22,1174,1175,1176],{},"Up: ",[738,1177,1179],{"href":1178},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies\u002F","Advanced argument validation strategies",[22,1181,1182,1183],{},"Sideways: ",[738,1184,1186],{"href":1185},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies\u002Fparsing-nested-json-arguments-in-python-clis\u002F","Parsing nested JSON arguments in Python CLIs",[22,1188,1182,1189],{},[738,1190,1192],{"href":1191},"\u002Fadvanced-input-parsing-user-experience\u002Fhandling-configuration-files-env-vars\u002Floading-yaml-configs-safely-in-cli-apps\u002F","Loading YAML configs safely in CLI apps",[22,1194,1195,1196],{},"Related: ",[738,1197,1199],{"href":1198},"\u002Fadvanced-input-parsing-user-experience\u002Ferror-handling-and-exit-codes\u002Fchoosing-exit-codes-for-cli-tools\u002F","Choosing exit codes for CLI tools",[22,1201,1195,1202],{},[738,1203,1205],{"href":1204},"\u002Fproject-setup-dependency-management\u002Fvirtual-environments-isolation-best-practices\u002Fmanaging-virtual-environments-for-cross-platform-clis\u002F","Managing virtual environments for cross-platform CLIs",[1207,1208,1209],"style",{},"html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .szBVR, html code.shiki .szBVR{--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .s4XuR, html code.shiki .s4XuR{--shiki-default:#E36209;--shiki-dark:#FFAB70}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sJ8bj, html code.shiki .sJ8bj{--shiki-default:#6A737D;--shiki-dark:#6A737D}",{"title":113,"searchDepth":131,"depth":131,"links":1211},[1212,1213,1214,1215,1216,1217,1218,1219,1220,1221,1232],{"id":16,"depth":131,"text":17},{"id":82,"depth":131,"text":83},{"id":101,"depth":131,"text":102},{"id":361,"depth":131,"text":362},{"id":550,"depth":131,"text":551},{"id":647,"depth":131,"text":648},{"id":715,"depth":131,"text":716},{"id":763,"depth":131,"text":764},{"id":1060,"depth":131,"text":1061},{"id":1067,"depth":131,"text":1068,"children":1222},[1223,1225,1226,1227,1228,1230,1231],{"id":1072,"depth":144,"text":1224},"Should I use Path or str for path parameters?",{"id":1091,"depth":144,"text":1092},{"id":1098,"depth":144,"text":1099},{"id":1108,"depth":144,"text":1109},{"id":1119,"depth":144,"text":1229},"Does resolve() fail on a path that does not exist?",{"id":1141,"depth":144,"text":1142},{"id":1160,"depth":144,"text":1161},{"id":1169,"depth":131,"text":1170},"2026-08-01","Validate paths in a Python CLI - built-in existence and permission checks, refusing paths that escape a root, and errors that print the resolved path.","intermediate",false,"md",{},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies\u002Fvalidating-file-and-directory-paths-in-clis",{"title":5,"description":1234},"advanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies\u002Fvalidating-file-and-directory-paths-in-clis\u002Findex",[1243,1244,89,1245,1246],"validation","paths","security","click","EOTkeCeCwFQ9lyD58UZ4-VuCwU2V9YxlLNxzP_xlNAk",[1249,1252,1255,1258,1259,1262,1265,1268,1271,1274,1277,1280,1283,1286,1289,1292,1294,1297,1300,1303,1306,1309,1312,1315,1318,1321,1324,1327,1330,1333,1336,1339,1341,1344,1347,1350,1353,1356,1359,1362,1365,1368,1371,1374,1377,1380,1383,1386,1389,1392,1395,1398,1401,1404,1407,1410,1413,1416,1419,1422,1425,1428,1431,1434,1437,1440,1443,1446,1449,1452,1455,1458,1461,1464,1467,1470,1473,1476,1479,1482,1485,1488,1491],{"path":1250,"title":1251},"\u002Fabout","About Python CLI Toolcraft",{"path":1253,"title":1254},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies","Advanced Argument Validation Strategies",{"path":1256,"title":1257},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies\u002Fparsing-nested-json-arguments-in-python-clis","Parsing Nested JSON Args in Python CLIs",{"path":1239,"title":5},{"path":1260,"title":1261},"\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":1263,"title":1264},"\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":1266,"title":1267},"\u002Fadvanced-input-parsing-user-experience\u002Fcli-help-output-and-documentation","CLI Help Output and Documentation",{"path":1269,"title":1270},"\u002Fadvanced-input-parsing-user-experience\u002Fcli-help-output-and-documentation\u002Fversioning-and-deprecating-cli-flags","Versioning and Deprecating CLI Flags",{"path":1272,"title":1273},"\u002Fadvanced-input-parsing-user-experience\u002Fcli-help-output-and-documentation\u002Fwriting-help-text-users-actually-read","Writing Help Text Users Actually Read",{"path":1275,"title":1276},"\u002Fadvanced-input-parsing-user-experience\u002Ferror-handling-and-exit-codes\u002Fchoosing-exit-codes-for-cli-tools","Choosing Exit Codes for CLI Tools",{"path":1278,"title":1279},"\u002Fadvanced-input-parsing-user-experience\u002Ferror-handling-and-exit-codes\u002Ffriendly-error-messages-and-tracebacks","Friendly Error Messages and Tracebacks",{"path":1281,"title":1282},"\u002Fadvanced-input-parsing-user-experience\u002Ferror-handling-and-exit-codes\u002Fhandling-keyboard-interrupt-cleanly","Handling Keyboard Interrupt Cleanly",{"path":1284,"title":1285},"\u002Fadvanced-input-parsing-user-experience\u002Ferror-handling-and-exit-codes","Error Handling and Exit Codes for CLIs",{"path":1287,"title":1288},"\u002Fadvanced-input-parsing-user-experience\u002Fhandling-configuration-files-env-vars\u002Fconfig-precedence-flags-env-files-defaults","Config Precedence: Flags, Env, Files, Defaults",{"path":1290,"title":1291},"\u002Fadvanced-input-parsing-user-experience\u002Fhandling-configuration-files-env-vars","Handling Config Files and Env Vars in CLIs",{"path":1293,"title":1192},"\u002Fadvanced-input-parsing-user-experience\u002Fhandling-configuration-files-env-vars\u002Floading-yaml-configs-safely-in-cli-apps",{"path":1295,"title":1296},"\u002Fadvanced-input-parsing-user-experience","Advanced Input Parsing for Python CLIs",{"path":1298,"title":1299},"\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":1301,"title":1302},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich","Interactive Terminal UI with Rich",{"path":1304,"title":1305},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich\u002Frendering-tables-and-json-with-rich","Rendering Tables and JSON with Rich",{"path":1307,"title":1308},"\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":1310,"title":1311},"\u002Fadvanced-input-parsing-user-experience\u002Fshell-completion-for-python-clis","Shell Completion for Python CLIs",{"path":1313,"title":1314},"\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":1316,"title":1317},"\u002Fadvanced-input-parsing-user-experience\u002Fstructured-logging-for-cli-apps\u002Fadding-verbose-and-quiet-logging-flags","Adding Verbose and Quiet Logging Flags",{"path":1319,"title":1320},"\u002Fadvanced-input-parsing-user-experience\u002Fstructured-logging-for-cli-apps","Structured Logging for CLI Apps",{"path":1322,"title":1323},"\u002Fadvanced-input-parsing-user-experience\u002Fstructured-logging-for-cli-apps\u002Fstructured-json-logging-in-python-clis","Structured JSON Logging in Python CLIs",{"path":1325,"title":1326},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes\u002Fdetecting-tty-and-adapting-output","Detecting a TTY and Adapting Output",{"path":1328,"title":1329},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes\u002Femitting-json-output-for-scripting","Emitting JSON Output for Scripting",{"path":1331,"title":1332},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes\u002Fhandling-broken-pipe-and-sigpipe","Handling Broken Pipe and SIGPIPE",{"path":1334,"title":1335},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes","Working with stdin, stdout and Pipes",{"path":1337,"title":1338},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes\u002Freading-piped-input-in-python-clis","Reading Piped Input in Python CLIs",{"path":584,"title":1340},"Python CLI Toolcraft",{"path":1342,"title":1343},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcli-startup-performance-and-lazy-loading","CLI Startup Performance and Lazy Loading",{"path":1345,"title":1346},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcli-startup-performance-and-lazy-loading\u002Flazy-loading-subcommands-for-faster-startup","Lazy Loading Subcommands for Faster Startup",{"path":1348,"title":1349},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcli-startup-performance-and-lazy-loading\u002Fprofiling-python-cli-startup-time","Profiling Python CLI Startup Time",{"path":1351,"title":1352},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcli-startup-performance-and-lazy-loading\u002Freducing-cli-dependency-weight","Reducing CLI Dependency Weight",{"path":1354,"title":1355},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse\u002Fargparse-subparsers-for-subcommands","argparse Subparsers for Subcommands",{"path":1357,"title":1358},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse\u002Fargparse-vs-click-vs-typer-comparison","argparse vs Click vs Typer Compared",{"path":1360,"title":1361},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse","Command-Line Parsing with argparse",{"path":1363,"title":1364},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse\u002Fmigrating-from-argparse-to-typer","Migrating from argparse to Typer",{"path":1366,"title":1367},"\u002Fmodern-python-cli-frameworks-architecture","Python CLI Frameworks and Architecture",{"path":1369,"title":1370},"\u002Fmodern-python-cli-frameworks-architecture\u002Fplugin-architectures-for-extensible-clis","Plugin Architectures for Extensible CLIs",{"path":1372,"title":1373},"\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":1375,"title":1376},"\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":1378,"title":1379},"\u002Fmodern-python-cli-frameworks-architecture\u002Fstructuring-multi-command-python-clis\u002Fdependency-injection-patterns-for-cli-commands","Dependency Injection Patterns for CLI Commands",{"path":1381,"title":1382},"\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":1384,"title":1385},"\u002Fmodern-python-cli-frameworks-architecture\u002Fstructuring-multi-command-python-clis","Structuring Multi-Command Python CLIs",{"path":1387,"title":1388},"\u002Fmodern-python-cli-frameworks-architecture\u002Fstructuring-multi-command-python-clis\u002Fsharing-state-with-click-context-objects","Sharing State with Click Context Objects",{"path":1390,"title":1391},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications","Testing Python CLI Applications",{"path":1393,"title":1394},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Fmeasuring-cli-test-coverage","Measuring CLI Test Coverage",{"path":1396,"title":1397},"\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":1399,"title":1400},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Fsnapshot-testing-cli-output","Snapshot Testing CLI Output",{"path":1402,"title":1403},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Ftesting-click-commands-with-clirunner","Testing Click Commands with CliRunner",{"path":1405,"title":1406},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Ftesting-interactive-prompts-and-stdin","Testing Interactive Prompts and stdin",{"path":1408,"title":1409},"\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":1411,"title":1412},"\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":1414,"title":1415},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftyper-vs-click-when-to-use-each","Typer vs Click: When to Use Each",{"path":1417,"title":1418},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftyper-vs-click-when-to-use-each\u002Ftyper-callback-functions-explained","Typer callback functions explained",{"path":1420,"title":1421},"\u002Fproject-setup-dependency-management\u002Fcli-project-scaffolding-with-cookiecutter\u002Fcopier-vs-cookiecutter-for-cli-templates","Copier vs Cookiecutter for CLI Templates",{"path":1423,"title":1424},"\u002Fproject-setup-dependency-management\u002Fcli-project-scaffolding-with-cookiecutter","CLI Project Scaffolding with Cookiecutter",{"path":1426,"title":1427},"\u002Fproject-setup-dependency-management\u002Fdistributing-clis-as-standalone-binaries\u002Fbuilding-cross-platform-release-binaries-in-ci","Building Cross-Platform Release Binaries in CI",{"path":1429,"title":1430},"\u002Fproject-setup-dependency-management\u002Fdistributing-clis-as-standalone-binaries\u002Fbundling-a-python-cli-with-pyinstaller","Bundling a Python CLI with PyInstaller",{"path":1432,"title":1433},"\u002Fproject-setup-dependency-management\u002Fdistributing-clis-as-standalone-binaries\u002Fhomebrew-and-scoop-packaging-for-python-clis","Homebrew and Scoop Packaging for Python CLIs",{"path":1435,"title":1436},"\u002Fproject-setup-dependency-management\u002Fdistributing-clis-as-standalone-binaries","Distributing CLIs as Standalone Binaries",{"path":1438,"title":1439},"\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":1441,"title":1442},"\u002Fproject-setup-dependency-management","Project Setup & Dependency Management",{"path":1444,"title":1445},"\u002Fproject-setup-dependency-management\u002Fmanaging-cli-versioning-changelogs\u002Fautomating-changelogs-with-conventional-commits","Automating Changelogs with Conventional Commits",{"path":1447,"title":1448},"\u002Fproject-setup-dependency-management\u002Fmanaging-cli-versioning-changelogs\u002Fexposing-version-info-and-build-metadata","Exposing Version Info and Build Metadata",{"path":1450,"title":1451},"\u002Fproject-setup-dependency-management\u002Fmanaging-cli-versioning-changelogs","Managing CLI Versioning & Changelogs",{"path":1453,"title":1454},"\u002Fproject-setup-dependency-management\u002Fpackaging-python-clis-for-distribution\u002Fbuilding-wheels-and-sdists-for-python-clis","Building Wheels and sdists for Python CLIs",{"path":1456,"title":1457},"\u002Fproject-setup-dependency-management\u002Fpackaging-python-clis-for-distribution","Packaging Python CLIs for Distribution",{"path":1459,"title":1460},"\u002Fproject-setup-dependency-management\u002Fpackaging-python-clis-for-distribution\u002Finstalling-and-distributing-clis-with-pipx","Installing and Distributing CLIs with pipx",{"path":1462,"title":1463},"\u002Fproject-setup-dependency-management\u002Fpackaging-python-clis-for-distribution\u002Fpublishing-a-python-cli-to-pypi","Publishing a Python CLI to PyPI",{"path":1465,"title":1466},"\u002Fproject-setup-dependency-management\u002Fpoetry-workflows-for-cli-development","Poetry Workflows for CLI Development",{"path":1468,"title":1469},"\u002Fproject-setup-dependency-management\u002Fpoetry-workflows-for-cli-development\u002Fpoetry-entry-points-and-scripts-for-clis","Poetry Entry Points and Scripts for CLIs",{"path":1471,"title":1472},"\u002Fproject-setup-dependency-management\u002Fpre-commit-hooks-for-cli-projects","Pre-commit Hooks for CLI Projects",{"path":1474,"title":1475},"\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":1477,"title":1478},"\u002Fproject-setup-dependency-management\u002Fuv-for-python-cli-dependency-management","uv for Python CLI Dependency Management",{"path":1480,"title":1481},"\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":1483,"title":1484},"\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":1486,"title":1487},"\u002Fproject-setup-dependency-management\u002Fvirtual-environments-isolation-best-practices","Python CLI Env Isolation Best Practices",{"path":1489,"title":1490},"\u002Fproject-setup-dependency-management\u002Fvirtual-environments-isolation-best-practices\u002Fmanaging-virtual-environments-for-cross-platform-clis","Managing Python CLI Virtual Environments",{"path":1492,"title":1493},"\u002Fproject-setup-dependency-management\u002Fvirtual-environments-isolation-best-practices\u002Fpinning-the-python-version-for-a-cli","Pinning the Python Version for a CLI",1785614690027]