Fix subprocess.run on Windows Python 3.7 (#5220)

## Summary

From the [subprocess
docs](https://docs.python.org/3/library/subprocess.html#subprocess.Popen):

> Changed in version 3.6: args parameter accepts a path-like object if
shell is False and a sequence containing path-like objects on POSIX.
>
> Changed in version 3.8: args parameter accepts a path-like object if
shell is False and a sequence containing bytes and path-like objects on
Windows.

We want to support python 3.7 on windows, so we need to convert the
`Path` into a `str`
This commit is contained in:
konstin 2023-06-20 19:53:32 +02:00 committed by GitHub
parent 30734f06fd
commit acb23dce3c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -32,5 +32,7 @@ def find_ruff_bin() -> Path:
if __name__ == "__main__":
ruff = find_ruff_bin()
completed_process = subprocess.run([ruff, *sys.argv[1:]])
# Passing a path-like to `subprocess.run()` on windows is only supported in 3.8+,
# but we also support 3.7
completed_process = subprocess.run([os.fsdecode(ruff), *sys.argv[1:]])
sys.exit(completed_process.returncode)