PyCQA / PyCQA/isort

Suppress all `check_file()` output

Open
#1,868 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
7k
Forks
687
Avg merge
4h 56m
Merged PRs (30d)
2

Description

Hi! I apologize if this has been answered elsewhere, but I don't see any existing documentation on this point (https://github.com/PyCQA/isort/issues/156 is the closest I found).

I'm currently building a tool that will call the isort.check_file() API, but I don't want to emit the lines like

ERROR: /tmp/test.py Imports are incorrectly sorted and/or formatted.

Looking at the code, it doesn't look like this is currently possible, as we just unconditionally create a "terminal printer" and then unconditionally call .error() on it:
https://github.com/PyCQA/isort/blob/44e3b5d179da5033ce23f796b014e74f3a3259cd/isort/api.py#L272-L275
https://github.com/PyCQA/isort/blob/44e3b5d179da5033ce23f796b014e74f3a3259cd/isort/api.py#L280

which ultimately unconditionally calls print():
https://github.com/PyCQA/isort/blob/44e3b5d179da5033ce23f796b014e74f3a3259cd/isort/format.py#L107

Is there a config option I'm missing somewhere? If not, what options do I have? I've considered monkey-patching create_terminal_printer() and monkey-patching sys.stderr, but neither seem like long-term solutions :)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in isort/api.py at check_file(), create_terminal_printer(), and the terminal error call described in the issue. Read isort/format.py where the printer reaches print(), then inspect nearby tests or API coverage. Done means callers can suppress all check_file() output without monkey-patching, while the check result remains usable.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, cli
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.