diff --git a/pyproject.toml b/pyproject.toml index 3666988..220dda5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,6 +6,7 @@ readme = "README.md" dependencies = [ "sigtools==4.0.1", + "typing_extensions>=4.6", ] requires-python = ">=3.8" diff --git a/synchronicity/combined_types.py b/synchronicity/combined_types.py index 5568323..d6bcb09 100644 --- a/synchronicity/combined_types.py +++ b/synchronicity/combined_types.py @@ -56,14 +56,10 @@ def __get__(self, instance, owner=None): class AsyncAndBlockingContextManager(typing_extensions.Protocol[CTX]): - def __enter__(self) -> CTX: - ... + def __enter__(self) -> CTX: ... - async def __aenter__(self) -> CTX: - ... + async def __aenter__(self) -> CTX: ... - def __exit__(self, typ, value, tb): - ... + def __exit__(self, typ, value, tb): ... - async def __aexit__(self, typ, value, tb): - ... + async def __aexit__(self, typ, value, tb): ... diff --git a/synchronicity/overload_tracking.py b/synchronicity/overload_tracking.py index 1ebd5df..db97a4c 100644 --- a/synchronicity/overload_tracking.py +++ b/synchronicity/overload_tracking.py @@ -19,6 +19,7 @@ def foo(a: typing.Union[bool, int]) -> typing.Union[bool, float]: # in the order they are declared foo_overloads = get_overloads(foo) """ + import contextlib import typing from unittest import mock diff --git a/synchronicity/type_stubs.py b/synchronicity/type_stubs.py index 1f68330..cbd8a98 100644 --- a/synchronicity/type_stubs.py +++ b/synchronicity/type_stubs.py @@ -5,6 +5,7 @@ implementation types directly (but translated to blocking). * Let synchronicity emit actual function bodies, to avoid runtime wrapping altogether """ + import collections import collections.abc import contextlib diff --git a/test/type_stub_test.py b/test/type_stub_test.py index 6a57f25..311ed8d 100644 --- a/test/type_stub_test.py +++ b/test/type_stub_test.py @@ -379,8 +379,7 @@ def foo() -> typing.Callable[..., typing.Any]: def test_typing_literal(): - def foo() -> typing.Literal["three", "str"]: - ... + def foo() -> typing.Literal["three", "str"]: ... src = _function_source(foo) assert "-> typing.Literal['three', 'str']" in src # "str" should not be eval:ed in a Literal!