-
-
Notifications
You must be signed in to change notification settings - Fork 834
Closed
Labels
questionQuestion or problemQuestion or problem
Description
First Check
- I added a very descriptive title to this issue.
- I used the GitHub search to find a similar issue and didn't find it.
- I searched the Typer documentation, with the integrated search.
- I already searched in Google "How to X in Typer" and didn't find any information.
- I already read and followed all the tutorial in the docs and didn't find an answer.
- I already checked if it is not related to Typer but to Click.
Commit to Help
- I commit to help with one of those options 👆
Example Code
# cli.py
@app.command()
def main(
config_file: Optional[Path] = typer.Argument(
"config.yaml", # Default if not provided
exists=True,
file_okay=True,
dir_okay=False,
writable=False,
readable=True,
resolve_path=True,
)
):
config_data = parse_yaml_config_file(config_file)
# config.py
import yaml
def parse_yaml_config_file(file) -> dict:
with open(file) as yaml_file:
return yaml.safe_load(yaml_file)Description
The above code works as expected in dev, and all unit tests pass. However, after creating a wheel and installing into a test venv I get the following Traceback:
Traceback (most recent call last):
File "C:\Users\RickyWhite\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\RickyWhite\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Users\RickyWhite\OneDrive - The Migus Group\Desktop\Test\venv\Scripts\hofund.exe\__main__.py", line 7, in <module>
File "C:\Users\RickyWhite\OneDrive - The Migus Group\Desktop\Test\venv\lib\site-packages\hofund\cli.py", line 37, in main
config_data = parse_yaml_config_file(config_file)
File "C:\Users\RickyWhite\OneDrive - The Migus Group\Desktop\Test\venv\lib\site-packages\hofund\config.py", line 8, in parse_yaml_config_file
with open(config_file) as yaml_file:
TypeError: expected str, bytes or os.PathLike object, not ArgumentInfo
I've check my debugger and with print, and the config_file is indeed a WindowsPath object.
I've tried converting to a str, but get an OSError: [Errno 22] Invalid argument: '<typer.models.ArgumentInfo object at 0x000001F590930DC0>' error instead.
I'm not sure why it seems to be of type ArgumentInfo when installed from a wheel, but WindowsPath object when ran locally. 😕
Operating System
Windows
Operating System Details
Windows 11
OS build 22000.438
Typer Version
0.4.0
Python Version
3.10
Additional Context
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
questionQuestion or problemQuestion or problem