aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2022-03-08 15:10:46 -0800
committerEli Schwartz <eschwartz93@gmail.com>2022-05-23 23:32:47 -0400
commit10fc19ecb46bea3b32ec0775818e43c5c942acff (patch)
treecc748be9f67a090e8ba445f03cde7f6064df5493
parent1c52ac4e156c2f21d44cf800b112c5ea26878185 (diff)
downloadmeson-10fc19ecb46bea3b32ec0775818e43c5c942acff.zip
meson-10fc19ecb46bea3b32ec0775818e43c5c942acff.tar.gz
meson-10fc19ecb46bea3b32ec0775818e43c5c942acff.tar.bz2
modules: add typing to the modtest module
-rw-r--r--mesonbuild/modules/modtest.py21
-rwxr-xr-xrun_mypy.py1
2 files changed, 17 insertions, 5 deletions
diff --git a/mesonbuild/modules/modtest.py b/mesonbuild/modules/modtest.py
index dd2e2ff..e36899f 100644
--- a/mesonbuild/modules/modtest.py
+++ b/mesonbuild/modules/modtest.py
@@ -12,19 +12,30 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+from __future__ import annotations
+import typing as T
+
from . import ExtensionModule
-from ..interpreterbase import noKwargs
+from ..interpreterbase import noKwargs, noPosargs
+
+if T.TYPE_CHECKING:
+ from . import ModuleState
+ from ..interpreter.interpreter import Interpreter
+ from ..interpreterbase.baseobjects import TYPE_kwargs, TYPE_var
+
class TestModule(ExtensionModule):
- def __init__(self, interpreter):
+ def __init__(self, interpreter: Interpreter) -> None:
super().__init__(interpreter)
self.methods.update({
'print_hello': self.print_hello,
})
@noKwargs
- def print_hello(self, state, args, kwargs):
+ @noPosargs
+ def print_hello(self, state: ModuleState, args: T.List[TYPE_var], kwargs: TYPE_kwargs) -> None:
print('Hello from a Meson module')
-def initialize(*args, **kwargs):
- return TestModule(*args, **kwargs)
+
+def initialize(interp: Interpreter) -> TestModule:
+ return TestModule(interp)
diff --git a/run_mypy.py b/run_mypy.py
index d4fde4f..b7af49e 100755
--- a/run_mypy.py
+++ b/run_mypy.py
@@ -45,6 +45,7 @@ modules = [
'mesonbuild/modules/i18n.py',
'mesonbuild/modules/java.py',
'mesonbuild/modules/keyval.py',
+ 'mesonbuild/modules/modtest.py',
'mesonbuild/modules/qt.py',
'mesonbuild/modules/sourceset.py',
'mesonbuild/modules/unstable_external_project.py',