diff options
author | Eli Schwartz <eschwartz@archlinux.org> | 2021-12-04 21:11:51 -0500 |
---|---|---|
committer | Eli Schwartz <eschwartz@archlinux.org> | 2022-01-10 18:36:57 -0500 |
commit | 4b351aef26a19b4c73f6ef295f64da1c74bc713d (patch) | |
tree | 44f0b5c34c6bfb06360ffc22870ff423fc9305e2 /mesonbuild/wrap/wrap.py | |
parent | 98a41ec24e77d7670ea83fd986853d0fe7cb2f5b (diff) | |
download | meson-4b351aef26a19b4c73f6ef295f64da1c74bc713d.zip meson-4b351aef26a19b4c73f6ef295f64da1c74bc713d.tar.gz meson-4b351aef26a19b4c73f6ef295f64da1c74bc713d.tar.bz2 |
first pass at migrating to dataclasses
In some cases, init variables that accept None as a sentinel and
immediately overwrite with [], are migrated to dataclass field
factories. \o/
Note: dataclasses by default cannot provide eq methods, as they then
become unhashable. In the future we may wish to opt into declaring them
frozen, instead/additionally.
Diffstat (limited to 'mesonbuild/wrap/wrap.py')
-rw-r--r-- | mesonbuild/wrap/wrap.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/mesonbuild/wrap/wrap.py b/mesonbuild/wrap/wrap.py index f2b59bd..80756af 100644 --- a/mesonbuild/wrap/wrap.py +++ b/mesonbuild/wrap/wrap.py @@ -14,6 +14,7 @@ from .. import mlog import contextlib +from dataclasses import dataclass import urllib.request import urllib.error import urllib.parse @@ -203,13 +204,15 @@ def verbose_git(cmd: T.List[str], workingdir: str, check: bool = False) -> bool: except mesonlib.GitException as e: raise WrapException(str(e)) +@dataclass(eq=False) class Resolver: - def __init__(self, source_dir: str, subdir: str, subproject: str = '', wrap_mode: WrapMode = WrapMode.default) -> None: - self.source_dir = source_dir - self.subdir = subdir - self.subproject = subproject - self.wrap_mode = wrap_mode - self.subdir_root = os.path.join(source_dir, subdir) + source_dir: str + subdir: str + subproject: str = '' + wrap_mode: WrapMode = WrapMode.default + + def __post_init__(self) -> None: + self.subdir_root = os.path.join(self.source_dir, self.subdir) self.cachedir = os.path.join(self.subdir_root, 'packagecache') self.wraps = {} # type: T.Dict[str, PackageDefinition] self.provided_deps = {} # type: T.Dict[str, PackageDefinition] |