dazzling-elephant-33766
04/22/2024, 11:52 AMruff integration. I’m seeing differences between running when running ruff inside an exported virutalenv vs via pants
I’m using a pinned version of ruff 0.3.0
[ruff]
install_from_resolve = "python-default"
pants export --resolve=python-default
When I run the local venv version:
dist/export/python/virtualenvs/python-default/3.11.8/bin/ruff check <file>
No changes ...
VS when I run via pants
pants lint <file>
12:46:51.29 [ERROR] Completed: Lint with `ruff check` - environment:macos - ruff check failed (exit code 1).
<file>:1:1: I001 [*] Import block is un-sorted or un-formatted
Found 1 error.
[*] 1 fixable with the `--fix` option.
Unsure what’s going on here. It’s obviously discovering the config correctly because the rule in question I001 is configured in my pyproject.toml
Is there a way to confirm pants is running the correct version here?gentle-flower-25372
04/22/2024, 12:58 PM--verbose flag to figure it out. It turns out that ruff was categorizing things different based on the context of where ruff is called. I saw it start when we upgraded from ruff 0.1.8 to the 0.3.x. I first obvserved the difference between ruff in pre-commit and running ruff via poetry run ruff.
I ended up fixing it by using ruff's known-first-party configuration. Pretty annoying actually, but it solved the problem for us. I hope this helps.gentle-flower-25372
04/22/2024, 12:58 PM--verbose flag:
[2024-04-22][06:55:18][ruff_linter::rules::isort::categorize][DEBUG] Categorized 'altdev.commands.ado' as Known(FirstParty) (KnownFirstParty)
[2024-04-22][06:55:18][ruff_linter::rules::isort::categorize][DEBUG] Categorized 'logging' as Known(StandardLibrary) (KnownStandardLibrary)
[2024-04-22][06:55:18][ruff_linter::rules::isort::categorize][DEBUG] Categorized 'time' as Known(StandardLibrary) (KnownStandardLibrary)
[2024-04-22][06:55:18][ruff_linter::rules::isort::categorize][DEBUG] Categorized 'json' as Known(StandardLibrary) (KnownStandardLibrary)
[2024-04-22][06:55:18][ruff_linter::rules::isort::categorize][DEBUG] Categorized 'os' as Known(StandardLibrary) (KnownStandardLibrary)gentle-flower-25372
04/22/2024, 12:59 PMbetter-van-82973
04/22/2024, 1:03 PMcurved-television-6568
04/22/2024, 1:53 PMdazzling-elephant-33766
04/22/2024, 2:35 PMknown-first-party fixed my issues