A clear and concise description of what the bug is.
When I try to exec ad hoc command using locally the docker connector @docker with image python3.8, it seems that the image that is taken into account is python2 since it doesn't accept syntax of print with parenthesis ("print()")
Steps to reproduce the behavior (include code & usage example):
Here are command to produce the error :
pyinfra -v @docker/python:3.8 exec -- python3.8 -c "print(sys.version_info)"
See output :

When we run the command using python2 syntax it works :
pyinfra -v @docker/python:3.8 exec -- python3.8 -c "print sys.version_info"
see output :

the expected behaviour is to run as in docker :
docker run -it python:3.8 python3.8 -c "import sys; print(sys.version_info)"

pyinfra --support.-vv and --debug.Thank you for your awsome work, keep going, it might become the new standard
I think this is an issue with quoting your docker command. This is what I got to work.
$ pyinfra -v @docker/python:3.8 exec -- 'python3.8 -c "import sys;print(sys.version_info)"'
--> Loading config...
--> Loading inventory...
--> Connecting to hosts...
[@docker/python:3.8] Connected
--> Proposed changes:
Groups: @docker
[@docker/python:3.8] Operations: 1 Commands: 1
--> Beginning operation run...
--> Starting operation: Server/Shell (python3.8 -c "import sys;print(sys.version_info)")
[@docker/python:3.8] sys.version_info(major=3, minor=8, micro=10, releaselevel='final', serial=0)
[@docker/python:3.8] Success
--> Results:
Groups: @docker
[@docker/python:3.8] Successful: 1 Errors: 0 Commands: 1/1
localhost: Getting image source signatures
localhost: Copying blob sha256:688e187d6c79c46e8261890f0010fd5d178b8faa178959b0b46b2635aa1eeff3
localhost: Copying blob sha256:00bcea93703b384ab61d2344d6e721c75b0e47198b7912136a86759d8d885711
localhost: Copying blob sha256:ccb9b68523fdb47816f2a15d7590d06ff3d897dfdb3e0733e9c06a2bb79ebfc7
localhost: Copying blob sha256:685934357c8993799eda4a6d71c2bb2d2c54b1138d6e037f675eeeeffc719f2d
localhost: Copying blob sha256:dd3097cd7909834b61bdd207dcf8dd6e4db35b638f643c6ccfd5ef1a58c3b7ae
localhost: Copying blob sha256:1591bf7ec708b8e0d9ff6a4bfbfdfcce7177f5a8e52a78bb3b0cee0099ad2386
localhost: Copying blob sha256:3102aefb25e8ee1f62e70c3538678ee62a2fe9be77189157f72220bc3fa08845
localhost: Copying blob sha256:3ce6c827e0feb4ea7e9dca34ef9b8c7b410d5926bfef7c8108e0090027633e85
localhost: Copying blob sha256:8ab46b5dc98d6ac8f8a32b27cfac43fd875ad11d9e5a8e8cf709f54d9fa6ddb2
localhost: Copying blob sha256:5868b4f562b7e97ce97416d0fa17a586d23baf00683917cad6950a2cc8a4c348
localhost: Copying config sha256:22c78c1807a7aa1c56096eda909440a31b8ee06b469c94ab48dc14ac3438dd18
localhost: Writing manifest to image destination
localhost: Storing signatures
localhost: 22c78c1807a7aa1c56096eda909440a31b8ee06b469c94ab48dc14ac3438dd18
localhost: 8d4a7d42439b9650741d3c1fced9c0a2699ec76c45e3c0142063e664f756bfff
[@docker/python:3.8] docker build complete, image ID: 807a7aa1c560
Thank you, it works for me too, so I'll close the issue, I will also point that it might be useful to point the attention in the documentation to this quote behavior
Most helpful comment
Thank you for your awsome work, keep going, it might become the new standard