Remove dependency on stringcase, apply black
This commit is contained in:
parent
5d2f3a2cd9
commit
3ca75dadd7
@ -28,9 +28,8 @@ from typing import (
|
|||||||
|
|
||||||
|
|
||||||
import grpclib.const
|
import grpclib.const
|
||||||
import stringcase
|
|
||||||
|
|
||||||
from .casing import safe_snake_case, snake_case
|
from .casing import camel_case, safe_snake_case, snake_case
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from grpclib._protocols import IProtoMessage
|
from grpclib._protocols import IProtoMessage
|
||||||
@ -131,7 +130,7 @@ DATETIME_ZERO = datetime_default_gen()
|
|||||||
class Casing(enum.Enum):
|
class Casing(enum.Enum):
|
||||||
"""Casing constants for serialization."""
|
"""Casing constants for serialization."""
|
||||||
|
|
||||||
CAMEL = stringcase.camelcase
|
CAMEL = camel_case
|
||||||
SNAKE = snake_case
|
SNAKE = snake_case
|
||||||
|
|
||||||
|
|
||||||
|
@ -154,8 +154,10 @@ def import_cousin(current_package, imports, py_package, py_type):
|
|||||||
)
|
)
|
||||||
string_import = py_package[-1]
|
string_import = py_package[-1]
|
||||||
# Add trailing __ to avoid name mangling (python.org/dev/peps/pep-0008/#id34)
|
# Add trailing __ to avoid name mangling (python.org/dev/peps/pep-0008/#id34)
|
||||||
string_alias = f"{'_' * distance_up}" + safe_snake_case(
|
string_alias = (
|
||||||
".".join(py_package[len(shared_ancestry) :])
|
f"{'_' * distance_up}"
|
||||||
) + "__"
|
+ safe_snake_case(".".join(py_package[len(shared_ancestry) :]))
|
||||||
|
+ "__"
|
||||||
|
)
|
||||||
imports.add(f"from {string_from} import {string_import} as {string_alias}")
|
imports.add(f"from {string_from} import {string_import} as {string_alias}")
|
||||||
return f"{string_alias}.{py_type}"
|
return f"{string_alias}.{py_type}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user