I'm getting a strange warning in Pycharm, I wanted to check it is a mistake with Pycharm and not my code.

I use subprocess.run to call certain external commands:

with open(log.txt, 'w+') as log:
    subprocess.run('echo "hello world"', shell=True, stdout=log, stderr=log)

Now, this works fine and shows no errors. However, if I add a condition:

if condition:
    with open(log.txt, 'w+') as log:
        subprocess.run('echo "hello world"', shell=True, stdout=log, stderr=log)

Pycharm now throws a warning "bool object not callable". Is this just a Pycharm error (as obviously I'm calling a string command) or is there something deeper going on here?

Thanks for any help.

0 Answers