diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2023-06-30 10:55:29 -0700 |
---|---|---|
committer | Eli Schwartz <eschwartz93@gmail.com> | 2023-07-25 15:50:21 -0400 |
commit | b0cd88ceae930b3ddc8165d43513141fa9486587 (patch) | |
tree | f4a397e7c977f19eb2424ca8a9688caa0968ab07 /mesonbuild/templates | |
parent | b082f0025032724216858bc0e2a78ae959287a56 (diff) | |
download | meson-b0cd88ceae930b3ddc8165d43513141fa9486587.zip meson-b0cd88ceae930b3ddc8165d43513141fa9486587.tar.gz meson-b0cd88ceae930b3ddc8165d43513141fa9486587.tar.bz2 |
minit: use a Protocol for arguments
Which gives better type hinting. It also points out that we're changing
the type of sourcefiles. That's now fixed
Diffstat (limited to 'mesonbuild/templates')
-rw-r--r-- | mesonbuild/templates/mesontemplates.py | 7 | ||||
-rw-r--r-- | mesonbuild/templates/samplefactory.py | 8 |
2 files changed, 11 insertions, 4 deletions
diff --git a/mesonbuild/templates/mesontemplates.py b/mesonbuild/templates/mesontemplates.py index 2868f7b..bc059fa 100644 --- a/mesonbuild/templates/mesontemplates.py +++ b/mesonbuild/templates/mesontemplates.py @@ -13,7 +13,10 @@ # limitations under the License. from __future__ import annotations -import argparse +import typing as T + +if T.TYPE_CHECKING: + from ..minit import Arguments meson_executable_template = '''project('{project_name}', {language}, version : '{version}', @@ -36,7 +39,7 @@ jar('{executable}', ''' -def create_meson_build(options: argparse.Namespace) -> None: +def create_meson_build(options: Arguments) -> None: if options.type != 'executable': raise SystemExit('\nGenerating a meson.build file from existing sources is\n' 'supported only for project type "executable".\n' diff --git a/mesonbuild/templates/samplefactory.py b/mesonbuild/templates/samplefactory.py index 1950837..5c91023 100644 --- a/mesonbuild/templates/samplefactory.py +++ b/mesonbuild/templates/samplefactory.py @@ -13,6 +13,8 @@ # limitations under the License. from __future__ import annotations +import typing as T + from mesonbuild.templates.valatemplates import ValaProject from mesonbuild.templates.fortrantemplates import FortranProject from mesonbuild.templates.objcpptemplates import ObjCppProject @@ -26,9 +28,11 @@ from mesonbuild.templates.cstemplates import CSharpProject from mesonbuild.templates.ctemplates import CProject from mesonbuild.templates.sampleimpl import SampleImpl -import argparse +if T.TYPE_CHECKING: + from ..minit import Arguments + -def sameple_generator(options: argparse.Namespace) -> SampleImpl: +def sameple_generator(options: Arguments) -> SampleImpl: return { 'c': CProject, 'cpp': CppProject, |