pre-commit: add isort hook and apply (#354)
This commit is contained in:
committed by
GitHub
parent
18a518efa7
commit
70310c9e8c
@@ -1,10 +1,10 @@
|
||||
#!/usr/bin/env python
|
||||
import asyncio
|
||||
import os
|
||||
from pathlib import Path
|
||||
import platform
|
||||
import shutil
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import Set
|
||||
|
||||
from tests.util import (
|
||||
@@ -15,6 +15,7 @@ from tests.util import (
|
||||
protoc,
|
||||
)
|
||||
|
||||
|
||||
# Force pure-python implementation instead of C++, otherwise imports
|
||||
# break things because we can't properly reset the symbol database.
|
||||
os.environ["PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION"] = "python"
|
||||
|
@@ -3,18 +3,19 @@ import sys
|
||||
import uuid
|
||||
|
||||
import grpclib
|
||||
import grpclib.client
|
||||
import grpclib.metadata
|
||||
import grpclib.server
|
||||
import grpclib.client
|
||||
import pytest
|
||||
from betterproto.grpc.util.async_channel import AsyncChannel
|
||||
from grpclib.testing import ChannelFor
|
||||
|
||||
from betterproto.grpc.util.async_channel import AsyncChannel
|
||||
from tests.output_betterproto.service import (
|
||||
DoThingRequest,
|
||||
DoThingResponse,
|
||||
GetThingRequest,
|
||||
TestStub as ThingServiceClient,
|
||||
)
|
||||
from tests.output_betterproto.service import TestStub as ThingServiceClient
|
||||
|
||||
from .thing_service import ThingService
|
||||
|
||||
|
@@ -1,9 +1,11 @@
|
||||
import asyncio
|
||||
from dataclasses import dataclass
|
||||
from typing import AsyncIterator
|
||||
|
||||
import pytest
|
||||
|
||||
import betterproto
|
||||
from betterproto.grpc.util.async_channel import AsyncChannel
|
||||
from dataclasses import dataclass
|
||||
import pytest
|
||||
from typing import AsyncIterator
|
||||
|
||||
|
||||
@dataclass
|
||||
|
@@ -1,12 +1,14 @@
|
||||
from typing import Dict
|
||||
|
||||
import grpclib
|
||||
import grpclib.server
|
||||
|
||||
from tests.output_betterproto.service import (
|
||||
DoThingResponse,
|
||||
DoThingRequest,
|
||||
DoThingResponse,
|
||||
GetThingRequest,
|
||||
GetThingResponse,
|
||||
)
|
||||
import grpclib
|
||||
import grpclib.server
|
||||
from typing import Dict
|
||||
|
||||
|
||||
class ThingService:
|
||||
|
@@ -1,6 +1,6 @@
|
||||
from tests.output_betterproto.enum import (
|
||||
Test,
|
||||
Choice,
|
||||
Test,
|
||||
)
|
||||
|
||||
|
||||
|
@@ -1,7 +1,11 @@
|
||||
from typing import AsyncIterable, AsyncIterator
|
||||
from typing import (
|
||||
AsyncIterable,
|
||||
AsyncIterator,
|
||||
)
|
||||
|
||||
import pytest
|
||||
from grpclib.testing import ChannelFor
|
||||
|
||||
from tests.output_betterproto.example_service import (
|
||||
ExampleRequest,
|
||||
ExampleResponse,
|
||||
|
@@ -1,14 +1,14 @@
|
||||
import pytest
|
||||
|
||||
from google.protobuf import json_format
|
||||
|
||||
import betterproto
|
||||
from tests.output_betterproto.google_impl_behavior_equivalence import (
|
||||
Test,
|
||||
Foo,
|
||||
Test,
|
||||
)
|
||||
from tests.output_reference.google_impl_behavior_equivalence.google_impl_behavior_equivalence_pb2 import (
|
||||
Test as ReferenceTest,
|
||||
Foo as ReferenceFoo,
|
||||
Test as ReferenceTest,
|
||||
)
|
||||
|
||||
|
||||
|
@@ -1,9 +1,18 @@
|
||||
from typing import Any, Callable, Optional
|
||||
from typing import (
|
||||
Any,
|
||||
Callable,
|
||||
Optional,
|
||||
)
|
||||
|
||||
import pytest
|
||||
|
||||
import betterproto.lib.google.protobuf as protobuf
|
||||
import pytest
|
||||
from tests.mocks import MockChannel
|
||||
from tests.output_betterproto.googletypes_response import Input, TestStub
|
||||
from tests.output_betterproto.googletypes_response import (
|
||||
Input,
|
||||
TestStub,
|
||||
)
|
||||
|
||||
|
||||
test_cases = [
|
||||
(TestStub.get_double, protobuf.DoubleValue, 2.5),
|
||||
|
@@ -1,4 +1,5 @@
|
||||
import pytest
|
||||
|
||||
from tests.mocks import MockChannel
|
||||
from tests.output_betterproto.googletypes_response_embedded import (
|
||||
Input,
|
||||
|
@@ -1,4 +1,5 @@
|
||||
import pytest
|
||||
|
||||
from tests.mocks import MockChannel
|
||||
from tests.output_betterproto.import_service_input_message import (
|
||||
NestedRequestMessage,
|
||||
|
@@ -1,11 +1,12 @@
|
||||
import pytest
|
||||
import datetime
|
||||
|
||||
import pytest
|
||||
|
||||
import betterproto
|
||||
from tests.output_betterproto.oneof_default_value_serialization import (
|
||||
Test,
|
||||
Message,
|
||||
NestedMessage,
|
||||
Test,
|
||||
)
|
||||
|
||||
|
||||
|
@@ -1,6 +1,10 @@
|
||||
import json
|
||||
|
||||
from tests.output_betterproto.proto3_field_presence import Test, InnerTest, TestEnum
|
||||
from tests.output_betterproto.proto3_field_presence import (
|
||||
InnerTest,
|
||||
Test,
|
||||
TestEnum,
|
||||
)
|
||||
|
||||
|
||||
def test_null_fields_json():
|
||||
|
@@ -1,7 +1,7 @@
|
||||
from tests.output_betterproto.proto3_field_presence_oneof import (
|
||||
Test,
|
||||
InnerNested,
|
||||
Nested,
|
||||
Test,
|
||||
WithOptional,
|
||||
)
|
||||
|
||||
|
@@ -1,4 +1,7 @@
|
||||
from datetime import datetime, timedelta
|
||||
from datetime import (
|
||||
datetime,
|
||||
timedelta,
|
||||
)
|
||||
|
||||
from tests.output_betterproto.repeated_duration_timestamp import Test
|
||||
|
||||
|
@@ -1,6 +1,10 @@
|
||||
import pytest
|
||||
|
||||
from betterproto.casing import camel_case, pascal_case, snake_case
|
||||
from betterproto.casing import (
|
||||
camel_case,
|
||||
pascal_case,
|
||||
snake_case,
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
@@ -2,7 +2,10 @@ import warnings
|
||||
|
||||
import pytest
|
||||
|
||||
from tests.output_betterproto.deprecated import Message, Test
|
||||
from tests.output_betterproto.deprecated import (
|
||||
Message,
|
||||
Test,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
@@ -1,8 +1,18 @@
|
||||
from copy import (
|
||||
copy,
|
||||
deepcopy,
|
||||
)
|
||||
from dataclasses import dataclass
|
||||
from copy import copy, deepcopy
|
||||
from datetime import datetime
|
||||
from inspect import Parameter, signature
|
||||
from typing import Dict, List, Optional
|
||||
from inspect import (
|
||||
Parameter,
|
||||
signature,
|
||||
)
|
||||
from typing import (
|
||||
Dict,
|
||||
List,
|
||||
Optional,
|
||||
)
|
||||
|
||||
import betterproto
|
||||
|
||||
@@ -351,8 +361,10 @@ def test_recursive_message():
|
||||
|
||||
|
||||
def test_recursive_message_defaults():
|
||||
from tests.output_betterproto.recursivemessage import Intermediate
|
||||
from tests.output_betterproto.recursivemessage import Test as RecursiveMessage
|
||||
from tests.output_betterproto.recursivemessage import (
|
||||
Intermediate,
|
||||
Test as RecursiveMessage,
|
||||
)
|
||||
|
||||
msg = RecursiveMessage(name="bob", intermediate=Intermediate(42))
|
||||
|
||||
|
@@ -1,6 +1,9 @@
|
||||
import pytest
|
||||
|
||||
from betterproto.compile.importing import get_type_reference, parse_source_type_name
|
||||
from betterproto.compile.importing import (
|
||||
get_type_reference,
|
||||
parse_source_type_name,
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
@@ -5,7 +5,13 @@ import os
|
||||
import sys
|
||||
from collections import namedtuple
|
||||
from types import ModuleType
|
||||
from typing import Any, Dict, List, Set, Tuple
|
||||
from typing import (
|
||||
Any,
|
||||
Dict,
|
||||
List,
|
||||
Set,
|
||||
Tuple,
|
||||
)
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -19,6 +25,7 @@ from tests.util import (
|
||||
inputs_path,
|
||||
)
|
||||
|
||||
|
||||
# Force pure-python implementation instead of C++, otherwise imports
|
||||
# break things because we can't properly reset the symbol database.
|
||||
os.environ["PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION"] = "python"
|
||||
|
@@ -1,7 +1,10 @@
|
||||
from betterproto import __version__
|
||||
from pathlib import Path
|
||||
|
||||
import tomlkit
|
||||
|
||||
from betterproto import __version__
|
||||
|
||||
|
||||
PROJECT_TOML = Path(__file__).joinpath("..", "..", "pyproject.toml").resolve()
|
||||
|
||||
|
||||
|
@@ -1,11 +1,20 @@
|
||||
import asyncio
|
||||
from dataclasses import dataclass
|
||||
import importlib
|
||||
import os
|
||||
from pathlib import Path
|
||||
import sys
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
from types import ModuleType
|
||||
from typing import Callable, Dict, Generator, List, Optional, Tuple, Union
|
||||
from typing import (
|
||||
Callable,
|
||||
Dict,
|
||||
Generator,
|
||||
List,
|
||||
Optional,
|
||||
Tuple,
|
||||
Union,
|
||||
)
|
||||
|
||||
|
||||
os.environ["PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION"] = "python"
|
||||
|
||||
|
Reference in New Issue
Block a user