diff options
author | Eli Schwartz <eschwartz@archlinux.org> | 2022-10-06 23:42:37 -0400 |
---|---|---|
committer | Eli Schwartz <eschwartz@archlinux.org> | 2023-02-01 17:01:30 -0500 |
commit | a21af43200e13fa65e12bdbe5116a0cecc4990b3 (patch) | |
tree | 4db989be7c51dd745fa17e09b60d64f64f6f6bcc /mesonbuild/interpreterbase/interpreterbase.py | |
parent | 680b5ff819bf36397ea560f802510bce5b83f6bc (diff) | |
download | meson-a21af43200e13fa65e12bdbe5116a0cecc4990b3.zip meson-a21af43200e13fa65e12bdbe5116a0cecc4990b3.tar.gz meson-a21af43200e13fa65e12bdbe5116a0cecc4990b3.tar.bz2 |
micro-optimize: define typing-only objects in TYPE_CHECKING
Union types that exist solely for use as annotations don't need to be
created in normal runs.
Diffstat (limited to 'mesonbuild/interpreterbase/interpreterbase.py')
-rw-r--r-- | mesonbuild/interpreterbase/interpreterbase.py | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/mesonbuild/interpreterbase/interpreterbase.py b/mesonbuild/interpreterbase/interpreterbase.py index 76fb465..f72ddc1 100644 --- a/mesonbuild/interpreterbase/interpreterbase.py +++ b/mesonbuild/interpreterbase/interpreterbase.py @@ -27,8 +27,6 @@ from .baseobjects import ( ObjectHolder, IterableObject, - TYPE_var, - HoldableTypes, ) @@ -52,26 +50,26 @@ import typing as T import textwrap if T.TYPE_CHECKING: - from .baseobjects import SubProject, TYPE_kwargs + from .baseobjects import SubProject, TYPE_kwargs, TYPE_var from ..interpreter import Interpreter -HolderMapType = T.Dict[ - T.Union[ - T.Type[mesonlib.HoldableObject], - T.Type[int], - T.Type[bool], - T.Type[str], - T.Type[list], - T.Type[dict], - ], - # For some reason, this has to be a callable and can't just be ObjectHolder[InterpreterObjectTypeVar] - T.Callable[[InterpreterObjectTypeVar, 'Interpreter'], ObjectHolder[InterpreterObjectTypeVar]] -] - -FunctionType = T.Dict[ - str, - T.Callable[[mparser.BaseNode, T.List[TYPE_var], T.Dict[str, TYPE_var]], TYPE_var] -] + HolderMapType = T.Dict[ + T.Union[ + T.Type[mesonlib.HoldableObject], + T.Type[int], + T.Type[bool], + T.Type[str], + T.Type[list], + T.Type[dict], + ], + # For some reason, this has to be a callable and can't just be ObjectHolder[InterpreterObjectTypeVar] + T.Callable[[InterpreterObjectTypeVar, 'Interpreter'], ObjectHolder[InterpreterObjectTypeVar]] + ] + + FunctionType = T.Dict[ + str, + T.Callable[[mparser.BaseNode, T.List[TYPE_var], T.Dict[str, TYPE_var]], TYPE_var] + ] class InterpreterBase: def __init__(self, source_root: str, subdir: str, subproject: 'SubProject'): |