mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 05:44:56 +00:00
Move Pylint rendering to ruff_db
(#19340)
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](https://github.com/astral-sh/ruff/issues/1953), [PR](https://github.com/astral-sh/ruff/pull/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>
This commit is contained in:
parent
92a302e291
commit
e9cac3684a
11 changed files with 154 additions and 88 deletions
|
@ -624,6 +624,12 @@ impl OneIndexed {
|
|||
}
|
||||
}
|
||||
|
||||
impl Default for OneIndexed {
|
||||
fn default() -> Self {
|
||||
Self::MIN
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for OneIndexed {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||
std::fmt::Debug::fmt(&self.0.get(), f)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue