aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers/mixins/pgi.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/pgi.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/pgi.py')
-rw-r--r--mesonbuild/compilers/mixins/pgi.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/mesonbuild/compilers/mixins/pgi.py b/mesonbuild/compilers/mixins/pgi.py
index d69abda..f6ad279 100644
--- a/mesonbuild/compilers/mixins/pgi.py
+++ b/mesonbuild/compilers/mixins/pgi.py
@@ -21,8 +21,14 @@ from pathlib import Path
from ..compilers import clike_debug_args, clike_optimization_args
if T.TYPE_CHECKING:
- from ...envconfig import MachineInfo
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
pgi_buildtype_args = {
'plain': [],
@@ -34,11 +40,7 @@ pgi_buildtype_args = {
} # type: T.Dict[str, T.List[str]]
-class PGICompiler:
-
- if T.TYPE_CHECKING:
- info = MachineInfo('', '', '', '')
- language = ''
+class PGICompiler(Compiler):
def __init__(self) -> None:
self.base_options = ['b_pch']