From 10fc19ecb46bea3b32ec0775818e43c5c942acff Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Tue, 8 Mar 2022 15:10:46 -0800 Subject: modules: add typing to the modtest module --- mesonbuild/modules/modtest.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'mesonbuild') 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) -- cgit v1.1