Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Path option doesn't seem to expand user #252

Open
felixgao opened this issue Mar 23, 2021 · 2 comments · May be fixed by #255
Open

[BUG] Path option doesn't seem to expand user #252

felixgao opened this issue Mar 23, 2021 · 2 comments · May be fixed by #255
Labels
bug Something isn't working

Comments

@felixgao
Copy link

Describe the bug

When the path have ~ in the path it doesn't seem to resolve.

To Reproduce

  • Create a file main.py with:
import typer

app = typer.Typer()

@app.command()
def login(
    config_path: Path = typer.Option(
        default=os.environ.get("PROFILE", "~/.aws/my_profile"),
        exists=True,
        file_okay=True,
        dir_okay=False,
        readable=True,
        resolve_path=True,
    )
):
  typer.echo(f"Hello {config_path}")

if __name__ == "__main__":
    app()
  • Call it with:
python main.py
  • It outputs:
Error: Invalid value for '--config-path': File '~/.aws/my_profile' does not exist.
  • But I expected it to output:
Hello ~/.aws/my_profile 

or

Hello /User/username/.aws/my_profile

Environment

  • OS: macOS
  • Typer Version: 0.3.2
  • Python version: 3.6.12
@felixgao felixgao added the bug Something isn't working label Mar 23, 2021
pmav99 added a commit to pmav99/typer that referenced this issue Mar 29, 2021
pmav99 added a commit to pmav99/typer that referenced this issue Mar 29, 2021
pmav99 added a commit to pmav99/typer that referenced this issue Mar 29, 2021
pmav99 added a commit to pmav99/typer that referenced this issue Mar 29, 2021
@pmav99 pmav99 linked a pull request Mar 29, 2021 that will close this issue
@curoky
Copy link

curoky commented Apr 22, 2022

Also expect to have a parameter control expanduser, and there are also some discussions in pallets/click#287.

@alexreg
Copy link

alexreg commented May 10, 2022

The documentation is clear about this.

:param resolve_path: Make the value absolute and resolve any
    symlinks. A ~ is not expanded, as this is supposed to be done by the shell only.

So, I'm afraid it's a feature, not a bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants