Do not unwrap google.protobuf.Value and unsupported wrapper types
This commit is contained in:
parent
e8991339e9
commit
53ce1255d3
@ -1,13 +1,15 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
from collections import defaultdict
|
|
||||||
import itertools
|
import itertools
|
||||||
import os.path
|
import os.path
|
||||||
|
import re
|
||||||
import stringcase
|
import stringcase
|
||||||
import sys
|
import sys
|
||||||
import textwrap
|
import textwrap
|
||||||
|
from collections import defaultdict
|
||||||
from typing import Dict, List, Optional, Type
|
from typing import Dict, List, Optional, Type
|
||||||
from betterproto.casing import safe_snake_case
|
from betterproto.casing import safe_snake_case
|
||||||
|
import betterproto
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# betterproto[compiler] specific dependencies
|
# betterproto[compiler] specific dependencies
|
||||||
@ -259,11 +261,13 @@ def generate_code(request, response):
|
|||||||
field_type = f.Type.Name(f.type).lower()[5:]
|
field_type = f.Type.Name(f.type).lower()[5:]
|
||||||
|
|
||||||
field_wraps = ""
|
field_wraps = ""
|
||||||
if f.type_name.startswith(
|
match_wrapper = re.match(
|
||||||
".google.protobuf"
|
"\\.google\\.protobuf\\.(.+)Value", f.type_name
|
||||||
) and f.type_name.endswith("Value"):
|
)
|
||||||
w = f.type_name.split(".").pop()[:-5].upper()
|
if match_wrapper:
|
||||||
field_wraps = f"betterproto.TYPE_{w}"
|
wrapped_type = "TYPE_" + match_wrapper.group(1).upper()
|
||||||
|
if wrapped_type in dir(betterproto):
|
||||||
|
field_wraps = f"betterproto.{wrapped_type}"
|
||||||
|
|
||||||
map_types = None
|
map_types = None
|
||||||
if f.type == 11:
|
if f.type == 11:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user