From 2c806099c7d581b4181acd3ecffac42bed223bea Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Sun, 19 Mar 2023 15:31:09 -0400 Subject: repair install_mode support for uid/gid effectively everywhere We silently dropped all integer values to install_mode since the original implementation of doing this in KwargInfo, in commit 596c8d4af50d0e5a25ee0ee1e177e46b6c7ad22e. This happened because install_mode is supposed to convert False (exactly) to None, and otherwise pass all arguments in place. But a generator is homogeneous and attempting to do this correctly produced a mypy error that FileMode arguments were allowed to be ints -- well of course they are -- so that resulted in the convertor... treating ints like False instead, to make mypy happy. Fixes #11538 --- mesonbuild/interpreter/type_checking.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'mesonbuild') diff --git a/mesonbuild/interpreter/type_checking.py b/mesonbuild/interpreter/type_checking.py index beae001..2d2b916 100644 --- a/mesonbuild/interpreter/type_checking.py +++ b/mesonbuild/interpreter/type_checking.py @@ -97,8 +97,17 @@ def _install_mode_validator(mode: T.List[T.Union[str, bool, int]]) -> T.Optional def _install_mode_convertor(mode: T.Optional[T.List[T.Union[str, bool, int]]]) -> FileMode: """Convert the DSL form of the `install_mode` keyword argument to `FileMode`""" - # this has already been validated by the validator - return FileMode(*(m if isinstance(m, str) else None for m in mode)) + if not mode: + return FileMode() + + # This has already been validated by the validator. False denotes "use + # default". mypy is totally incapable of understanding it, because + # generators clobber types via homogeneous return. But also we *must* + # convert the first element different from the rest + m1 = mode[0] if isinstance(mode[0], str) else None + rest = (m if isinstance(m, (str, int)) else None for m in mode[1:]) + + return FileMode(m1, *rest) def _lower_strlist(input: T.List[str]) -> T.List[str]: -- cgit v1.1