From e8838109d85fb6966f08083dc7e114bbb35119ad Mon Sep 17 00:00:00 2001 From: Danny McClanahan <1305167+cosmicexplorer@users.noreply.github.com> Date: Fri, 11 Feb 2022 12:52:01 -0500 Subject: move typing_extensions.py back into typing.py =\ (#28549) --- lib/spack/external/py2/typing.py | 23 ++++++++++++++++++++++- lib/spack/external/py2/typing_extensions.py | 26 -------------------------- lib/spack/spack/test/llnl/util/tty/log.py | 6 ++++-- 3 files changed, 26 insertions(+), 29 deletions(-) delete mode 100644 lib/spack/external/py2/typing_extensions.py (limited to 'lib') diff --git a/lib/spack/external/py2/typing.py b/lib/spack/external/py2/typing.py index 7c36962d9f..a74bd4a1ea 100644 --- a/lib/spack/external/py2/typing.py +++ b/lib/spack/external/py2/typing.py @@ -1,4 +1,4 @@ -# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other +# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other # Spack Project Developers. See the top-level COPYRIGHT file for details. # # SPDX-License-Identifier: (Apache-2.0 OR MIT) @@ -80,3 +80,24 @@ get_origin = None get_type_hints = None no_type_check = None no_type_check_decorator = None + +## typing_extensions +# We get a ModuleNotFoundError when attempting to import anything from typing_extensions +# if we separate this into a separate typing_extensions.py file for some reason. + +# (1) Unparameterized types. +IntVar = object +Literal = object +NewType = object +Text = object + +# (2) Parameterized types. +Protocol = defaultdict(lambda: object) + +# (3) Macro for avoiding evaluation except during type checking. +TYPE_CHECKING = False + +# (4) Decorators. +final = lambda x: x +overload = lambda x: x +runtime_checkable = lambda x: x diff --git a/lib/spack/external/py2/typing_extensions.py b/lib/spack/external/py2/typing_extensions.py deleted file mode 100644 index ca6bc10999..0000000000 --- a/lib/spack/external/py2/typing_extensions.py +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other -# Spack Project Developers. See the top-level COPYRIGHT file for details. -# -# SPDX-License-Identifier: (Apache-2.0 OR MIT) -""" -This is a fake set of symbols to allow spack to import typing in python -versions where we do not support type checking (<3) -""" -from collections import defaultdict - -# (1) Unparameterized types. -IntVar = object -Literal = object -NewType = object -Text = object - -# (2) Parameterized types. -Protocol = defaultdict(lambda: object) - -# (3) Macro for avoiding evaluation except during type checking. -TYPE_CHECKING = False - -# (4) Decorators. -final = lambda x: x -overload = lambda x: x -runtime_checkable = lambda x: x diff --git a/lib/spack/spack/test/llnl/util/tty/log.py b/lib/spack/spack/test/llnl/util/tty/log.py index a5e6d8877d..7e5e728eb0 100644 --- a/lib/spack/spack/test/llnl/util/tty/log.py +++ b/lib/spack/spack/test/llnl/util/tty/log.py @@ -11,8 +11,10 @@ import os import signal import sys import time -from types import ModuleType # novm -from typing import Optional # novm +from typing import TYPE_CHECKING, Optional # novm + +if TYPE_CHECKING: + from types import ModuleType # novm import pytest -- cgit v1.2.3-60-g2f50