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

Make the CLI less verbose #4594

Closed
silverwind opened this issue Feb 8, 2023 · 9 comments
Closed

Make the CLI less verbose #4594

silverwind opened this issue Feb 8, 2023 · 9 comments
Labels
addressed in next version Issue is fixed and will appear in next published version enhancement request New feature or request

Comments

@silverwind
Copy link

silverwind commented Feb 8, 2023

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.

@silverwind silverwind added the enhancement request New feature or request label Feb 8, 2023
@erictraut
Copy link
Collaborator

This has been discussed previously, and we decided against it. The current information output by the cli is there for a reason.

@erictraut erictraut added the as designed Not a bug, working as intended label Feb 8, 2023
@erictraut
Copy link
Collaborator

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.

@silverwind
Copy link
Author

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.

@jamielinux
Copy link

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.

@carlosgmartin
Copy link

carlosgmartin commented Apr 16, 2023

@erictraut

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.

@erictraut erictraut reopened this Apr 26, 2023
@erictraut
Copy link
Collaborator

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.

@erictraut erictraut added addressed in next version Issue is fixed and will appear in next published version and removed as designed Not a bug, working as intended labels Apr 26, 2023
@jamielinux
Copy link

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! ☺️

@erictraut
Copy link
Collaborator

This is addressed in pyright 1.1.306, which I just published.

@randolf-scholz
Copy link

randolf-scholz commented May 2, 2024

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/)(.*:.*)"' --

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addressed in next version Issue is fixed and will appear in next published version enhancement request New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants