Make the CLI less verbose
silverwind opened this issue ยท 9 comments
Is your feature request related to a problem? Please describe.
The pyright
cli is very verbose, it prints a lot of uninteresting debug-style output that can not be suppressed, which makes visually parsing the output harder than it needs to be.
In my opinion, well-behaved CLIs should be silent on success and only print the actual valuable parts (the errors,warnings and informations) by default, eslint
cli is a good example that does just that.
Describe the solution you'd like
Reduce default cli output from
Loading configuration file at pyrightconfig.json
Assuming Python version 3.10
Assuming Python platform Darwin
Auto-excluding **/node_modules
Auto-excluding **/__pycache__
Auto-excluding **/.*
stubPath typings is not a valid directory.
Searching for source files
Found 1 source file
pyright 1.1.293
file.py
file.py:1:1 - warning: Some Warning
0 errors, 1 warning, 0 informations
Completed in 1.877sec
to
file.py
file.py:1:1 - warning: Some Warning
0 errors, 1 warning, 0 informations
Additional context
Existing output could be moved to the existing --verbose
flag. If backwards compatibility is a concern, the new reduced output style could be used when a --silent
or --quiet
flag is given.
This has been discussed previously, and we decided against it. The current information output by the cli is there for a reason.
I forgot to mention that there is an --outputjson
option. Using this, you can easily customize the output to be in any form you'd like. It just takes a couple of lines of script that wraps the pyright executable.
Maybe at least the stubPath typings is not a valid directory.
message can be removed. It looks like an error, but I think it isn't.
Anyone reading this issue may like to give this a try: https://github.com/jamielinux/pyright-polite
It's a cross-platform wrapper for pyright that gets rid of unnecessary output, preserves pyright's colorisation, and supports --watch
mode.
It's hilariously over-engineered ๐คฃ but was mainly a fun weekend project to play around with asyncio.
This has been discussed previously, and we decided against it. The current information output by the cli is there for a reason.
Can you explain? I don't see how an optional --silent
or --quiet
flag would hurt.
I'm revisiting this issue since it has gotten numerous thumbs-ups. I've changed the CLI to limit its output by default. If you use --stats
, it includes more (including all of the details it output previously), and if you include --verbose
it outputs much much more.
Thanks @jamielinux for posting your formatter, and apologies for making it obsolete.
Thank you @erictraut ! ๐
Thanks @jamielinux for posting your formatter, and apologies for making it obsolete.
Heh, no problem, pyright-polite's goal in life was to become obsolete!
This is addressed in pyright 1.1.306, which I just published.
For people who want even less verbose output (similar to mypy --hide-error-context --hide-error-end --no-pretty
), for usage in e.g. pre-commit, one can do:
pyright src/ | grep -Po "(?<=$PWD/)(.*:.*)" # does not preserve color
script -c "pyright src" /dev/null | grep --color=never -Po "(?<=$PWD/)(.*:.*)" # preserves color
e.g.
- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.361
hooks:
- id: pyright
entry: sh -c '! script -c "pyright $*" /dev/null | grep --color=never -Po "(?<=$PWD/)(.*:.*)"' --