From ed1a6debbb50e37b5bb528cf3afa43a6b574ac29 Mon Sep 17 00:00:00 2001 From: Thomas Pelletier Date: Thu, 1 Feb 2024 21:05:07 -0500 Subject: [PATCH 1/2] Automatically sort imports --- Makefile | 1 + pyproject.toml | 4 ++++ src/dispatch/__init__.py | 14 ++++++------- src/dispatch/coroutine.py | 4 ++-- src/dispatch/experimental/durable/durable.py | 1 + src/dispatch/experimental/durable/frame.pyi | 2 +- .../experimental/durable/generator.py | 6 +++--- src/dispatch/experimental/durable/registry.py | 1 - .../experimental/multicolor/__init__.py | 2 +- .../experimental/multicolor/compile.py | 5 +++-- src/dispatch/experimental/multicolor/parse.py | 2 +- src/dispatch/fastapi.py | 4 ++-- src/dispatch/sdk/v1/endpoint_pb2.py | 1 - src/dispatch/sdk/v1/endpoint_pb2.pyi | 17 ++++++++-------- src/dispatch/sdk/v1/executor_pb2.py | 2 +- src/dispatch/sdk/v1/executor_pb2.pyi | 20 +++++++++---------- src/dispatch/sdk/v1/key_pb2.pyi | 15 +++++++------- src/dispatch/sdk/v1/status_pb2.pyi | 5 +++-- .../experimental/durable/test_frame.py | 1 + .../experimental/durable/test_generator.py | 3 ++- .../experimental/multicolor/test_compile.py | 7 ++++--- .../experimental/multicolor/test_desugar.py | 4 ++-- .../experimental/multicolor/test_generator.py | 3 ++- tests/executor_service.py | 2 +- tests/task_service.py | 5 +---- tests/test_client.py | 5 +++-- tests/test_fastapi.py | 9 +++++---- tests/test_full.py | 9 +++++---- 28 files changed, 81 insertions(+), 73 deletions(-) diff --git a/Makefile b/Makefile index 3447e720..c98443dd 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,7 @@ dev: $(PYTHON) -m pip install -e .[dev] fmt: + $(PYTHON) -m isort . $(PYTHON) -m black . typecheck: diff --git a/pyproject.toml b/pyproject.toml index 00ec8744..d0de6125 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,12 +17,16 @@ dependencies = [ [project.optional-dependencies] dev = [ "black==24.1.0", + "isort==5.13.2", "mypy==1.8.0", "fastapi==0.109.0", "httpx==0.26.0", "coverage==7.4.1" ] +[tool.isort] +profile = "black" +src_paths = ["src"] [tool.coverage.run] omit = [ diff --git a/src/dispatch/__init__.py b/src/dispatch/__init__.py index 8f9b9239..9634f36b 100644 --- a/src/dispatch/__init__.py +++ b/src/dispatch/__init__.py @@ -2,24 +2,24 @@ """ from __future__ import annotations -import pickle + import os -from urllib.parse import urlparse -from functools import cached_property +import pickle from collections.abc import Iterable -from typing import Any, TypeAlias from dataclasses import dataclass +from functools import cached_property +from typing import Any, TypeAlias +from urllib.parse import urlparse -import grpc import google.protobuf import google.protobuf.any_pb2 import google.protobuf.message import google.protobuf.wrappers_pb2 +import grpc +import dispatch.coroutine import dispatch.sdk.v1.endpoint_pb2 as endpoint_pb import dispatch.sdk.v1.endpoint_pb2_grpc as endpoint_grpc -import dispatch.coroutine - __all__ = ["Client", "ExecutionID", "ExecutionInput", "ExecutionDef"] diff --git a/src/dispatch/coroutine.py b/src/dispatch/coroutine.py index 2e186c69..1ca13562 100644 --- a/src/dispatch/coroutine.py +++ b/src/dispatch/coroutine.py @@ -11,17 +11,17 @@ """ from __future__ import annotations + import enum import pickle -from typing import Any, Callable from dataclasses import dataclass +from typing import Any, Callable import google.protobuf.message from dispatch.sdk.v1 import executor_pb2 as executor_pb from dispatch.sdk.v1 import status_pb2 as status_pb - # Most types in this package are thin wrappers around the various protobuf # messages of ring.coroutine.v1. They provide some safeguards and ergonomics. diff --git a/src/dispatch/experimental/durable/durable.py b/src/dispatch/experimental/durable/durable.py index aaf8049f..761e6514 100644 --- a/src/dispatch/experimental/durable/durable.py +++ b/src/dispatch/experimental/durable/durable.py @@ -1,4 +1,5 @@ from types import FunctionType, GeneratorType + from .generator import DurableGenerator from .registry import register_function diff --git a/src/dispatch/experimental/durable/frame.pyi b/src/dispatch/experimental/durable/frame.pyi index 4bd01e2d..b3ff99c2 100644 --- a/src/dispatch/experimental/durable/frame.pyi +++ b/src/dispatch/experimental/durable/frame.pyi @@ -1,5 +1,5 @@ from types import FrameType -from typing import Any, Tuple, Generator +from typing import Any, Generator, Tuple def get_frame_ip(frame: FrameType | Generator) -> int: ... def set_frame_ip(frame: FrameType | Generator, ip: int): ... diff --git a/src/dispatch/experimental/durable/generator.py b/src/dispatch/experimental/durable/generator.py index 9caf7945..d7189554 100644 --- a/src/dispatch/experimental/durable/generator.py +++ b/src/dispatch/experimental/durable/generator.py @@ -1,8 +1,8 @@ -from types import GeneratorType, TracebackType, CodeType, FrameType +from types import CodeType, FrameType, GeneratorType, TracebackType from typing import Generator, TypeVar -from .registry import lookup_function -from . import frame as ext +from . import frame as ext +from .registry import lookup_function _YieldT = TypeVar("_YieldT", covariant=True) _SendT = TypeVar("_SendT", contravariant=True) diff --git a/src/dispatch/experimental/durable/registry.py b/src/dispatch/experimental/durable/registry.py index a0f70206..e6d28a44 100644 --- a/src/dispatch/experimental/durable/registry.py +++ b/src/dispatch/experimental/durable/registry.py @@ -1,6 +1,5 @@ from types import FunctionType - _REGISTRY: dict[str, FunctionType] = {} diff --git a/src/dispatch/experimental/multicolor/__init__.py b/src/dispatch/experimental/multicolor/__init__.py index 296a0ab9..01425f6d 100644 --- a/src/dispatch/experimental/multicolor/__init__.py +++ b/src/dispatch/experimental/multicolor/__init__.py @@ -1,4 +1,4 @@ from .compile import compile_function -from .yields import yields, CustomYield, GeneratorYield +from .yields import CustomYield, GeneratorYield, yields __all__ = ["compile_function", "yields", "CustomYield", "GeneratorYield"] diff --git a/src/dispatch/experimental/multicolor/compile.py b/src/dispatch/experimental/multicolor/compile.py index e0244abd..93afefaf 100644 --- a/src/dispatch/experimental/multicolor/compile.py +++ b/src/dispatch/experimental/multicolor/compile.py @@ -5,9 +5,10 @@ from enum import Enum from types import FunctionType, GeneratorType, MethodType from typing import cast + from .desugar import desugar_function -from .generator import is_generator, empty_generator -from .parse import parse_function, NoSourceError, repair_indentation +from .generator import empty_generator, is_generator +from .parse import NoSourceError, parse_function, repair_indentation from .template import rewrite_template from .yields import CustomYield, GeneratorYield diff --git a/src/dispatch/experimental/multicolor/parse.py b/src/dispatch/experimental/multicolor/parse.py index a49ab75a..680c1b90 100644 --- a/src/dispatch/experimental/multicolor/parse.py +++ b/src/dispatch/experimental/multicolor/parse.py @@ -1,7 +1,7 @@ import ast import inspect -from typing import cast from types import FunctionType +from typing import cast def parse_function(fn: FunctionType) -> tuple[ast.Module, ast.FunctionDef]: diff --git a/src/dispatch/fastapi.py b/src/dispatch/fastapi.py index e2799a12..455da923 100644 --- a/src/dispatch/fastapi.py +++ b/src/dispatch/fastapi.py @@ -18,15 +18,15 @@ def read_root(): """ import os -from typing import Any, Dict from collections.abc import Callable +from typing import Any, Dict import fastapi import fastapi.responses from httpx import _urlparse -from dispatch.sdk.v1 import executor_pb2 as executor_pb import dispatch.coroutine +from dispatch.sdk.v1 import executor_pb2 as executor_pb def configure( diff --git a/src/dispatch/sdk/v1/endpoint_pb2.py b/src/dispatch/sdk/v1/endpoint_pb2.py index 06032d20..d6708604 100644 --- a/src/dispatch/sdk/v1/endpoint_pb2.py +++ b/src/dispatch/sdk/v1/endpoint_pb2.py @@ -16,7 +16,6 @@ from google.protobuf import any_pb2 as google_dot_protobuf_dot_any__pb2 from google.protobuf import duration_pb2 as google_dot_protobuf_dot_duration__pb2 - DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile( b'\n\x1e\x64ispatch/sdk/v1/endpoint.proto\x12\x0f\x64ispatch.sdk.v1\x1a\x19google/protobuf/any.proto\x1a\x1egoogle/protobuf/duration.proto"U\n\x17\x43reateExecutionsRequest\x12:\n\nexecutions\x18\x01 \x03(\x0b\x32\x1a.dispatch.sdk.v1.ExecutionR\nexecutions",\n\x18\x43reateExecutionsResponse\x12\x10\n\x03ids\x18\x01 \x03(\tR\x03ids"\xc4\x01\n\tExecution\x12#\n\rcoroutine_uri\x18\x01 \x01(\tR\x0c\x63oroutineUri\x12+\n\x11\x63oroutine_version\x18\x02 \x01(\tR\x10\x63oroutineVersion\x12*\n\x05input\x18\x03 \x01(\x0b\x32\x14.google.protobuf.AnyR\x05input\x12\x39\n\nexpiration\x18\x04 \x01(\x0b\x32\x19.google.protobuf.DurationR\nexpiration2|\n\x0f\x45ndpointService\x12i\n\x10\x43reateExecutions\x12(.dispatch.sdk.v1.CreateExecutionsRequest\x1a).dispatch.sdk.v1.CreateExecutionsResponse"\x00\x42\x82\x01\n\x13\x63om.dispatch.sdk.v1B\rEndpointProtoP\x01\xa2\x02\x03\x44SX\xaa\x02\x0f\x44ispatch.Sdk.V1\xca\x02\x0f\x44ispatch\\Sdk\\V1\xe2\x02\x1b\x44ispatch\\Sdk\\V1\\GPBMetadata\xea\x02\x11\x44ispatch::Sdk::V1b\x06proto3' ) diff --git a/src/dispatch/sdk/v1/endpoint_pb2.pyi b/src/dispatch/sdk/v1/endpoint_pb2.pyi index 081227f5..117fa4e1 100644 --- a/src/dispatch/sdk/v1/endpoint_pb2.pyi +++ b/src/dispatch/sdk/v1/endpoint_pb2.pyi @@ -1,15 +1,14 @@ +from typing import ClassVar as _ClassVar +from typing import Iterable as _Iterable +from typing import Mapping as _Mapping +from typing import Optional as _Optional +from typing import Union as _Union + from google.protobuf import any_pb2 as _any_pb2 -from google.protobuf import duration_pb2 as _duration_pb2 -from google.protobuf.internal import containers as _containers from google.protobuf import descriptor as _descriptor +from google.protobuf import duration_pb2 as _duration_pb2 from google.protobuf import message as _message -from typing import ( - ClassVar as _ClassVar, - Iterable as _Iterable, - Mapping as _Mapping, - Optional as _Optional, - Union as _Union, -) +from google.protobuf.internal import containers as _containers DESCRIPTOR: _descriptor.FileDescriptor diff --git a/src/dispatch/sdk/v1/executor_pb2.py b/src/dispatch/sdk/v1/executor_pb2.py index fe084951..7440481b 100644 --- a/src/dispatch/sdk/v1/executor_pb2.py +++ b/src/dispatch/sdk/v1/executor_pb2.py @@ -13,10 +13,10 @@ _sym_db = _symbol_database.Default() -from dispatch.sdk.v1 import status_pb2 as dispatch_dot_sdk_dot_v1_dot_status__pb2 from google.protobuf import any_pb2 as google_dot_protobuf_dot_any__pb2 from google.protobuf import duration_pb2 as google_dot_protobuf_dot_duration__pb2 +from dispatch.sdk.v1 import status_pb2 as dispatch_dot_sdk_dot_v1_dot_status__pb2 DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile( b'\n\x1e\x64ispatch/sdk/v1/executor.proto\x12\x0f\x64ispatch.sdk.v1\x1a\x1c\x64ispatch/sdk/v1/status.proto\x1a\x19google/protobuf/any.proto\x1a\x1egoogle/protobuf/duration.proto"\xe3\x01\n\x0e\x45xecuteRequest\x12#\n\rcoroutine_uri\x18\x01 \x01(\tR\x0c\x63oroutineUri\x12+\n\x11\x63oroutine_version\x18\x02 \x01(\tR\x10\x63oroutineVersion\x12,\n\x05input\x18\x03 \x01(\x0b\x32\x14.google.protobuf.AnyH\x00R\x05input\x12\x44\n\rpoll_response\x18\x04 \x01(\x0b\x32\x1d.dispatch.sdk.v1.PollResponseH\x00R\x0cpollResponseB\x0b\n\tcoroutine"\xfb\x01\n\x0f\x45xecuteResponse\x12#\n\rcoroutine_uri\x18\x01 \x01(\tR\x0c\x63oroutineUri\x12+\n\x11\x63oroutine_version\x18\x02 \x01(\tR\x10\x63oroutineVersion\x12/\n\x06status\x18\x03 \x01(\x0e\x32\x17.dispatch.sdk.v1.StatusR\x06status\x12+\n\x04\x65xit\x18\x04 \x01(\x0b\x32\x15.dispatch.sdk.v1.ExitH\x00R\x04\x65xit\x12+\n\x04poll\x18\x05 \x01(\x0b\x32\x15.dispatch.sdk.v1.PollH\x00R\x04pollB\x0b\n\tdirective"k\n\x04\x45xit\x12/\n\x06result\x18\x01 \x01(\x0b\x32\x17.dispatch.sdk.v1.ResultR\x06result\x12\x32\n\ttail_call\x18\x02 \x01(\x0b\x32\x15.dispatch.sdk.v1.CallR\x08tailCall"d\n\x06Result\x12,\n\x06output\x18\x03 \x01(\x0b\x32\x14.google.protobuf.AnyR\x06output\x12,\n\x05\x65rror\x18\x05 \x01(\x0b\x32\x16.dispatch.sdk.v1.ErrorR\x05\x65rror"5\n\x05\x45rror\x12\x12\n\x04type\x18\x01 \x01(\tR\x04type\x12\x18\n\x07message\x18\x02 \x01(\tR\x07message"\xa0\x01\n\x04Poll\x12\x14\n\x05state\x18\x01 \x01(\x0cR\x05state\x12+\n\x05\x63\x61lls\x18\x02 \x03(\x0b\x32\x15.dispatch.sdk.v1.CallR\x05\x63\x61lls\x12\x34\n\x08max_wait\x18\x03 \x01(\x0b\x32\x19.google.protobuf.DurationR\x07maxWait\x12\x1f\n\x0bmax_results\x18\x04 \x01(\x05R\nmaxResults"[\n\x0cPollResponse\x12\x14\n\x05state\x18\x01 \x01(\x0cR\x05state\x12\x35\n\x07results\x18\x02 \x03(\x0b\x32\x1b.dispatch.sdk.v1.CallResultR\x07results"\xab\x01\n\x04\x43\x61ll\x12#\n\rcoroutine_uri\x18\x01 \x01(\tR\x0c\x63oroutineUri\x12+\n\x11\x63oroutine_version\x18\x02 \x01(\tR\x10\x63oroutineVersion\x12%\n\x0e\x63orrelation_id\x18\x03 \x01(\x04R\rcorrelationId\x12*\n\x05input\x18\x04 \x01(\x0b\x32\x14.google.protobuf.AnyR\x05input"\xb6\x01\n\nCallResult\x12#\n\rcoroutine_uri\x18\x01 \x01(\tR\x0c\x63oroutineUri\x12+\n\x11\x63oroutine_version\x18\x02 \x01(\tR\x10\x63oroutineVersion\x12%\n\x0e\x63orrelation_id\x18\x03 \x01(\x04R\rcorrelationId\x12/\n\x06result\x18\x04 \x01(\x0b\x32\x17.dispatch.sdk.v1.ResultR\x06result2a\n\x0f\x45xecutorService\x12N\n\x07\x45xecute\x12\x1f.dispatch.sdk.v1.ExecuteRequest\x1a .dispatch.sdk.v1.ExecuteResponse"\x00\x42\x82\x01\n\x13\x63om.dispatch.sdk.v1B\rExecutorProtoP\x01\xa2\x02\x03\x44SX\xaa\x02\x0f\x44ispatch.Sdk.V1\xca\x02\x0f\x44ispatch\\Sdk\\V1\xe2\x02\x1b\x44ispatch\\Sdk\\V1\\GPBMetadata\xea\x02\x11\x44ispatch::Sdk::V1b\x06proto3' diff --git a/src/dispatch/sdk/v1/executor_pb2.pyi b/src/dispatch/sdk/v1/executor_pb2.pyi index 0f04ec33..cac345b0 100644 --- a/src/dispatch/sdk/v1/executor_pb2.pyi +++ b/src/dispatch/sdk/v1/executor_pb2.pyi @@ -1,16 +1,16 @@ -from dispatch.sdk.v1 import status_pb2 as _status_pb2 +from typing import ClassVar as _ClassVar +from typing import Iterable as _Iterable +from typing import Mapping as _Mapping +from typing import Optional as _Optional +from typing import Union as _Union + from google.protobuf import any_pb2 as _any_pb2 -from google.protobuf import duration_pb2 as _duration_pb2 -from google.protobuf.internal import containers as _containers from google.protobuf import descriptor as _descriptor +from google.protobuf import duration_pb2 as _duration_pb2 from google.protobuf import message as _message -from typing import ( - ClassVar as _ClassVar, - Iterable as _Iterable, - Mapping as _Mapping, - Optional as _Optional, - Union as _Union, -) +from google.protobuf.internal import containers as _containers + +from dispatch.sdk.v1 import status_pb2 as _status_pb2 DESCRIPTOR: _descriptor.FileDescriptor diff --git a/src/dispatch/sdk/v1/key_pb2.pyi b/src/dispatch/sdk/v1/key_pb2.pyi index 157b97e5..ac8894fb 100644 --- a/src/dispatch/sdk/v1/key_pb2.pyi +++ b/src/dispatch/sdk/v1/key_pb2.pyi @@ -1,13 +1,12 @@ -from google.protobuf.internal import containers as _containers +from typing import ClassVar as _ClassVar +from typing import Iterable as _Iterable +from typing import Mapping as _Mapping +from typing import Optional as _Optional +from typing import Union as _Union + from google.protobuf import descriptor as _descriptor from google.protobuf import message as _message -from typing import ( - ClassVar as _ClassVar, - Iterable as _Iterable, - Mapping as _Mapping, - Optional as _Optional, - Union as _Union, -) +from google.protobuf.internal import containers as _containers DESCRIPTOR: _descriptor.FileDescriptor diff --git a/src/dispatch/sdk/v1/status_pb2.pyi b/src/dispatch/sdk/v1/status_pb2.pyi index 17786f17..9d584f46 100644 --- a/src/dispatch/sdk/v1/status_pb2.pyi +++ b/src/dispatch/sdk/v1/status_pb2.pyi @@ -1,7 +1,8 @@ -from google.protobuf.internal import enum_type_wrapper as _enum_type_wrapper -from google.protobuf import descriptor as _descriptor from typing import ClassVar as _ClassVar +from google.protobuf import descriptor as _descriptor +from google.protobuf.internal import enum_type_wrapper as _enum_type_wrapper + DESCRIPTOR: _descriptor.FileDescriptor class Status(int, metaclass=_enum_type_wrapper.EnumTypeWrapper): diff --git a/tests/dispatch/experimental/durable/test_frame.py b/tests/dispatch/experimental/durable/test_frame.py index 958f98ab..1be4a906 100644 --- a/tests/dispatch/experimental/durable/test_frame.py +++ b/tests/dispatch/experimental/durable/test_frame.py @@ -1,4 +1,5 @@ import unittest + from dispatch.experimental.durable import frame as ext diff --git a/tests/dispatch/experimental/durable/test_generator.py b/tests/dispatch/experimental/durable/test_generator.py index c8d3d35f..b39b0d9b 100644 --- a/tests/dispatch/experimental/durable/test_generator.py +++ b/tests/dispatch/experimental/durable/test_generator.py @@ -1,5 +1,6 @@ -import unittest import pickle +import unittest + from dispatch.experimental.durable import durable diff --git a/tests/dispatch/experimental/multicolor/test_compile.py b/tests/dispatch/experimental/multicolor/test_compile.py index d867fd23..a11efd47 100644 --- a/tests/dispatch/experimental/multicolor/test_compile.py +++ b/tests/dispatch/experimental/multicolor/test_compile.py @@ -1,14 +1,15 @@ import time import unittest +from enum import Enum from types import FunctionType from typing import Any + from dispatch.experimental.multicolor import ( - compile_function, - yields, CustomYield, GeneratorYield, + compile_function, + yields, ) -from enum import Enum class YieldTypes(Enum): diff --git a/tests/dispatch/experimental/multicolor/test_desugar.py b/tests/dispatch/experimental/multicolor/test_desugar.py index f1b2bc27..7b29d54e 100644 --- a/tests/dispatch/experimental/multicolor/test_desugar.py +++ b/tests/dispatch/experimental/multicolor/test_desugar.py @@ -1,9 +1,9 @@ import ast import unittest from types import FunctionType -from dispatch.experimental.multicolor.parse import parse_function -from dispatch.experimental.multicolor.desugar import desugar_function +from dispatch.experimental.multicolor.desugar import desugar_function +from dispatch.experimental.multicolor.parse import parse_function # Disable lint checks: # ruff: noqa diff --git a/tests/dispatch/experimental/multicolor/test_generator.py b/tests/dispatch/experimental/multicolor/test_generator.py index ba803c2a..c3b7bed1 100644 --- a/tests/dispatch/experimental/multicolor/test_generator.py +++ b/tests/dispatch/experimental/multicolor/test_generator.py @@ -1,6 +1,7 @@ import unittest -from dispatch.experimental.multicolor.parse import parse_function + from dispatch.experimental.multicolor.generator import YieldCounter, is_generator +from dispatch.experimental.multicolor.parse import parse_function class TestYieldCounter(unittest.TestCase): diff --git a/tests/executor_service.py b/tests/executor_service.py index 57b753fa..9d476941 100644 --- a/tests/executor_service.py +++ b/tests/executor_service.py @@ -1,5 +1,5 @@ -import httpx import grpc +import httpx from dispatch.sdk.v1 import executor_pb2 as executor_pb from dispatch.sdk.v1 import executor_pb2_grpc as executor_grpc diff --git a/tests/task_service.py b/tests/task_service.py index a2f83b55..f23e30ab 100644 --- a/tests/task_service.py +++ b/tests/task_service.py @@ -4,12 +4,9 @@ import dispatch.sdk.v1.endpoint_pb2 as endpoint_pb import dispatch.sdk.v1.endpoint_pb2_grpc as endpoint_grpc - import dispatch.sdk.v1.executor_pb2 as executor_pb import dispatch.sdk.v1.executor_pb2_grpc as executor_grpc - -from dispatch import Client, ExecutionInput, ExecutionID - +from dispatch import Client, ExecutionID, ExecutionInput _test_auth_token = "THIS_IS_A_TEST_AUTH_TOKEN" diff --git a/tests/test_client.py b/tests/test_client.py index 24df0175..105213a8 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -3,10 +3,11 @@ from unittest import mock import grpc -from google.protobuf import wrappers_pb2, any_pb2 +from google.protobuf import any_pb2, wrappers_pb2 -from dispatch import Client, ExecutionInput, ExecutionID +from dispatch import Client, ExecutionID, ExecutionInput from dispatch.coroutine import _any_unpickle as any_unpickle + from .task_service import ServerTest diff --git a/tests/test_fastapi.py b/tests/test_fastapi.py index b8b18619..8b29852c 100644 --- a/tests/test_fastapi.py +++ b/tests/test_fastapi.py @@ -2,15 +2,16 @@ import unittest from typing import Any -import httpx import fastapi -from fastapi.testclient import TestClient import google.protobuf.wrappers_pb2 +import httpx +from fastapi.testclient import TestClient -import dispatch.fastapi import dispatch.coroutine -from dispatch.coroutine import Input, Output, Error, Status +import dispatch.fastapi +from dispatch.coroutine import Error, Input, Output, Status from dispatch.sdk.v1 import executor_pb2 as executor_pb + from . import executor_service diff --git a/tests/test_full.py b/tests/test_full.py index 30424186..751b6a39 100644 --- a/tests/test_full.py +++ b/tests/test_full.py @@ -3,12 +3,13 @@ import fastapi from fastapi.testclient import TestClient -from dispatch import Client, ExecutionInput, ExecutionID -from dispatch.coroutine import Input, Output, Error, Status -from dispatch.coroutine import _any_unpickle as any_unpickle import dispatch.fastapi -from .test_client import ServerTest +from dispatch import Client, ExecutionID, ExecutionInput +from dispatch.coroutine import Error, Input, Output, Status +from dispatch.coroutine import _any_unpickle as any_unpickle + from . import executor_service +from .test_client import ServerTest class TestFullFastapi(unittest.TestCase): From f3b2416f3cb36bb1030ef002605c8392ada2eef6 Mon Sep 17 00:00:00 2001 From: Thomas Pelletier Date: Thu, 1 Feb 2024 21:08:14 -0500 Subject: [PATCH 2/2] Remove unused imports --- src/dispatch/__init__.py | 1 - src/dispatch/fastapi.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/dispatch/__init__.py b/src/dispatch/__init__.py index 9634f36b..5bc3e45f 100644 --- a/src/dispatch/__init__.py +++ b/src/dispatch/__init__.py @@ -7,7 +7,6 @@ import pickle from collections.abc import Iterable from dataclasses import dataclass -from functools import cached_property from typing import Any, TypeAlias from urllib.parse import urlparse diff --git a/src/dispatch/fastapi.py b/src/dispatch/fastapi.py index 455da923..04660c41 100644 --- a/src/dispatch/fastapi.py +++ b/src/dispatch/fastapi.py @@ -19,7 +19,7 @@ def read_root(): import os from collections.abc import Callable -from typing import Any, Dict +from typing import Dict import fastapi import fastapi.responses