User Actions
mkdir $'my\ndir'
my-tool $'my\ndir'
Expected Output
Invalid value for 'PATH': File 'my\ndir' is a directory.
Actual Output
Invalid value for 'PATH': File 'my
dir' is a directory.
Code
from pathlib import Path
from typing import Annotated
import typer
def main(path: Annotated[Path, typer.Argument(dir_okay=False)]) -> None:
pass
if __name__ == '__main__':
typer.run(main)
Cause
You clearly forgot !r on this line and are using quotes instead.
Just compare these lines in click.types:
_("{name} {filename!r} does not exist.").format(
_("{name} {filename!r} is a file.").format(
_("{name} '{filename}' is a directory.").format(
_("{name} {filename!r} is not readable.").format(
_("{name} {filename!r} is not writable.").format(
_("{name} {filename!r} is not executable.").format(