In another instance of Pants using the wrong Pytho...
# general
r
In another instance of Pants using the wrong Python version, we have in our
pants.toml
,
Copy code
[black]
interpreter_constraints = ["==3.12.*"]
However, black gives us the following error:
Copy code
Cannot parse: 51:67:                     f"Database name in config is {database_config["dbname"]}, "
This f-string is fine in 3.12. black must be incorrectly using the wrong version. This seems like a bug, right?
1
@happy-kitchen-89482 should I file a bug on this?
r
Shouldn't you escape the double quote around dbname? Or use single quotes
r
@refined-addition-53644 thanks for the response! But those are not needed in 3.12. See https://peps.python.org/pep-0701/
👍 1
r
Well I need to keep up. Didn't know that! Thank you!
b
Do you have black configuration (eg in pyproject.toml)? If so, does that set the target version?
r
I have it in
pants.toml
(see above). I don't have a
pyproject.toml
.
b
Ah, okay. I think the config there is describing what interpreter to use to run the black process itself. It sounds like black doesn’t use its current interpreter as the default language version. Can you try setting https://black.readthedocs.io/en/stable/usage_and_configuration/the_basics.html#t-target-version ? Maybe like
Copy code
[black]
…
args = [“--target-version=py312”]
You may also need to tell pants to use a newer version of black than what it has built in: https://www.pantsbuild.org/2.19/docs/python/overview/lockfiles#lockfiles-for-tools
r
@broad-processor-92400 thanks, this is useful - it seems like it really is something that Black is doing wrong itself. I looked at their issues, and indeed they don't support this yet: https://github.com/psf/black/issues/3746
h
Good to know!