From cbbc936ed9811bdb5dd480bc2c5e10c3062532be Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 4 May 2024 02:33:55 +0200 Subject: Merging upstream version 0.18.6. Signed-off-by: Daniel Baumann --- compat.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'compat.py') diff --git a/compat.py b/compat.py index 9786fae..46d0c3b 100644 --- a/compat.py +++ b/compat.py @@ -1,4 +1,3 @@ -# coding: utf-8 from __future__ import annotations @@ -7,18 +6,23 @@ from __future__ import annotations import sys import os import io -import traceback from abc import abstractmethod import collections.abc +from ruamel.yaml.docinfo import Version # NOQA # fmt: off -from typing import Any, Dict, Optional, List, Union, BinaryIO, IO, Text, Tuple # NOQA -from typing import Optional # NOQA -try: - from typing import SupportsIndex as SupportsIndex # in order to reexport for mypy -except ImportError: - SupportsIndex = int # type: ignore +if False: # MYPY + from typing import Any, Dict, Optional, List, Union, BinaryIO, IO, Text, Tuple # NOQA + from typing import Optional # NOQA + try: + from typing import SupportsIndex as SupportsIndex # in order to reexport for mypy + except ImportError: + SupportsIndex = int # type: ignore + + StreamType = Any + StreamTextType = StreamType + VersionType = Union[str , Tuple[int, int] , List[int] , Version , None] # fmt: on _DEFAULT_YAML_VERSION = (1, 2) @@ -51,11 +55,6 @@ class ordereddict(OrderedDict): # type: ignore StringIO = io.StringIO BytesIO = io.BytesIO -StreamType = Any - -StreamTextType = StreamType -from ruamel.yaml.docinfo import Version # NOQA -VersionType = Union[str , Tuple[int, int] , List[int] , Version , None] builtins_module = 'builtins' @@ -117,6 +116,8 @@ class Nprint: self._file_name = file_name def __call__(self, *args: Any, **kw: Any) -> None: + import traceback + if not bool(_debug): return out = sys.stdout if self._file_name is None else open(self._file_name, 'a') -- cgit v1.2.3