pfnet / pysen

Python linting made easy. Also a casual yet honorific way to address individuals who have entered an organization prior to you.
MIT License
487 stars 20 forks source link

`pysen --loglevel debug run ...` truncates log outputs #42

Closed keisuke-nakata closed 8 months ago

keisuke-nakata commented 8 months ago

pysen --loglevel debug run lint truncates log outputs, but I don't think it is intended. I expect to see all log outputs when --loglevel debug.

For example the line > /Users/keisuke.nakata/.pyenv/versions/3.11.8/envs/pysen/bin/python -m black --config /Users/keisuke.nakata/Projects/pysen/pyproject.toml --diff --c... is truncated and I couldn't catch the exact command which pysen run.

$ pysen --logleve debug run lint
successfully found config file: /Users/keisuke.nakata/Projects/pysen/pyproject.toml
Running commands concurrently...
... concurrent execution done
Running: black
Checking 88 files
> /Users/keisuke.nakata/.pyenv/versions/3.11.8/envs/pysen/bin/python -m black --config /Users/keisuke.nakata/Projects/pysen/pyproject.toml --diff --c...
All done! ✨ 🍰 ✨
88 files would be left unchanged.
Running: flake8
Checking 88 files
> /Users/keisuke.nakata/.pyenv/versions/3.11.8/envs/pysen/bin/python -m flake8 --config /Users/keisuke.nakata/Projects/pysen/setup.cfg /Users/keisuke...
Running: isort
Checking 88 files
> /Users/keisuke.nakata/.pyenv/versions/3.11.8/envs/pysen/bin/python -m isort --settings-path /Users/keisuke.nakata/Projects/pysen/pyproject.toml --d...
Running: mypy
[1/5] Checking 3 entries
> /Users/keisuke.nakata/.pyenv/versions/3.11.8/envs/pysen/bin/python -m mypy --show-absolute-path --pretty --config-file /Users/keisuke.nakata/Projec...
keisuke-nakata commented 8 months ago

This truncation comes from https://github.com/pfnet/pysen/blob/main/pysen/reporter.py#L19 . However this function _truncate_command_sequence is called only here https://github.com/pfnet/pysen/blob/main/pysen/reporter.py#L84, where the log level is debug.

To resolve this issue, I suggest:

    def report_command(self, cmd: str) -> None:
        self._logger.debug(f"> {cmd}")
        self._commands.append(cmd)

and remove _truncate_command_sequence function from the codebase.