Hey, I'm getting this error when trying to run `pa...
# general
r
Hey, I'm getting this error when trying to run
pants check
after configuring a custom linter plugin.
Copy code
12:11:57.96 [ERROR] 1 Exception encountered:

Engine traceback:
  in `check` goal

InvalidLockfileError: You are using the `pants-plugins` lockfile at 3rdparty/python/pants-plugins.lock with incompatible inputs.



- The inputs use interpreter constraints (`CPython==3.8.*`) that are not a subset of those used to generate the lockfile (`CPython==3.9.*`).- The input interpreter constraints are specified by your code, using the `[python].interpreter_constraints` option and the `interpreter_constraints` target field.

- To create a lockfile with new interpreter constraints, update the option `[python].resolves_to_interpreter_constraints`, and then generate the lockfile (see below).

See {doc_url('python-interpreter-compatibility')} for details.

To regenerate your lockfile, run `pants generate-lockfiles --resolve=pants-plugins`.

See <https://www.pantsbuild.org/v2.16/docs/python-third-party-dependencies> for details.
My default interpreter is Python 3.8, but I have my
pants-plugins
resolve set to use Python 3.9 in my
pants.toml
Copy code
[python.resolves_to_interpreter_constraints]
pants-plugins = [ "CPython==3.9.*" ]
Ooh wait I think I get it
Mypy needs the interpreter for 3.9.* - gonna test my hypothesis now
Hmm, that didn't work even as I anticipated, with error message
Copy code
- The inputs use interpreter constraints (`CPython<4,>=3.7`) that are not a subset of those used to generate the lockfile (`CPython==3.9.*`).- The input interpreter constraints are specified by your code, using the `[python].interpreter_constraints` option and the `interpreter_constraints` target field.
h
Can you put a small repo together that repros this?
b
What other interpreter constraints do you set in
pants.toml
(and elsewhere)? The ones mentioned in that second message look like the default ones
r
I just tried recreating this in an adhoc repo and I cannot so I must have some setting messed up somewhere. In
pants.toml
I have
Copy code
[python]
interpreter_constraints = [ "CPython>=3.8,<3.11" ]
enable_resolves = true

[python.resolves]
python-default = "default.lock"
pants-plugins = "plugins.lock"

[python.resolves_to_interpreter_constraints]
python-default = [ "==3.8.*" ]
pants-plugins = [ "==3.9.*" ]
Then in my lockfiles for both mypy and pytest I see
Copy code
//   "valid_for_interpreter_constraints": [
//     "CPython<3.11,>=3.8"
//   ],
I reset the default interpreter constraints to only consider 3.8 - 3.10 so now it shows
Copy code
14:58:20.23 [ERROR] 1 Exception encountered:

Engine traceback:
  in `check` goal

InvalidLockfileError: You are using the `pants-plugins` lockfile at 3rdparty/python/pants-plugins.lock with incompatible inputs.



- The inputs use interpreter constraints (`CPython<3.11,>=3.8`) that are not a subset of those used to generate the lockfile (`CPython==3.9.*`).- The input interpreter constraints are specified by your code, using the `[python].interpreter_constraints` option and the `interpreter_constraints` target field.

- To create a lockfile with new interpreter constraints, update the option `[python].resolves_to_interpreter_constraints`, and then generate the lockfile (see below).

See {doc_url('python-interpreter-compatibility')} for details.

To regenerate your lockfile, run `pants generate-lockfiles --resolve=pants-plugins`.

See <https://www.pantsbuild.org/v2.16/docs/python-third-party-dependencies> for details.
Ah now I figured it out for real
Needed to set interpreter constraints on the source and test files and not just the resolve
But now I have discovered that it looks like we can't run checks over everything if you need incompatible python versions?
Aka I can't run mypy over a python 3.8 vs python. 3.9 project together, they need to be run separately
But it's weird because I'm getting this message:
Copy code
- The inputs use interpreter constraints (`CPython<4,>=3.7`) that are not a subset of those used to generate the lockfile (`CPython==3.8.* OR CPython==3.9.*`).- The input interpreter constraints may be specified by `[{resolve}].interpreter_constraints` (if applicable).
But when I run
pants py-constraints --summary
I only see dependencies with interpreter constraints
==3.8.*
or
==3.9.*
h
Ah yes, it's important to note (and I recently updated this in the docs) that the ICs on a resolve are inputs to its generation, but the ICs on the source files are the ones actually used, and they must be compatible