From 36301eaf8a043fe8cd862f86fd4e8e70e59d9f30 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Tue, 25 Jul 2023 10:04:08 -0700 Subject: [PATCH] modules/python3: use typed_kwargs for extension_module Just like python, but for the python3 module --- mesonbuild/modules/python3.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/mesonbuild/modules/python3.py b/mesonbuild/modules/python3.py index 065e8d7a2..9d160980c 100644 --- a/mesonbuild/modules/python3.py +++ b/mesonbuild/modules/python3.py @@ -14,13 +14,21 @@ from __future__ import annotations import sysconfig -from .. import mesonlib +import typing as T +from .. import mesonlib from . import ExtensionModule, ModuleInfo -from ..interpreterbase import typed_pos_args, noPosargs, noKwargs, permittedKwargs +from ..interpreter.type_checking import SHARED_MOD_KWS +from ..interpreterbase import typed_kwargs, typed_pos_args, noPosargs, noKwargs, permittedKwargs from ..build import known_shmod_kwargs from ..programs import ExternalProgram +if T.TYPE_CHECKING: + from ..interpreter.kwargs import SharedModule as SharedModuleKW + + +_MOD_KWARGS = [k for k in SHARED_MOD_KWS if k.name not in {'name_prefix', 'name_suffix'}] + class Python3Module(ExtensionModule): @@ -36,7 +44,8 @@ class Python3Module(ExtensionModule): }) @permittedKwargs(known_shmod_kwargs) - def extension_module(self, state, args, kwargs): + @typed_kwargs('python3.extension_module', *_MOD_KWARGS, allow_unknown=True) + def extension_module(self, state, args, kwargs: SharedModuleKW): if 'name_prefix' in kwargs: raise mesonlib.MesonException('Name_prefix is set automatically, specifying it is forbidden.') if 'name_suffix' in kwargs: