cool-easter-32542
08/21/2024, 2:28 PM[WARN] Value mismatch for the option `args` in scope [ruff]:
Legacy value: ['--quiet', '--config', 'lint.isort.known-first-party=["foo","bar"]'] of type <class 'list'>, from source CONFIG
Native value: ['--quiet', '--config', 'lint.isort.known-first-party=[\\"foo\\",\\"bar\\"]'] of type <class 'list'>, from source CONFIG
Here's a minimal repro:
cat << EOF > pants.toml
[GLOBAL]
pants_version="2.22.0.rc2"
backend_packages = [
"pants.backend.python",
"pants.backend.experimental.python.lint.ruff.check",
]
[python]
interpreter_constraints = ["CPython==3.12.*"]
[ruff]
args = ["--quiet", "--config", """lint.isort.known-first-party=%(env.FIRST_PARTY)s"""]
EOF
cat << EOF > .pants.bootstrap
# there should be 3 slashes before each quote, so we need to do extra escaping for the heredoc
FIRST_PARTY='[\\\\\"foo\\\\\",\\\\\"bar\\\\\"]'
export FIRST_PARTY
EOF
cat << EOF > main.py
print("hello world")
EOF
cat << EOF > BUILD
python_sources()
EOF
# run pants lint - shows the Value mismatch warning
pants lint ::
Note, this is traced back to some unintuitive behavior in shlex, ref:
$ python
Python 3.12.5 (main, Aug 6 2024, 19:08:49) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import shlex
>>> shlex.split("""lint.isort.known-first-party=[\'foo\',\'bar\']""")
['lint.isort.known-first-party=[foo,bar]']
>>> shlex.split("""lint.isort.known-first-party=[\\\'foo\\\',\\\'bar\\\']""")
["lint.isort.known-first-party=['foo','bar']"]
... and I believe the new behavior is more ergonomic.
Pants version
2.22.0.rc2
OS
MacOS
Additional info
n/a
pantsbuild/pants