You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I used the GitHub search to find a similar question 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 tutorials 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
# test_hello.pyfromtyper.testingimportCliRunnerfromhelloimportapprunner=CliRunner()
deftest_hello() ->None:
_=runner.invoke(app, ["hello"])
# hello.pyimportloggingimporttyperlogger=logging.getLogger(__name__)
app=typer.Typer()
@app.command()defhello() ->None:
"""Simple program that greets NAME for a total of COUNT times."""logger.warning("Greeting user now...")
typer.echo(f"Hello, world!")
@app.command()defbye(name: str="world") ->None:
"""Another command to avoid empty CLI issues."""typer.echo(f"Goodbye, {name}!")
if__name__=="__main__":
app()
# clipytest--log-cli-level=INFOtest_hello.py# Notice "ValueError: I/O operation on closed file."
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
First Check
Commit to Help
Example Code
Description
I can get the example to work as reported in pallets/click#824 (comment) with click 8.1.8.
But I want it working with Typer too, and unfortunately that still fails. Tried with
uv tree
Resolved 14 packages in 10ms
logs v0.1.0
├── click v8.1.8
├── typer v0.17.3
│ ├── click v8.1.8
│ ├── rich v14.1.0
│ │ ├── markdown-it-py v4.0.0
│ │ │ └── mdurl v0.1.2
│ │ └── pygments v2.19.2
│ ├── shellingham v1.5.4
│ └── typing-extensions v4.15.0
└── pytest v8.4.1 (group: dev)
├── iniconfig v2.1.0
├── packaging v25.0
├── pluggy v1.6.0
└── pygments v2.19.2
and also latest typer 0.17.3 and latest click 8.2.1.
Anyone know of a solution to get live logging working with pytest and clirunner with Typer? The exampel below fails.
pytest --log-cli-level=INFO test_hello.py
results in
It's important to enable live pytest logging (like via --log-cli-level). That's when the error occurs (and you actually do any logging).
Operating System
Windows, macOS
Operating System Details
No response
Typer Version
0.17.3
Python Version
3.13.7
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions