pre-commit: add isort hook and apply (#354)
This commit is contained in:
committed by
GitHub
parent
18a518efa7
commit
70310c9e8c
@@ -7,9 +7,16 @@ import sys
|
||||
import typing
|
||||
import warnings
|
||||
from abc import ABC
|
||||
from base64 import b64decode, b64encode
|
||||
from base64 import (
|
||||
b64decode,
|
||||
b64encode,
|
||||
)
|
||||
from copy import deepcopy
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from datetime import (
|
||||
datetime,
|
||||
timedelta,
|
||||
timezone,
|
||||
)
|
||||
from typing import (
|
||||
Any,
|
||||
Callable,
|
||||
@@ -29,9 +36,14 @@ from dateutil.parser import isoparse
|
||||
|
||||
from ._types import T
|
||||
from ._version import __version__
|
||||
from .casing import camel_case, safe_snake_case, snake_case
|
||||
from .casing import (
|
||||
camel_case,
|
||||
safe_snake_case,
|
||||
snake_case,
|
||||
)
|
||||
from .grpc.grpclib_client import ServiceStub
|
||||
|
||||
|
||||
# Proto 3 data types
|
||||
TYPE_ENUM = "enum"
|
||||
TYPE_BOOL = "bool"
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
from typing import TYPE_CHECKING, TypeVar
|
||||
from typing import (
|
||||
TYPE_CHECKING,
|
||||
TypeVar,
|
||||
)
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from grpclib._typing import IProtoMessage
|
||||
|
||||
from . import Message
|
||||
|
||||
# Bound type variable to allow methods to return `self` of subclasses
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from pkg_resources import get_distribution
|
||||
|
||||
|
||||
__version__ = get_distribution("betterproto").version
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import keyword
|
||||
import re
|
||||
|
||||
|
||||
# Word delimiters and symbols that will not be preserved when re-casing.
|
||||
# language=PythonRegExp
|
||||
SYMBOLS = "[^a-zA-Z0-9]*"
|
||||
|
||||
@@ -1,11 +1,18 @@
|
||||
import os
|
||||
import re
|
||||
from typing import Dict, List, Set, Tuple, Type
|
||||
from typing import (
|
||||
Dict,
|
||||
List,
|
||||
Set,
|
||||
Tuple,
|
||||
Type,
|
||||
)
|
||||
|
||||
from ..casing import safe_snake_case
|
||||
from ..lib.google import protobuf as google_protobuf
|
||||
from .naming import pythonize_class_name
|
||||
|
||||
|
||||
WRAPPER_TYPES: Dict[str, Type] = {
|
||||
".google.protobuf.DoubleValue": google_protobuf.DoubleValue,
|
||||
".google.protobuf.FloatValue": google_protobuf.FloatValue,
|
||||
|
||||
@@ -15,7 +15,11 @@ from typing import (
|
||||
|
||||
import grpclib.const
|
||||
|
||||
from .._types import ST, T
|
||||
from .._types import (
|
||||
ST,
|
||||
T,
|
||||
)
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from grpclib.client import Channel
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
from abc import ABC
|
||||
from collections.abc import AsyncIterable
|
||||
from typing import Any, Callable, Dict
|
||||
from typing import (
|
||||
Any,
|
||||
Callable,
|
||||
Dict,
|
||||
)
|
||||
|
||||
import grpclib
|
||||
import grpclib.server
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
import asyncio
|
||||
from typing import AsyncIterable, AsyncIterator, Iterable, Optional, TypeVar, Union
|
||||
from typing import (
|
||||
AsyncIterable,
|
||||
AsyncIterator,
|
||||
Iterable,
|
||||
Optional,
|
||||
TypeVar,
|
||||
Union,
|
||||
)
|
||||
|
||||
|
||||
T = TypeVar("T")
|
||||
|
||||
|
||||
@@ -3,7 +3,10 @@
|
||||
# plugin: python-betterproto
|
||||
import warnings
|
||||
from dataclasses import dataclass
|
||||
from typing import Dict, List
|
||||
from typing import (
|
||||
Dict,
|
||||
List,
|
||||
)
|
||||
|
||||
import betterproto
|
||||
from betterproto.grpc.grpclib_server import ServiceBase
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import os.path
|
||||
|
||||
|
||||
try:
|
||||
# betterproto[compiler] specific dependencies
|
||||
import black
|
||||
|
||||
@@ -7,9 +7,8 @@ from betterproto.lib.google.protobuf.compiler import (
|
||||
CodeGeneratorRequest,
|
||||
CodeGeneratorResponse,
|
||||
)
|
||||
|
||||
from betterproto.plugin.parser import generate_code
|
||||
from betterproto.plugin.models import monkey_patch_oneof_index
|
||||
from betterproto.plugin.parser import generate_code
|
||||
|
||||
|
||||
def main() -> None:
|
||||
|
||||
@@ -33,13 +33,28 @@ reference to `A` to `B`'s `fields` attribute.
|
||||
import builtins
|
||||
import re
|
||||
import textwrap
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Dict, Iterable, Iterator, List, Optional, Set, Type, Union
|
||||
from dataclasses import (
|
||||
dataclass,
|
||||
field,
|
||||
)
|
||||
from typing import (
|
||||
Dict,
|
||||
Iterable,
|
||||
Iterator,
|
||||
List,
|
||||
Optional,
|
||||
Set,
|
||||
Type,
|
||||
Union,
|
||||
)
|
||||
|
||||
import betterproto
|
||||
from betterproto import which_one_of
|
||||
from betterproto.casing import sanitize_name
|
||||
from betterproto.compile.importing import get_type_reference, parse_source_type_name
|
||||
from betterproto.compile.importing import (
|
||||
get_type_reference,
|
||||
parse_source_type_name,
|
||||
)
|
||||
from betterproto.compile.naming import (
|
||||
pythonize_class_name,
|
||||
pythonize_field_name,
|
||||
@@ -58,13 +73,17 @@ from betterproto.lib.google.protobuf import (
|
||||
from betterproto.lib.google.protobuf.compiler import CodeGeneratorRequest
|
||||
|
||||
from ..casing import sanitize_name
|
||||
from ..compile.importing import get_type_reference, parse_source_type_name
|
||||
from ..compile.importing import (
|
||||
get_type_reference,
|
||||
parse_source_type_name,
|
||||
)
|
||||
from ..compile.naming import (
|
||||
pythonize_class_name,
|
||||
pythonize_field_name,
|
||||
pythonize_method_name,
|
||||
)
|
||||
|
||||
|
||||
# Create a unique placeholder to deal with
|
||||
# https://stackoverflow.com/questions/51575931/class-inheritance-in-python-3-7-dataclasses
|
||||
PLACEHOLDER = object()
|
||||
|
||||
@@ -1,3 +1,15 @@
|
||||
import itertools
|
||||
import pathlib
|
||||
import sys
|
||||
from typing import (
|
||||
TYPE_CHECKING,
|
||||
Iterator,
|
||||
List,
|
||||
Set,
|
||||
Tuple,
|
||||
Union,
|
||||
)
|
||||
|
||||
from betterproto.lib.google.protobuf import (
|
||||
DescriptorProto,
|
||||
EnumDescriptorProto,
|
||||
@@ -11,10 +23,7 @@ from betterproto.lib.google.protobuf.compiler import (
|
||||
CodeGeneratorResponseFeature,
|
||||
CodeGeneratorResponseFile,
|
||||
)
|
||||
import itertools
|
||||
import pathlib
|
||||
import sys
|
||||
from typing import Iterator, List, Set, Tuple, TYPE_CHECKING, Union
|
||||
|
||||
from .compiler import outputfile_compiler
|
||||
from .models import (
|
||||
EnumDefinitionCompiler,
|
||||
@@ -30,6 +39,7 @@ from .models import (
|
||||
is_oneof,
|
||||
)
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from google.protobuf.descriptor import Descriptor
|
||||
|
||||
|
||||
Reference in New Issue
Block a user