diff --git a/promise/async_.py b/promise/async_.py index 21ac6e2..0e33c9c 100644 --- a/promise/async_.py +++ b/promise/async_.py @@ -1,10 +1,11 @@ # Based on https://github.com/petkaantonov/bluebird/blob/master/src/promise.js from collections import deque from threading import local +from typing import TYPE_CHECKING -if False: +if TYPE_CHECKING: from .promise import Promise - from typing import Any, Callable, Optional, Union # flake8: noqa + from typing import Any, Callable, Optional, Union class Async(local): diff --git a/promise/dataloader.py b/promise/dataloader.py index cb1dd0d..9fdc34f 100644 --- a/promise/dataloader.py +++ b/promise/dataloader.py @@ -5,10 +5,11 @@ from collections import Iterable from functools import partial from threading import local +from typing import TYPE_CHECKING from .promise import Promise, async_instance, get_default_scheduler -if False: +if TYPE_CHECKING: from typing import ( Any, List, diff --git a/promise/iterate_promise.py b/promise/iterate_promise.py index ba64f9c..ab5980a 100644 --- a/promise/iterate_promise.py +++ b/promise/iterate_promise.py @@ -1,5 +1,7 @@ # flake8: noqa -if False: +from typing import TYPE_CHECKING + +if TYPE_CHECKING: from .promise import Promise from typing import Iterator diff --git a/promise/promise.py b/promise/promise.py index ef9a45f..042f7e0 100644 --- a/promise/promise.py +++ b/promise/promise.py @@ -16,13 +16,13 @@ from .utils import deprecated, integer_types, string_types, text_type, binary_type, warn from .promise_list import PromiseList from .schedulers.immediate import ImmediateScheduler -from typing import TypeVar, Generic +from typing import TypeVar, Generic, TYPE_CHECKING # from .schedulers.gevent import GeventScheduler # from .schedulers.asyncio import AsyncioScheduler # from .schedulers.thread import ThreadScheduler -if False: +if TYPE_CHECKING: from typing import ( Type, List, diff --git a/promise/promise_list.py b/promise/promise_list.py index eeba766..860eb49 100644 --- a/promise/promise_list.py +++ b/promise/promise_list.py @@ -4,15 +4,14 @@ from collections.abc import Iterable except ImportError: from collections import Iterable +from typing import TYPE_CHECKING -if False: +if TYPE_CHECKING: from .promise import Promise from typing import ( Any, Optional, - Tuple, Union, - List, Type, Collection, ) # flake8: noqa