aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/dependencies
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2022-03-01 23:32:14 -0500
committerEli Schwartz <eschwartz@archlinux.org>2022-03-07 19:01:04 -0500
commita009eacc65ddb447edcfc9fd317ad828d9b3353a (patch)
treeae1c6388bfa45eb0672bbed1d8f18ebe0b3c2819 /mesonbuild/dependencies
parent187dc656f48ba7a86a14a5c8d9f16a3b2b7d8770 (diff)
downloadmeson-a009eacc65ddb447edcfc9fd317ad828d9b3353a.zip
meson-a009eacc65ddb447edcfc9fd317ad828d9b3353a.tar.gz
meson-a009eacc65ddb447edcfc9fd317ad828d9b3353a.tar.bz2
treewide: string-quote the first argument to T.cast
Using future annotations, type annotations become strings at runtime and don't impact performance. This is not possible to do with T.cast though, because it is a function argument instead of an annotation. Quote the type argument everywhere in order to have the same effect as future annotations. This also allows linters to better detect in some cases that a given import is typing-only.
Diffstat (limited to 'mesonbuild/dependencies')
-rw-r--r--mesonbuild/dependencies/detect.py4
-rw-r--r--mesonbuild/dependencies/qt.py4
2 files changed, 4 insertions, 4 deletions
diff --git a/mesonbuild/dependencies/detect.py b/mesonbuild/dependencies/detect.py
index 0f99c36..a721cba 100644
--- a/mesonbuild/dependencies/detect.py
+++ b/mesonbuild/dependencies/detect.py
@@ -176,13 +176,13 @@ def _build_external_dependency_list(name: str, env: 'Environment', for_machine:
# class method, if one exists, otherwise the list just consists of the
# constructor
if isinstance(packages[lname], type):
- entry1 = T.cast(T.Type[ExternalDependency], packages[lname]) # mypy doesn't understand isinstance(..., type)
+ entry1 = T.cast('T.Type[ExternalDependency]', packages[lname]) # mypy doesn't understand isinstance(..., type)
if issubclass(entry1, ExternalDependency):
# TODO: somehow make mypy understand that entry1(env, kwargs) is OK...
func: T.Callable[[], 'ExternalDependency'] = lambda: entry1(env, kwargs) # type: ignore
dep = [func]
else:
- entry2 = T.cast(T.Union['DependencyFactory', 'WrappedFactoryFunc'], packages[lname])
+ entry2 = T.cast('T.Union[DependencyFactory, WrappedFactoryFunc]', packages[lname])
dep = entry2(env, for_machine, kwargs)
return dep
diff --git a/mesonbuild/dependencies/qt.py b/mesonbuild/dependencies/qt.py
index a004688..f645f0e 100644
--- a/mesonbuild/dependencies/qt.py
+++ b/mesonbuild/dependencies/qt.py
@@ -127,13 +127,13 @@ class _QtBase:
else:
self.qtpkgname = self.qtname
- self.private_headers = T.cast(bool, kwargs.get('private_headers', False))
+ self.private_headers = T.cast('bool', kwargs.get('private_headers', False))
self.requested_modules = mesonlib.stringlistify(mesonlib.extract_as_list(kwargs, 'modules'))
if not self.requested_modules:
raise DependencyException('No ' + self.qtname + ' modules specified.')
- self.qtmain = T.cast(bool, kwargs.get('main', False))
+ self.qtmain = T.cast('bool', kwargs.get('main', False))
if not isinstance(self.qtmain, bool):
raise DependencyException('"main" argument must be a boolean')