-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Added pylint formatter #1995
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
Added pylint formatter #1995
Conversation
Co-authored-by: messense <messense@icloud.com>
|
Looks great, thank you for putting this together! |
| (GitLab CI code quality report). | ||
| (machine-readable), `"junit"` (machine-readable XML), `"github"` (GitHub | ||
| Actions annotations), `"gitlab"` (GitLab CI code quality report), or | ||
| `"pylint"` (Pylint text format). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for the future: all these references are auto-generated from the documentation, so this needed to be changed in src/settings/options.rs (followed by an invocation of cargo dev generate-all).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, good to know!
| // See: https://flake8.pycqa.org/en/latest/internal/formatters.html#pylint-formatter | ||
| for message in &diagnostics.messages { | ||
| let label = format!( | ||
| "{}:{}: [{}] {}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tweaked this to put some of the plain-text characters in the format string directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was unsure about this but this is more what I would expect.
Cheers, thanks for the merge! |
[](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [ruff](https://togithub.com/charliermarsh/ruff) | `^0.0.226` -> `^0.0.227` | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>charliermarsh/ruff</summary> ### [`v0.0.227`](https://togithub.com/charliermarsh/ruff/releases/tag/v0.0.227) [Compare Source](https://togithub.com/charliermarsh/ruff/compare/v0.0.226...v0.0.227) #### What's Changed - Drop `RuleCode` in favor of `Rule` enum with human-friendly names by [@​not-my-profile](https://togithub.com/not-my-profile) in [https://github.com/charliermarsh/ruff/pull/1941](https://togithub.com/charliermarsh/ruff/pull/1941) - Make define_rule_mapping! set rule code as doc comment of variants by [@​not-my-profile](https://togithub.com/not-my-profile) in [https://github.com/charliermarsh/ruff/pull/1991](https://togithub.com/charliermarsh/ruff/pull/1991) - Added pylint formatter by [@​damienallen](https://togithub.com/damienallen) in [https://github.com/charliermarsh/ruff/pull/1995](https://togithub.com/charliermarsh/ruff/pull/1995) - Preserve unmatched comparators in `SIM109` by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/1998](https://togithub.com/charliermarsh/ruff/pull/1998) - Drop `Violation::placeholder` by [@​not-my-profile](https://togithub.com/not-my-profile) in [https://github.com/charliermarsh/ruff/pull/1996](https://togithub.com/charliermarsh/ruff/pull/1996) - Apply #\[derive(Default)] fixes suggested by Clippy by [@​akx](https://togithub.com/akx) in [https://github.com/charliermarsh/ruff/pull/2000](https://togithub.com/charliermarsh/ruff/pull/2000) - Avoid `SIM201` and `SIM202` errors in `__ne__` et al by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/2001](https://togithub.com/charliermarsh/ruff/pull/2001) - Fix that --explain panics by [@​not-my-profile](https://togithub.com/not-my-profile) in [https://github.com/charliermarsh/ruff/pull/2002](https://togithub.com/charliermarsh/ruff/pull/2002) - Split up pydocstyle rules by [@​akx](https://togithub.com/akx) in [https://github.com/charliermarsh/ruff/pull/2003](https://togithub.com/charliermarsh/ruff/pull/2003) - Add RUF005 "unpack instead of concatenating" check by [@​akx](https://togithub.com/akx) in [https://github.com/charliermarsh/ruff/pull/1957](https://togithub.com/charliermarsh/ruff/pull/1957) - Enable autofix for `FitsOnOneLine` (`D200`) by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/2006](https://togithub.com/charliermarsh/ruff/pull/2006) - Change AsRef<str> impl for Rule to kebab-case by [@​not-my-profile](https://togithub.com/not-my-profile) in [https://github.com/charliermarsh/ruff/pull/2009](https://togithub.com/charliermarsh/ruff/pull/2009) - Upgrade RustPython by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/2011](https://togithub.com/charliermarsh/ruff/pull/2011) - Avoid SIM401 in `elif` blocks by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/2012](https://togithub.com/charliermarsh/ruff/pull/2012) - Improve --explain output by [@​not-my-profile](https://togithub.com/not-my-profile) in [https://github.com/charliermarsh/ruff/pull/2010](https://togithub.com/charliermarsh/ruff/pull/2010) - Avoid checking row types for single-name [@​parametrize](https://togithub.com/parametrize) decorators by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/2013](https://togithub.com/charliermarsh/ruff/pull/2013) #### New Contributors - [@​damienallen](https://togithub.com/damienallen) made their first contribution in [https://github.com/charliermarsh/ruff/pull/1995](https://togithub.com/charliermarsh/ruff/pull/1995) **Full Changelog**: astral-sh/ruff@v0.0.226...v0.0.227 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/ixm-one/pytest-cmake-presets). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC4xMDUuNCIsInVwZGF0ZWRJblZlciI6IjM0LjEwNS40In0=--> Signed-off-by: Renovate Bot <bot@renovateapp.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Summary -- This is a very simple output format, the only decision is what to do if the file is missing from the diagnostic. For now, I opted to `unwrap_or_default` both the path and the `OneIndexed` row number, giving `:1: main diagnostic message` in the test without a file. Another quirk here is that the path is relativized. I just pasted in the `relativize_path` and `get_cwd` implementations from `ruff_linter::fs` for now, but maybe there's a better place for them. I didn't see any details about why this needs to be relativized in the original [issue](#1953), [PR](#1995), or in the pylint [docs](https://flake8.pycqa.org/en/latest/internal/formatters.html#pylint-formatter), but it did change the results of the CLI integration test when I tried deleting it. I haven't been able to reproduce that in the CLI, though, so it may only happen with `Command::current_dir`. Test Plan -- Tests ported from `ruff_linter` and a new test for the case with no file
Summary -- This is a very simple output format, the only decision is what to do if the file is missing from the diagnostic. For now, I opted to `unwrap_or_default` both the path and the `OneIndexed` row number, giving `:1: main diagnostic message` in the test without a file. Another quirk here is that the path is relativized. I just pasted in the `relativize_path` and `get_cwd` implementations from `ruff_linter::fs` for now, but maybe there's a better place for them. I didn't see any details about why this needs to be relativized in the original [issue](#1953), [PR](#1995), or in the pylint [docs](https://flake8.pycqa.org/en/latest/internal/formatters.html#pylint-formatter), but it did change the results of the CLI integration test when I tried deleting it. I haven't been able to reproduce that in the CLI, though, so it may only happen with `Command::current_dir`. Test Plan -- Tests ported from `ruff_linter` and a new test for the case with no file
Summary -- This is a very simple output format, the only decision is what to do if the file is missing from the diagnostic. For now, I opted to `unwrap_or_default` both the path and the `OneIndexed` row number, giving `:1: main diagnostic message` in the test without a file. Another quirk here is that the path is relativized. I just pasted in the `relativize_path` and `get_cwd` implementations from `ruff_linter::fs` for now, but maybe there's a better place for them. I didn't see any details about why this needs to be relativized in the original [issue](#1953), [PR](#1995), or in the pylint [docs](https://flake8.pycqa.org/en/latest/internal/formatters.html#pylint-formatter), but it did change the results of the CLI integration test when I tried deleting it. I haven't been able to reproduce that in the CLI, though, so it may only happen with `Command::current_dir`. Test Plan -- Tests ported from `ruff_linter` and a new test for the case with no file --------- Co-authored-by: Micha Reiser <micha@reiser.io>
Fixes: #1953
@charliermarsh thank you for the tips in the issue.
I'm not very familiar with Rust, so please excuse if my string formatting syntax is messy.
In terms of testing, I compared output of
flake8 --format=pylintandcargo run --format=pylinton the same code and the output syntax seems to check out.