8000 pre-commit: add isort hook and apply (#354) · helloxms/python-betterproto@70310c9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 70310c9

Browse files
authored
pre-commit: add isort hook and apply (danielgtaylor#354)
1 parent 18a518e commit 70310c9

37 files changed

+216
-58
lines changed

.pre-commit-config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ ci:
22
autofix_prs: false
33

44
repos:
5+
- repo: https://github.com/pycqa/isort
6+
rev: 5.10.1
7+
hooks:
8+
- id: isort
9+
510
- repo: https://github.com/psf/black
611
rev: 22.1.0
712
hooks:

benchmarks/benchmarks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import betterproto
21
from dataclasses import dataclass
3-
42
from typing import List
53

4+
import betterproto
5+
66

77
@dataclass
88
class TestMessage(betterproto.Message):

pyproject.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,15 @@ help = "Run tests with multiple pythons"
100100
cmd = "black . --check --diff"
101101
help = "Check if code style is correct"
102102

103+
[tool.isort]
104+
py_version = 37
105+
profile = "black"
106+
force_single_line = false
107+
combine_as_imports = true
108+
lines_after_imports = 2
109+
include_trailing_comma = true
110+
force_grid_wrap = 2
111+
src_paths = ["src", "tests"]
103112

104113
[tool.black]
105114
target-version = ['py36']

src/betterproto/__init__.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,16 @@
77
import typing
88
import warnings
99
from abc import ABC
10-
from base64 import b64decode, b64encode
10+
from base64 import (
11+
b64decode,
12+
b64encode,
13+
)
1114
from copy import deepcopy
12-
from datetime import datetime, timedelta, timezone
15+
from datetime import (
16+
datetime,
17+
timedelta,
18+
timezone,
19+
)
1320
from typing import (
1421
Any,
1522
Callable,
@@ -29,9 +36,14 @@
2936

3037
from ._types import T
3138
from ._version import __version__
32-
from .casing import camel_case, safe_snake_case, snake_case
39+
from .casing import (
40+
camel_case,
41+
safe_snake_case,
42+
snake_case,
43+
)
3344
from .grpc.grpclib_client import ServiceStub
3445

46+
3547
# Proto 3 data types
3648
TYPE_ENUM = "enum"
3749
TYPE_BOOL = "bool"

src/betterproto/_types.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
from typing import TYPE_CHECKING, TypeVar
1+
from typing import (
2+
TYPE_CHECKING,
3+
TypeVar,
4+
)
5+
26

37
if TYPE_CHECKING:
48
from grpclib._typing import IProtoMessage
9+
510
from . import Message
611

712
# Bound type variable to allow methods to return `self` of subclasses

src/betterproto/_version.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
from pkg_resources import get_distribution
22

3+
34
__version__ = get_distribution("betterproto").version

src/betterproto/casing.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import keyword
22
import re
33

4+
45
# Word delimiters and symbols that will not be preserved when re-casing.
56
# language=PythonRegExp
67
SYMBOLS = "[^a-zA-Z0-9]*"

src/betterproto/compile/importing.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
import os
22
import re
3-
from typing import Dict, List, Set, Tuple, Type
3+
from typing import (
4+
Dict,
5+
List,
6+
Set,
7+
Tuple,
8+
Type,
9+
)
410

511
from ..casing import safe_snake_case
612
from ..lib.google import protobuf as google_protobuf
713
from .naming import pythonize_class_name
814

15+
916
WRAPPER_TYPES: Dict[str, Type] = {
1017
".google.protobuf.DoubleValue": google_protobuf.DoubleValue,
1118
".google.protobuf.FloatValue": google_protobuf.FloatValue,

src/betterproto/grpc/grpclib_client.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@
1515

1616
import grpclib.const
1717

18-
from .._types import ST, T
18+
from .._types import (
19+
ST,
20+
T,
21+
)
22+
1923

2024
if TYPE_CHECKING:
2125
from grpclib.client import Channel

src/betterproto/grpc/grpclib_server.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
from abc import ABC
22
from collections.abc import AsyncIterable
3-
from typing import Any, Callable, Dict
3+
from typing import (
4+
Any,
5+
Callable,
6+
Dict,
7+
)
48

59
import grpcli 3CBB b
610
import grpclib.server

0 commit comments

Comments
 (0)
0