eager-crayon-52125
04/28/2022, 5:27 PMbitter-ability-32190
04/28/2022, 5:37 PMeager-crayon-52125
04/28/2022, 5:39 PMeager-crayon-52125
04/28/2022, 5:40 PM.flake8
file between directories. Or a different minimum coverage bar. I assume you'd say the sameeager-crayon-52125
04/28/2022, 5:40 PMbitter-ability-32190
04/28/2022, 5:44 PMeager-crayon-52125
04/28/2022, 5:49 PMbitter-ability-32190
04/28/2022, 5:52 PMbitter-ability-32190
04/28/2022, 5:53 PM--no-process-cleanup
to leak the sandbox and inspect it.
You can also combine this with a lint
of a single file.
And try out lint --only=flake8
to only run flake8eager-crayon-52125
04/28/2022, 5:54 PMbitter-ability-32190
04/28/2022, 5:56 PMhappy-kitchen-89482
04/28/2022, 6:25 PMeager-crayon-52125
04/29/2022, 10:04 AM.flake8
file, and another one in utils/
. When I pants lint utils:
it doesn't pick up the flake8 file under utils/, whether my cwd is in utils/ or in the repo root.
I did add config_discovery = True
to [flake8]
section in pants.toml, to no avail.
I don't mind writing a some pants code for this to work, it's important to me. How do I start?bitter-ability-32190
04/29/2022, 1:11 PMutils
from the repo root?eager-crayon-52125
04/29/2022, 3:15 PMflake8 utils/foo.py
from the repo root, and have .flake8
in both utils/ and in the repo root, the one in the repo root is used.bitter-ability-32190
04/29/2022, 3:16 PMbitter-ability-32190
04/29/2022, 3:16 PMeager-crayon-52125
04/29/2022, 3:16 PMeager-crayon-52125
04/29/2022, 3:17 PMbitter-ability-32190
04/29/2022, 3:17 PMeager-crayon-52125
04/29/2022, 3:18 PMbitter-ability-32190
04/29/2022, 3:19 PMI propose that pants starts the search in the directory that holds that BUILD file containing the target.So AFAICT Pants is including ALL the relevant configs in the sandbox (as some tools do allow the hierarchical config). And the search does start at the relevant targets. What you're seeing isn't Pants' behavior but flake8s.
eager-crayon-52125
04/29/2022, 3:19 PMbitter-ability-32190
04/29/2022, 3:20 PMeager-crayon-52125
04/29/2022, 3:21 PMbitter-ability-32190
04/29/2022, 3:21 PM./pants --no-process-cleanup lint --only=-flake8 utils/foo.py
It'll log a dir that'll be leaked so that you can inspect the sandboxeager-crayon-52125
04/29/2022, 3:21 PMbitter-ability-32190
04/29/2022, 3:23 PMeager-crayon-52125
04/29/2022, 3:24 PMbitter-ability-32190
04/29/2022, 3:24 PMeager-crayon-52125
04/29/2022, 3:24 PMeager-crayon-52125
04/29/2022, 3:25 PMeager-crayon-52125
04/29/2022, 3:25 PMeager-crayon-52125
04/29/2022, 3:27 PMeager-crayon-52125
04/29/2022, 3:27 PMbitter-ability-32190
04/29/2022, 3:28 PMconfig
?eager-crayon-52125
04/29/2022, 3:28 PMeager-crayon-52125
04/29/2022, 3:29 PMeager-crayon-52125
04/29/2022, 3:29 PM[GLOBAL]
pants_version = "2.10.0"
backend_packages = [
"pants.backend.python",
"pants.backend.python.lint.flake8",
"pants.backend.python.typecheck.mypy",
"pants.backend.shell",
"pants.backend.shell.lint.shfmt",
"pants.backend.shell.lint.shellcheck",
]
use_deprecated_python_macros = false
[anonymous-telemetry]
enabled = false
[source]
root_patterns = ["/"]
[python]
interpreter_constraints = ["CPython>=3.9"]
[flake8]
config_discovery = true
[coverage-py]
interpreter_constraints = ["CPython>=3.9"]
eager-crayon-52125
04/29/2022, 3:33 PMeager-crayon-52125
04/29/2022, 3:33 PM~/proj/calius_repo $ find . -name .flake8
./.flake8
./utils/.flake8
eager-crayon-52125
04/29/2022, 3:33 PM~/proj/calius_repo $ ./pants --no-process-cleanup lint --only=flake8 utils/bisect_utils.py
18:33:02.30 [INFO] Preserving local process execution dir /private/var/folders/mk/_c6h2svs7ngdcc9h55f924wh0000gn/T/process-executionkZpbcd for "Run Flake8 on 1 file."
18:33:02.69 [INFO] Completed: Lint with Flake8 - flake8 succeeded.
✓ flake8 succeeded.
eager-crayon-52125
04/29/2022, 3:34 PMeager-crayon-52125
04/29/2022, 3:34 PM/private/…/T/process-executionkZpbcd $ cd /private/var/folders/mk/_c6h2svs7ngdcc9h55f924wh0000gn/T/process-executionkZpbcd
nitzans-macbook-pro
/private/…/T/process-executionkZpbcd $ find . -name .flake8
./.flake8
eager-crayon-52125
04/29/2022, 3:35 PMbitter-ability-32190
04/29/2022, 3:38 PMwell still appreciate it!Happy to help 🙂 (It's purely selfish, the more people on Pants the fancier my status as a maintainer is /s) Also, Pants isn't maintained by one company. Most of the maintainers today are Toolchain employees, but that's a product of history. We're onboarding more and more folks that aren't Toolchain (liek myself)
eager-crayon-52125
04/29/2022, 3:38 PMbitter-ability-32190
04/29/2022, 3:38 PMSo only one dot-flake8 file, and that's the one from the repo root. I ran md5sum.At least Pants is consistent with flake8 behavior
eager-crayon-52125
04/29/2022, 3:39 PMeager-crayon-52125
04/29/2022, 3:40 PMbitter-ability-32190
04/29/2022, 3:41 PMlogger.error(whatever)
. The async nature of the code makes it hard to breakpoint-debug.
You can use ./pants_from_sources
to run Pants from a sibling directory on your code.
See https://www.pantsbuild.org/v2.11/docs/contributor-overview for all the juicy docseager-crayon-52125
04/29/2022, 3:41 PMeager-crayon-52125
04/29/2022, 3:41 PMbitter-ability-32190
04/29/2022, 3:41 PMSo not really consistent -- you said above you think it's supposed to copy ALL relevant files, and it would be flake8 that "picks" the one.My code goggles aren't crisp. Bad assumption on my part 🙂
bitter-ability-32190
04/29/2022, 3:43 PMis to add some behavior to the code you sent me and/or to the flake8 pluginThat's what I'd do. FWIW Trying to swap the-thing-that-runs flake8 with something else isn't drop-in. You'd be implementing a new linter. See our (unfortunately not-so-up-to-date) docs: https://www.pantsbuild.org/v2.11/docs/plugins-lint-goal
eager-crayon-52125
04/29/2022, 3:43 PMbitter-ability-32190
04/29/2022, 3:43 PMbitter-ability-32190
04/29/2022, 3:44 PMbitter-ability-32190
04/29/2022, 3:45 PMeager-crayon-52125
04/29/2022, 3:45 PMbitter-ability-32190
04/29/2022, 3:45 PMbitter-ability-32190
04/29/2022, 3:53 PMisort
(which already supports hierarchical config). https://github.com/pantsbuild/pants/blob/e7c6095829304bd180e922fffeac3f8f0e4650f8/src/python/pants/backend/python/lint/isort/subsystem.py#L74eager-crayon-52125
04/29/2022, 9:04 PMeager-crayon-52125
04/29/2022, 9:04 PMhappy-kitchen-89482
04/29/2022, 9:45 PMbitter-ability-32190
04/29/2022, 9:49 PMhappy-kitchen-89482
04/29/2022, 10:18 PMhappy-kitchen-89482
04/29/2022, 10:18 PMbitter-ability-32190
04/29/2022, 10:30 PMextra_files
eager-crayon-52125
04/30/2022, 5:25 PMbitter-ability-32190
04/30/2022, 6:30 PMbitter-ability-32190
04/30/2022, 6:31 PMeager-crayon-52125
04/30/2022, 6:34 PMeager-crayon-52125
04/30/2022, 6:35 PMeager-crayon-52125
04/30/2022, 6:35 PMbitter-ability-32190
04/30/2022, 7:52 PMbitter-ability-32190
04/30/2022, 7:53 PMeager-crayon-52125
04/30/2022, 7:59 PMeager-crayon-52125
04/30/2022, 8:00 PMeager-crayon-52125
04/30/2022, 8:01 PMbitter-ability-32190
04/30/2022, 8:28 PMeager-crayon-52125
04/30/2022, 8:29 PMbitter-ability-32190
04/30/2022, 8:31 PMbitter-ability-32190
04/30/2022, 8:31 PMbitter-ability-32190
04/30/2022, 8:48 PMeager-crayon-52125
04/30/2022, 8:58 PMeager-crayon-52125
04/30/2022, 8:58 PMbitter-ability-32190
04/30/2022, 9:02 PMwitty-crayon-22786
04/30/2022, 9:10 PMscalafmt
… although ironically, i think it natively supports nested config), so that would be an option.bitter-ability-32190
04/30/2022, 9:27 PMbitter-ability-32190
04/30/2022, 9:28 PMhappy-kitchen-89482
05/01/2022, 12:40 AMflake8
directly in a subdir, it uses the config file in that subdir? So it basically uses whatever is in the cwd?eager-crayon-52125
05/01/2022, 4:14 AMeager-crayon-52125
05/01/2022, 4:14 AMhappy-kitchen-89482
05/01/2022, 1:29 PMeager-crayon-52125
05/02/2022, 4:00 AMflake8 --rc=utils/.flake8 utils/foo.py
from root, or if pants invoked flake8 foo.py
from within utils/. The latter seems better, because pants wouldn't have to know about the specific config files for each tool.
And to remind: flake8 is just an example. I also would like to run pytest that way, so that I can configure different minimum-coverage requirements per subdir.
So I'm just thinking: have pants be able to run tools from within a subdir.eager-crayon-52125
05/02/2022, 4:00 AMhappy-kitchen-89482
05/02/2022, 3:44 PMeager-crayon-52125
05/02/2022, 4:05 PMeager-crayon-52125
05/02/2022, 4:06 PMbitter-ability-32190
05/02/2022, 4:10 PMeager-crayon-52125
05/02/2022, 4:11 PMhappy-kitchen-89482
05/02/2022, 4:32 PMeager-crayon-52125
05/02/2022, 5:54 PMeager-crayon-52125
05/02/2022, 5:54 PMeager-crayon-52125
05/02/2022, 5:55 PMwitty-crayon-22786
05/02/2022, 5:58 PMhundreds-father-404
05/02/2022, 6:00 PMeager-crayon-52125
05/02/2022, 6:00 PMeager-crayon-52125
05/02/2022, 6:01 PMwitty-crayon-22786
05/02/2022, 6:01 PMeager-crayon-52125
05/02/2022, 6:01 PMwitty-crayon-22786
05/02/2022, 6:04 PMwitty-crayon-22786
05/02/2022, 6:04 PMskip_X
on a target by target basis is in line with that (you can skip using the repository’s rules, but not rewrite them)… per-directory configuration goes in another direction.witty-crayon-22786
05/02/2022, 6:07 PMpytest
because we have native support for slurping in conftest.py
files)eager-crayon-52125
05/02/2022, 6:07 PMwitty-crayon-22786
05/02/2022, 6:09 PMskip_X
flags or resolve=
flags hierarchically, rather than “variables must use snakecase”witty-crayon-22786
05/02/2022, 6:10 PM