modules: add typing to the modtest module

pull/10303/head
Dylan Baker 3 years ago committed by Eli Schwartz
parent 1c52ac4e15
commit 10fc19ecb4
  1. 21
      mesonbuild/modules/modtest.py
  2. 1
      run_mypy.py

@ -12,19 +12,30 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from __future__ import annotations
import typing as T
from . import ExtensionModule 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): class TestModule(ExtensionModule):
def __init__(self, interpreter): def __init__(self, interpreter: Interpreter) -> None:
super().__init__(interpreter) super().__init__(interpreter)
self.methods.update({ self.methods.update({
'print_hello': self.print_hello, 'print_hello': self.print_hello,
}) })
@noKwargs @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') print('Hello from a Meson module')
def initialize(*args, **kwargs):
return TestModule(*args, **kwargs) def initialize(interp: Interpreter) -> TestModule:
return TestModule(interp)

@ -45,6 +45,7 @@ modules = [
'mesonbuild/modules/i18n.py', 'mesonbuild/modules/i18n.py',
'mesonbuild/modules/java.py', 'mesonbuild/modules/java.py',
'mesonbuild/modules/keyval.py', 'mesonbuild/modules/keyval.py',
'mesonbuild/modules/modtest.py',
'mesonbuild/modules/qt.py', 'mesonbuild/modules/qt.py',
'mesonbuild/modules/sourceset.py', 'mesonbuild/modules/sourceset.py',
'mesonbuild/modules/unstable_external_project.py', 'mesonbuild/modules/unstable_external_project.py',

Loading…
Cancel
Save