Is this a bug or am I misusing the config? ```# p...
# general
g
Is this a bug or am I misusing the config?
Copy code
# pants.toml
[pytest]
args = ["-m", "not integration"]
How it's being picked up and processed by the runner (it's splitting the one arg into two):
Copy code
"./pytest_runner.pex_pex_shim.sh", "-m", "not", "integration"
b
It does seem like it's intentional: following the chain of
PyTest
subsystem's
args
->
ArgListOption
->
ShellStrListOption
-> uses of
shell_str
-> https://github.com/pantsbuild/pants/blob/2e010cd20a3b1cf2586923ee2863dd1be5f5497d/src/python/pants/option/custom_types.py#L194-L199 indicates that it's apparently intentionally splitting up each element of the list with
shlex.split
, so to fix your immediate problem
args = ["-m", "'not integration'"]
likely works. It's... unconventional that it takes a list of args, but still splits each element!
g
@broad-processor-92400 that worked! thank you.
w
unconventional that it takes a list of args, but still splits each element!
I was gonna say the opposite - most command lines/tooling I've used do something similar. I just always assumed it was a bash thing in the end which required the double escapes
g
interesting...
b
SJ, I've always seen two styles for constructing commands like this: 1. single string, which behaves according to shell rules (usually by passing the string to a shell invocation like
bash -c ...
) 2. an array, where each element is taken literally Two examples: • Python's
subprocess.run
(https://docs.python.org/3/library/subprocess.html#subprocess.run) has: a. 1 with
shell=True
:
subprocess.run("echo hello", shell=True)
passes that string as is to a shell, and so runs
echo
with arg
hello
b. 2 with the default
shell=False
:
subprocess.run(["echo hello"])
attempts to run a binary called
echo hello
, which likely doesn't exist • Docker
RUN
and other similar commands (https://docs.docker.com/reference/dockerfile/#shell-and-exec-form) has: ◦ 1 when passed text directly:
RUN echo hello
◦ 2 when passed an array:
RUN ["echo hello"]
Pants is doing a third thing, where it takes an array but splits each element, so
["echo hello"]
is equivalent to
["echo", "hello"]
.
w
Huh, well would you look at that. The stuff I'm referring to is a bit more artisanal CLIs from random companies - nothing I would put any particular faith in. Just never looked into it. That's kinda funny, because when I noticed that Pants args thing a while back, i just kinda shrugged it off as like "okay, sure"