aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2021-01-12 12:00:22 -0800
committerDylan Baker <dylan@pnwbakers.com>2021-01-13 13:32:48 -0800
commitcaab4d3d92e90430a77e7694a1582461b0fe2913 (patch)
tree67066c1fa74a0bfe81ed00eac3c107102a06fdee
parentc49ad7ca4877aabaebdb75c16814c9e6653c697e (diff)
downloadmeson-caab4d3d92e90430a77e7694a1582461b0fe2913.zip
meson-caab4d3d92e90430a77e7694a1582461b0fe2913.tar.gz
meson-caab4d3d92e90430a77e7694a1582461b0fe2913.tar.bz2
minstall: Fix signature of monkeypatched os.chown
this also clears up the last of the mypy problems in minstall, yay!
-rw-r--r--mesonbuild/minstall.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/mesonbuild/minstall.py b/mesonbuild/minstall.py
index 5389003..3e425eb 100644
--- a/mesonbuild/minstall.py
+++ b/mesonbuild/minstall.py
@@ -124,10 +124,19 @@ def set_chown(path: str, user: T.Optional[str] = None, group: T.Optional[str] =
# Not nice, but better than actually rewriting shutil.chown until
# this python bug is fixed: https://bugs.python.org/issue18108
real_os_chown = os.chown
+
+ def chown(path: T.Union[int, str, 'os.PathLike[str]', bytes, 'os.PathLike[bytes]'],
+ uid: int, gid: int, *, dir_fd: T.Optional[int] = dir_fd,
+ follow_symlinks: bool = follow_symlinks) -> None:
+ """Override the default behavior of os.chown
+
+ Use a real function rather than a lambda to help mypy out. Also real
+ functions are faster.
+ """
+ real_os_chown(path, gid, uid, dir_fd=dir_fd, follow_symlinks=follow_symlinks)
+
try:
- os.chown = lambda p, u, g: real_os_chown(p, u, g,
- dir_fd=dir_fd,
- follow_symlinks=follow_symlinks)
+ os.chown = chown
shutil.chown(path, user, group)
finally:
os.chown = real_os_chown