lemon-oxygen-72498
12/07/2022, 9:25 AMinterpreter_constraints = ["==3.8.*", "==3.9.*"]
in the top-level pants.toml
file and in one library, I have interpreter_constraints=parametrize(py38=["==3.8.*"], py39=["==3.9.*"])
to generate targets for the two interpreters.
My problem is that pants
doesn't want to run black
anymore, ./pants lint --only=black ::
fails with:
InvalidLockfileError: You are using the lockfile at pants-utils/3rdparty/python/black_lockfile.lock to install the tool `black`, but it is not compatible with your configuration:
- You have set interpreter constraints (`CPython<4,>=3.7`) that are not compatible with those used to generate the lockfile (`CPython==3.8.* OR CPython==3.9.*`).You can fix this by not setting `[black].interpreter_constraints`, or by using a new custom lockfile.
But ./pants lint --only=isort ::
works 🤯 Running ./pants generate-lockfiles --resolve=black
doesn't solve the issue. What is the root explanation and what can I do?wide-midnight-78598
12/07/2022, 1:04 PMlemon-oxygen-72498
12/07/2022, 2:47 PM→ git grep -h -C 4 interpreter_constraints pants-utils/3rdparty/python/black_lockfile.lock
//
// --- BEGIN PANTS LOCKFILE METADATA: DO NOT EDIT OR REMOVE ---
// {
// "version": 3,
// "valid_for_interpreter_constraints": [
// "CPython==3.8.*",
// "CPython==3.9.*"
// ],
// "generated_with_requirements": [
lemon-oxygen-72498
12/07/2022, 2:48 PMhappy-kitchen-89482
12/07/2022, 5:07 PMCPython<4,>=3.7
coming from? Were those the old interpreter constraints from pants.toml? Or the default if you weren't setting those?enough-analyst-54434
12/07/2022, 5:09 PM$ git grep "CPython>=3.7,<4"
src/python/pants/backend/cc/lint/clangformat/subsystem.py: default_interpreter_constraints = ["CPython>=3.7,<4"]
src/python/pants/backend/codegen/protobuf/python/python_protobuf_subsystem.py: default_interpreter_constraints = ["CPython>=3.7,<4"]
src/python/pants/backend/docker/subsystems/dockerfile_parser.py: default_interpreter_constraints = ["CPython>=3.7,<4"]
src/python/pants/backend/python/goals/coverage_py.py: default_interpreter_constraints = ["CPython>=3.7,<4"]
src/python/pants/backend/python/lint/add_trailing_comma/subsystem.py: default_interpreter_constraints = ["CPython>=3.7,<4"]
src/python/pants/backend/python/lint/autoflake/subsystem.py: default_interpreter_constraints = ["CPython>=3.7,<4"]
src/python/pants/backend/python/lint/black/subsystem.py: default_interpreter_constraints = ["CPython>=3.7,<4"]
src/python/pants/backend/python/lint/docformatter/subsystem.py: default_interpreter_constraints = ["CPython>=3.7,<4"]
src/python/pants/backend/python/lint/isort/subsystem.py: default_interpreter_constraints = ["CPython>=3.7,<4"]
src/python/pants/backend/python/lint/pyupgrade/subsystem.py: default_interpreter_constraints = ["CPython>=3.7,<4"]
src/python/pants/backend/python/lint/yapf/subsystem.py: default_interpreter_constraints = ["CPython>=3.7,<4"]
src/python/pants/backend/python/subsystems/setup.py: default_interpreter_constraints = ["CPython>=3.7,<4"]
src/python/pants/backend/python/subsystems/setuptools_scm.py: default_interpreter_constraints = ["CPython>=3.7,<4"]
src/python/pants/backend/python/subsystems/twine.py: default_interpreter_constraints = ["CPython>=3.7,<4"]
src/python/pants/backend/python/typecheck/mypy/subsystem.py: default_interpreter_constraints = ["CPython>=3.7,<4"]
src/python/pants/backend/python/typecheck/pyright/subsystem.py: default=["CPython>=3.7,<4"],
src/python/pants/backend/terraform/dependency_inference.py: default_interpreter_constraints = ["CPython>=3.7,<4"]
gentle-gigabyte-52115
12/07/2022, 5:13 PMwide-midnight-78598
12/07/2022, 5:29 PMWe seem to be able to set interpreter_constraints in the toml file to resolve thisWhich
interpreter_constraints
did you have to set to solve this? And which one didn't solve it?gentle-gigabyte-52115
12/07/2022, 6:24 PM[black] # <https://www.pantsbuild.org/docs/reference-black>
interpreter_constraints = [">=3.8"]
version = "black==22.3.0"
lockfile = "pants-utils/3rdparty/python/black_lockfile.lock"
enough-analyst-54434
12/07/2022, 6:42 PM>=3.8,<3.10
enough-analyst-54434
12/07/2022, 6:44 PM>=3.7,<4
default. That permits 3.12 alphas. We've had no issues reported as a result though that I'm aware of.lemon-oxygen-72498
12/07/2022, 7:42 PMinterpreter_constraints
declarations to tools. @gentle-gigabyte-52115's suggestion indeed works 👍happy-kitchen-89482
12/07/2022, 9:06 PMhappy-kitchen-89482
12/07/2022, 9:06 PM