diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2021-06-14 15:36:17 -0700 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2021-06-22 09:13:41 -0700 |
commit | d636b92c1adc1588ff11b6ee4972c4bdd686f433 (patch) | |
tree | 65511141ccd85f5c39a3e5b306a10086df595e2c | |
parent | 7213b7d81fb2cc53d7fdca35409281045bae0fdc (diff) | |
download | meson-d636b92c1adc1588ff11b6ee4972c4bdd686f433.zip meson-d636b92c1adc1588ff11b6ee4972c4bdd686f433.tar.gz meson-d636b92c1adc1588ff11b6ee4972c4bdd686f433.tar.bz2 |
install_*: FileMode doesn't need to be None
There's no reason to allow None into the backend, it already has code to
check that all of the values of the FileMode object are None, so let's
use that, which is much simpler all the way down.
-rw-r--r-- | mesonbuild/backend/backends.py | 3 | ||||
-rw-r--r-- | mesonbuild/build.py | 12 | ||||
-rw-r--r-- | mesonbuild/interpreter/interpreter.py | 4 |
3 files changed, 7 insertions, 12 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index 4e1ac1e..8df9705 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -42,9 +42,6 @@ if T.TYPE_CHECKING: from ..interpreter import Interpreter, Test from ..mesonlib import FileMode - InstallType = T.List[T.Tuple[str, str, T.Optional['FileMode']]] - InstallSubdirsType = T.List[T.Tuple[str, str, T.Optional['FileMode'], T.Tuple[T.Set[str], T.Set[str]]]] - # Languages that can mix with C or C++ but don't support unity builds yet # because the syntax we use for unity builds is specific to C/++/ObjC/++. # Assembly files cannot be unitified and neither can LLVM IR files diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 83dd3f0..ee3b9c9 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -135,7 +135,7 @@ class DependencyOverride(HoldableObject): class Headers(HoldableObject): def __init__(self, sources: T.List[File], install_subdir: T.Optional[str], - install_dir: T.Optional[str], install_mode: T.Optional['FileMode'], + install_dir: T.Optional[str], install_mode: 'FileMode', subproject: str): self.sources = sources self.install_subdir = install_subdir @@ -158,14 +158,14 @@ class Headers(HoldableObject): def get_custom_install_dir(self) -> T.Optional[str]: return self.custom_install_dir - def get_custom_install_mode(self) -> T.Optional['FileMode']: + def get_custom_install_mode(self) -> 'FileMode': return self.custom_install_mode class Man(HoldableObject): def __init__(self, sources: T.List[File], install_dir: T.Optional[str], - install_mode: T.Optional['FileMode'], subproject: str, + install_mode: 'FileMode', subproject: str, locale: T.Optional[str]): self.sources = sources self.custom_install_dir = install_dir @@ -176,7 +176,7 @@ class Man(HoldableObject): def get_custom_install_dir(self) -> T.Optional[str]: return self.custom_install_dir - def get_custom_install_mode(self) -> T.Optional['FileMode']: + def get_custom_install_mode(self) -> 'FileMode': return self.custom_install_mode def get_sources(self) -> T.List['File']: @@ -186,7 +186,7 @@ class Man(HoldableObject): class InstallDir(HoldableObject): def __init__(self, src_subdir: str, inst_subdir: str, install_dir: str, - install_mode: T.Optional['FileMode'], + install_mode: 'FileMode', exclude: T.Tuple[T.Set[str], T.Set[str]], strip_directory: bool, subproject: str, from_source_dir: bool = True): @@ -2611,7 +2611,7 @@ class ConfigurationData(HoldableObject): # during install. class Data(HoldableObject): def __init__(self, sources: T.List[File], install_dir: str, - install_mode: T.Optional['FileMode'], subproject: str, + install_mode: 'FileMode', subproject: str, rename: T.List[str] = None): self.sources = sources self.install_dir = install_dir diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py index d522d25..8d1b693 100644 --- a/mesonbuild/interpreter/interpreter.py +++ b/mesonbuild/interpreter/interpreter.py @@ -128,7 +128,7 @@ def _install_mode_validator(mode: T.List[T.Union[str, bool, int]]) -> T.Optional return None -def _install_mode_convertor(mode: T.Optional[T.List[T.Union[str, bool, int]]]) -> T.Optional[FileMode]: +def _install_mode_convertor(mode: T.Optional[T.List[T.Union[str, bool, int]]]) -> FileMode: """Convert the DSL form of the `install_mode` keyword arugment to `FileMode` This is not required, and if not required returns None @@ -136,8 +136,6 @@ def _install_mode_convertor(mode: T.Optional[T.List[T.Union[str, bool, int]]]) - TODO: It's not clear to me why this needs to be None and not just return an emtpy FileMode. """ - if mode is None: - return None # this has already been validated by the validator return FileMode(*[m if isinstance(m, str) else None for m in mode]) |