aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/dependencies
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2022-09-07 14:59:47 -0700
committerEli Schwartz <eschwartz@archlinux.org>2022-11-30 16:23:29 -0500
commit2d349eae8cb6f1f3b61838dca7cc989e9278be28 (patch)
treebc8d6325543e0df74b16941996f07797a746a2f6 /mesonbuild/dependencies
parent50f35039e7df321a309ee45db57d37635bf53ce3 (diff)
downloadmeson-2d349eae8cb6f1f3b61838dca7cc989e9278be28.zip
meson-2d349eae8cb6f1f3b61838dca7cc989e9278be28.tar.gz
meson-2d349eae8cb6f1f3b61838dca7cc989e9278be28.tar.bz2
pylint: enable the set_membership plugin
Which adds the `use-set-for-membership` check. It's generally faster in python to use a set with the `in` keyword, because it's a hash check instead of a linear walk, this is especially true with strings, where it's actually O(n^2), one loop over the container, and an inner loop of the strings (as string comparison works by checking that `a[n] == b[n]`, in a loop). Also, I'm tired of complaining about this in reviews, let the tools do it for me :)
Diffstat (limited to 'mesonbuild/dependencies')
-rw-r--r--mesonbuild/dependencies/base.py2
-rw-r--r--mesonbuild/dependencies/boost.py14
-rw-r--r--mesonbuild/dependencies/detect.py4
-rw-r--r--mesonbuild/dependencies/misc.py2
-rw-r--r--mesonbuild/dependencies/mpi.py2
5 files changed, 12 insertions, 12 deletions
diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py
index e78a420..d826026 100644
--- a/mesonbuild/dependencies/base.py
+++ b/mesonbuild/dependencies/base.py
@@ -274,7 +274,7 @@ class InternalDependency(Dependency):
assert isinstance(result, InternalDependency)
memo[id(self)] = result
for k, v in self.__dict__.items():
- if k in ['libraries', 'whole_libraries']:
+ if k in {'libraries', 'whole_libraries'}:
setattr(result, k, copy.copy(v))
else:
setattr(result, k, copy.deepcopy(v, memo))
diff --git a/mesonbuild/dependencies/boost.py b/mesonbuild/dependencies/boost.py
index 2a901ce..4ebd88d 100644
--- a/mesonbuild/dependencies/boost.py
+++ b/mesonbuild/dependencies/boost.py
@@ -152,9 +152,9 @@ class BoostLibraryFile():
self.version_lib = '{}_{}'.format(self.vers_raw[0], self.vers_raw[1])
# Detecting library type
- if self.nvsuffix in ['so', 'dll', 'dll.a', 'dll.lib', 'dylib']:
+ if self.nvsuffix in {'so', 'dll', 'dll.a', 'dll.lib', 'dylib'}:
self.static = False
- elif self.nvsuffix in ['a', 'lib']:
+ elif self.nvsuffix in {'a', 'lib'}:
self.static = True
else:
raise UnknownFileException(self.path)
@@ -177,7 +177,7 @@ class BoostLibraryFile():
for i in tags:
if i == 'mt':
self.mt = True
- elif len(i) == 3 and i[1:] in ['32', '64']:
+ elif len(i) == 3 and i[1:] in {'32', '64'}:
self.arch = i
elif BoostLibraryFile.reg_abi_tag.match(i):
self.runtime_static = 's' in i
@@ -316,13 +316,13 @@ class BoostLibraryFile():
# If no vscrt tag present, assume that it fits ['/MD', '/MDd', '/MT', '/MTd']
if not vscrt:
return True
- if vscrt in ['/MD', '-MD']:
+ if vscrt in {'/MD', '-MD'}:
return not self.runtime_static and not self.runtime_debug
- elif vscrt in ['/MDd', '-MDd']:
+ elif vscrt in {'/MDd', '-MDd'}:
return not self.runtime_static and self.runtime_debug
- elif vscrt in ['/MT', '-MT']:
+ elif vscrt in {'/MT', '-MT'}:
return (self.runtime_static or not self.static) and not self.runtime_debug
- elif vscrt in ['/MTd', '-MTd']:
+ elif vscrt in {'/MTd', '-MTd'}:
return (self.runtime_static or not self.static) and self.runtime_debug
mlog.warning(f'Boost: unknown vscrt tag {vscrt}. This may cause the compilation to fail. Please consider reporting this as a bug.', once=True)
diff --git a/mesonbuild/dependencies/detect.py b/mesonbuild/dependencies/detect.py
index ebbcc2f..782c2f1 100644
--- a/mesonbuild/dependencies/detect.py
+++ b/mesonbuild/dependencies/detect.py
@@ -52,8 +52,8 @@ def get_dep_identifier(name: str, kwargs: T.Dict[str, T.Any]) -> 'TV_DepID':
# 'default_options' is only used in fallback case
# 'not_found_message' has no impact on the dependency lookup
# 'include_type' is handled after the dependency lookup
- if key in ('version', 'native', 'required', 'fallback', 'allow_fallback', 'default_options',
- 'not_found_message', 'include_type'):
+ if key in {'version', 'native', 'required', 'fallback', 'allow_fallback', 'default_options',
+ 'not_found_message', 'include_type'}:
continue
# All keyword arguments are strings, ints, or lists (or lists of lists)
if isinstance(value, list):
diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py
index e5f92b3..d23eeee 100644
--- a/mesonbuild/dependencies/misc.py
+++ b/mesonbuild/dependencies/misc.py
@@ -214,7 +214,7 @@ class Python3DependencySystem(SystemDependency):
return None
elif pyplat == 'win32':
return '32'
- elif pyplat in ('win64', 'win-amd64'):
+ elif pyplat in {'win64', 'win-amd64'}:
return '64'
mlog.log(f'Unknown Windows Python platform {pyplat!r}')
return None
diff --git a/mesonbuild/dependencies/mpi.py b/mesonbuild/dependencies/mpi.py
index a99a4cc..842535d 100644
--- a/mesonbuild/dependencies/mpi.py
+++ b/mesonbuild/dependencies/mpi.py
@@ -136,7 +136,7 @@ class _MPIConfigToolDependency(ConfigToolDependency):
for f in args:
if self._is_link_arg(f):
result.append(f)
- if f in ('-L', '-Xlinker'):
+ if f in {'-L', '-Xlinker'}:
include_next = True
elif include_next:
include_next = False