summaryrefslogtreecommitdiff
path: root/mesonbuild/interpreterbase
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2022-03-01 23:55:42 -0500
committerEli Schwartz <eschwartz@archlinux.org>2022-03-07 19:09:50 -0500
commitc231c4bd2ad1a9b0ddb00a838c89566bc88d2a8e (patch)
treee2e782b9d7883b96a1bcecc13ddc51d6656bdf20 /mesonbuild/interpreterbase
parenta009eacc65ddb447edcfc9fd317ad828d9b3353a (diff)
downloadmeson-c231c4bd2ad1a9b0ddb00a838c89566bc88d2a8e.tar.gz
move a bunch of imports into TYPE_CHECKING blocks
These are only used for type checking, so don't bother importing them at runtime. Generally add future annotations at the same time, to make sure that existing uses of these imports don't need to be quoted.
Diffstat (limited to 'mesonbuild/interpreterbase')
-rw-r--r--mesonbuild/interpreterbase/decorators.py6
-rw-r--r--mesonbuild/interpreterbase/disabler.py7
-rw-r--r--mesonbuild/interpreterbase/interpreterbase.py5
3 files changed, 11 insertions, 7 deletions
diff --git a/mesonbuild/interpreterbase/decorators.py b/mesonbuild/interpreterbase/decorators.py
index 672ef5b9f..e678fd97f 100644
--- a/mesonbuild/interpreterbase/decorators.py
+++ b/mesonbuild/interpreterbase/decorators.py
@@ -11,12 +11,11 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+from __future__ import annotations
from .. import mesonlib, mlog
-from .baseobjects import TV_func, TYPE_var, TYPE_kwargs
from .disabler import Disabler
from .exceptions import InterpreterException, InvalidArguments
-from .operator import MesonOperator
from ._unholder import _unholder
from dataclasses import dataclass
@@ -30,8 +29,9 @@ if T.TYPE_CHECKING:
from typing_extensions import Protocol
from .. import mparser
- from .baseobjects import InterpreterObject
+ from .baseobjects import InterpreterObject, TV_func, TYPE_var, TYPE_kwargs
from .interpreterbase import SubProject
+ from .operator import MesonOperator
_TV_IntegerObject = T.TypeVar('_TV_IntegerObject', bound=InterpreterObject, contravariant=True)
_TV_ARG1 = T.TypeVar('_TV_ARG1', bound=TYPE_var, contravariant=True)
diff --git a/mesonbuild/interpreterbase/disabler.py b/mesonbuild/interpreterbase/disabler.py
index 63b914e59..182bb625c 100644
--- a/mesonbuild/interpreterbase/disabler.py
+++ b/mesonbuild/interpreterbase/disabler.py
@@ -11,10 +11,15 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+from __future__ import annotations
-from .baseobjects import MesonInterpreterObject, TYPE_var, TYPE_kwargs
import typing as T
+from .baseobjects import MesonInterpreterObject
+
+if T.TYPE_CHECKING:
+ from .baseobjects import TYPE_var, TYPE_kwargs
+
class Disabler(MesonInterpreterObject):
def method_call(self, method_name: str, args: T.List[TYPE_var], kwargs: TYPE_kwargs) -> TYPE_var:
if method_name == 'found':
diff --git a/mesonbuild/interpreterbase/interpreterbase.py b/mesonbuild/interpreterbase/interpreterbase.py
index 28211b051..85aabd163 100644
--- a/mesonbuild/interpreterbase/interpreterbase.py
+++ b/mesonbuild/interpreterbase/interpreterbase.py
@@ -14,6 +14,7 @@
# This class contains the basic functionality needed to run any interpreter
# or an interpreter-based tool.
+from __future__ import annotations
from .. import mparser, mesonlib
from .. import environment
@@ -26,10 +27,7 @@ from .baseobjects import (
ObjectHolder,
IterableObject,
- SubProject,
-
TYPE_var,
- TYPE_kwargs,
HoldableTypes,
)
@@ -54,6 +52,7 @@ import typing as T
import textwrap
if T.TYPE_CHECKING:
+ from .baseobjects import SubProject, TYPE_kwargs
from ..interpreter import Interpreter
HolderMapType = T.Dict[