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

Less verbose output #204

Open
tuukkamustonen opened this issue Nov 3, 2023 · 5 comments
Open

Less verbose output #204

tuukkamustonen opened this issue Nov 3, 2023 · 5 comments

Comments

@tuukkamustonen
Copy link

tuukkamustonen commented Nov 3, 2023

Hi, thanks for the great library. Taking it into use in a legacy repository that we've been refactoring mercilessly! The layered mode will come to good use.

What would you think of option for less verbose output? Even with no violations, the output is quite verbose:

=============
Import Linter
=============

---------
Contracts
---------

Analyzed 653 files, 2276 dependencies.
--------------------------------------

Layers KEPT

Contracts: 1 kept, 0 broken.

I'd rather only get single line (or no line at all, if all is okay).

We run import-linter alongside other tools, via a bash script. It will output something like:

Running Black...
All done! ✨ 🍰 ✨
26 files left unchanged.
Running ruff check --fix...
Running isort...
Running autoflake...
Running docformatter...
Running ruff...
Running flake8...
Running pydocstyle...

Most tools seem to default to not print anything at all, if there are no violations (only Black is more verbose as can be seen above). Would be nice to have the same behavior for import-linter, too?

@seddonym
Copy link
Owner

seddonym commented Nov 6, 2023

Nice idea. Happy to consider a pull request for this if anyone is interested.

I suggest we follow the same approach as Ruff, that is we add a --quiet flag which cannot be used with --verbose. That would be backwards compatible. Open to other suggestions.

@tuukkamustonen
Copy link
Author

tuukkamustonen commented Nov 7, 2023

I'm not sure, is --quiet for something else?

  -q, --quiet    Print diagnostics, but nothing else
touch foobar.py                                                                   ruff foobar.py             ruff --quiet foobar.py

Prints nothing (no violations).

echo "blahlbha" > foobar.py                                                                   ruff foobar.py             
foobar.py:1:1: B018 Found useless expression. Either assign it to a variable or remove it.
foobar.py:1:1: F821 Undefined name `blahlbha`
Found 2 errors.ruff --quiet foobar.py
foobar.py:1:1: B018 Found useless expression. Either assign it to a variable or remove it.
foobar.py:1:1: F821 Undefined name `blahlbha`

The --quiet seems to remove the "Found 2 errors." but it doesn't affect the violations output.

In any case, just to clarify what this ticket suggests:

  • No violations -> print nothing
  • Violations -> print them

@seddonym
Copy link
Owner

seddonym commented Nov 8, 2023

I don't understand, that seems to be what ruff is doing but I might be misunderstanding. In any case, feel free to outline here how you propose things should work in detail (maybe with some examples)?

@tuukkamustonen
Copy link
Author

I mean that ruff by default acts as suggested in this ticket. The explicit ruff --quiet only removes "Found 2 errors." when there are errors but it doesn't do anything when there aren't. Ruff is kinda quiet by default. I'm not exactly sure what the --quiet in ruff would be useful for...

So import-linter doesn't need similar --quiet but yes it needs --quiet to avoid changing the default behavior, which is opposite to ruff and most tools out there. For that reason, you might consider changing the default behavior but I totally understand if you don't want to.

I hope I sketched it out better this time! If not... we'll just carry on 😄

@seddonym
Copy link
Owner

seddonym commented Nov 9, 2023

you might consider changing the default behavior but I totally understand if you don't want to

I don't think I'll do this unless as part of a major release. In the meantime, open to pull requests that add a --quiet flag (or some other suggested API) but don't change the default behaviour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants