From 21ada1750b2aaa504211f3ac457fee0e799de886 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Mon, 24 Feb 2020 15:31:39 -0800 Subject: [PATCH] make a module for typing-related things --- babi/_types.py | 6 ++++++ babi/list_spy.py | 6 +----- tests/features/conftest.py | 7 +------ 3 files changed, 8 insertions(+), 11 deletions(-) create mode 100644 babi/_types.py diff --git a/babi/_types.py b/babi/_types.py new file mode 100644 index 0000000..b3f97e0 --- /dev/null +++ b/babi/_types.py @@ -0,0 +1,6 @@ +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from typing import Protocol # python3.8+ +else: + Protocol = object diff --git a/babi/list_spy.py b/babi/list_spy.py index aaf4215..f3dc86b 100644 --- a/babi/list_spy.py +++ b/babi/list_spy.py @@ -2,12 +2,8 @@ import functools from typing import Callable from typing import Iterator from typing import List -from typing import TYPE_CHECKING -if TYPE_CHECKING: - from typing import Protocol # python3.8+ -else: - Protocol = object +from babi._types import Protocol class MutableSequenceNoSlice(Protocol): diff --git a/tests/features/conftest.py b/tests/features/conftest.py index 93e7335..5250cfb 100644 --- a/tests/features/conftest.py +++ b/tests/features/conftest.py @@ -5,21 +5,16 @@ import shlex import sys from typing import List from typing import NamedTuple -from typing import TYPE_CHECKING from typing import Union from unittest import mock import pytest +from babi._types import Protocol from babi.main import main from babi.screen import VERSION_STR from testing.runner import PrintsErrorRunner -if TYPE_CHECKING: - from typing import Protocol -else: - Protocol = object - @pytest.fixture(autouse=True) def xdg_data_home(tmpdir):