aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers/mixins/ccrx.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2020-09-21 12:48:51 -0700
committerDylan Baker <dylan@pnwbakers.com>2020-09-24 12:14:13 -0700
commit682d22129c32edc64c610478368e1bc1f1dbc921 (patch)
tree093f5e8b064772ee3f0811c81123bb0df872bfee /mesonbuild/compilers/mixins/ccrx.py
parent2c0fbe161d61d2d15d29892456544442ab1c4ff6 (diff)
downloadmeson-682d22129c32edc64c610478368e1bc1f1dbc921.zip
meson-682d22129c32edc64c610478368e1bc1f1dbc921.tar.gz
meson-682d22129c32edc64c610478368e1bc1f1dbc921.tar.bz2
compilers: Tell mypy that the compiler mixins are just that
We do this by making the mixins inherit the Compiler class only when mypy is examining the code (using some clever inheritance shenanigans). This caught a bunch of issues, and also lets us delete a ton of code.
Diffstat (limited to 'mesonbuild/compilers/mixins/ccrx.py')
-rw-r--r--mesonbuild/compilers/mixins/ccrx.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/mesonbuild/compilers/mixins/ccrx.py b/mesonbuild/compilers/mixins/ccrx.py
index 4ac815a..fb82797 100644
--- a/mesonbuild/compilers/mixins/ccrx.py
+++ b/mesonbuild/compilers/mixins/ccrx.py
@@ -21,6 +21,13 @@ from ...mesonlib import EnvironmentException
if T.TYPE_CHECKING:
from ...environment import Environment
+ from ...compilers.compilers import Compiler
+else:
+ # This is a bit clever, for mypy we pretend that these mixins descend from
+ # Compiler, so we get all of the methods and attributes defined for us, but
+ # for runtime we make them descend from object (which all classes normally
+ # do). This gives up DRYer type checking, with no runtime impact
+ Compiler = object
ccrx_buildtype_args = {
'plain': [],
@@ -46,7 +53,7 @@ ccrx_debug_args = {
} # type: T.Dict[bool, T.List[str]]
-class CcrxCompiler:
+class CcrxCompiler(Compiler):
if T.TYPE_CHECKING:
is_cross = True