...but don't do that; bash script.sh is itself an antipattern. Scripts should choose their own interpreters by having a shebang line, and bash scripts shouldn't have sh extensions (bash and sh are two different interpreters); ideally they should have no extension at all. See also Commandname extensions considered harmful.
(also, if you're going to make a shell script write JSON, use a format-aware tool like jq to do it; think about what happens now if someone runs yourscript '39, "foobar": "baz"' -- they can inject arbitrary data into your document)
subprocess.run(['bash', 'script.sh', str(state)])bash script.shis itself an antipattern. Scripts should choose their own interpreters by having a shebang line, and bash scripts shouldn't have sh extensions (bash and sh are two different interpreters); ideally they should have no extension at all. See also Commandname extensions considered harmful.jqto do it; think about what happens now if someone runsyourscript '39, "foobar": "baz"'-- they can inject arbitrary data into your document)