damp-quill-59187
12/04/2019, 11:38 PM./pants lint-v2 <target> on 1.23.0rc0 and ran into an error:
ERROR: Not a registered union type: <class 'pants.engine.rules.TargetWithSources'>Which led me here: https://github.com/pantsbuild/pants/pull/8490. And I figured I was heading deeper down the rabbit hole. So question is, are v2 goals usable outside of pants development itself? and if so what's the uplift of bringing them into our project
aloof-angle-91616
12/04/2019, 11:54 PM./pants list is only in v2 -- ./pants fast-filedeps also works). the approach i took in #8760 to hack around that is just as slow as v1, as a result.
(3) @union and UnionRule are intended to make `@rule`s extensible by allowing acting on an abstract description of an object, and are some of the more complex parts of this quickly-evolving API. see https://github.com/pantsbuild/pants/pull/8542 for an example of an attempt to try to make using them simpler -- but the takeaway is that error messages are bad, and we're sorry, and we're definitely working to fix that as we speak as non-Twitter folks begin to start picking up the v2 engine.aloof-angle-91616
12/04/2019, 11:55 PMaloof-angle-91616
12/04/2019, 11:55 PMdamp-quill-59187
12/05/2019, 12:11 AMhundreds-father-404
12/05/2019, 2:10 AMaloof-angle-91616
12/05/2019, 2:11 AMaloof-angle-91616
12/05/2019, 2:12 AMhundreds-father-404
12/05/2019, 2:13 AM(if you productionize the use of black, i and twitter would be extremely interested!)It, and V2 isort, are good to go generally. We are about to start using V2 isort in Pants internally now. The issue is in how we distribute the plugins via
backend_packages. You’re supposed to activate them by adding pants.backend.python.lint.black or pants.backend.python.lint.isort to your `pants.ini`’s backend_packages and that works for Pants but not for external users due to the stack trace Tennyson posted at the start of this thread.aloof-angle-91616
12/05/2019, 2:14 AMaloof-angle-91616
12/05/2019, 2:15 AMdamp-quill-59187
12/05/2019, 2:25 AMaloof-angle-91616
12/05/2019, 2:25 AMdamp-quill-59187
12/05/2019, 2:27 AMaloof-angle-91616
12/05/2019, 2:28 AMdamp-quill-59187
12/05/2019, 3:03 PMhundreds-father-404
12/06/2019, 12:22 AMhundreds-father-404
12/06/2019, 7:11 PMbackend_packages: +[
"pants.backend.python.lint.black",
]
Can you please try this and let me know what happens?damp-quill-59187
12/06/2019, 7:12 PMdamp-quill-59187
12/06/2019, 7:12 PMhundreds-father-404
12/06/2019, 7:13 PM1.24.0.dev1damp-quill-59187
12/06/2019, 7:13 PMdamp-quill-59187
12/06/2019, 7:22 PMERROR: Failed to load the pants.backend.python.lint.black.register backend: ModuleNotFoundError("No module named 'pants.backend.python.lint.black'")hundreds-father-404
12/06/2019, 7:22 PMpants.backend.python.lint.isort please?damp-quill-59187
12/06/2019, 7:22 PMdamp-quill-59187
12/06/2019, 7:24 PM.cache/pants/setup/bootstrap-Darwin-x86_64/1.24.0.dev1_py37/lib/python3.7/site-packages/pants/backend/python/lintdamp-quill-59187
12/06/2019, 7:24 PMdamp-quill-59187
12/06/2019, 7:24 PMdamp-quill-59187
12/06/2019, 7:25 PMdamp-quill-59187
12/06/2019, 7:25 PMdamp-quill-59187
12/06/2019, 7:26 PMhundreds-father-404
12/06/2019, 7:27 PMbackend_packages: +[
"pants.backend.python.lint.black",
]
And don’t include black as a part of that option for nowdamp-quill-59187
12/06/2019, 7:28 PMhundreds-father-404
12/06/2019, 7:29 PMfrom animals import dog, cat instead of from animals import cat, doghundreds-father-404
12/06/2019, 7:29 PM./pants lint-v2 path/to:target or ./pants fmt-v2 path/to:targetdamp-quill-59187
12/06/2019, 7:32 PMdamp-quill-59187
12/06/2019, 7:32 PMdamp-quill-59187
12/06/2019, 7:33 PMdamp-quill-59187
12/06/2019, 7:34 PMhundreds-father-404
12/06/2019, 7:34 PMisort and black in your backend_packages. (We’re working on fixing that)damp-quill-59187
12/06/2019, 7:34 PMhundreds-father-404
12/06/2019, 7:35 PMpants.ini
backend_packages: +[
"pants.backend.python.lint.black",
]damp-quill-59187
12/06/2019, 7:35 PMdamp-quill-59187
12/06/2019, 7:46 PMdamp-quill-59187
12/06/2019, 7:47 PMdamp-quill-59187
12/06/2019, 7:47 PMERROR: Failed to load the pants.backend.python.lint.black.register backend: ImportError("cannot import name 'flatten_shlexed_list' from 'pants.option.option_util'damp-quill-59187
12/06/2019, 7:47 PMdamp-quill-59187
12/06/2019, 7:48 PMdamp-quill-59187
12/06/2019, 7:48 PMdamp-quill-59187
12/06/2019, 7:49 PMdamp-quill-59187
12/06/2019, 7:49 PMdamp-quill-59187
12/06/2019, 7:50 PMhundreds-father-404
12/06/2019, 7:53 PMfmt-v2 and lint-v2! They’re seeing a lot of active development.
One nice benefit is that once you run the command on a target, so long as no changes are made to that target, the result will be cached. So, you can run ./pants fmt-v2 :: and Black will only run over any new changes!hundreds-father-404
12/08/2019, 9:43 AMhundreds-father-404
12/09/2019, 9:22 PMbackend_packages: +[
"pants.backend.python.lint.black",
]